Class AbstractSpreadSheetReader

    • Field Detail

      • m_DataRowType

        protected DataRow m_DataRowType
        the data row type to use.
      • m_SpreadSheetType

        protected SpreadSheet m_SpreadSheetType
        the type of spreadsheet to use.
      • m_Quiet

        protected boolean m_Quiet
        whether to suppress logging output in the spreadsheet, e.g., parse errors of formulas.
      • m_OnlyStoreFormulas

        protected boolean m_OnlyStoreFormulas
        whether to only store formulas and not evaluate them.
      • m_Stopped

        protected boolean m_Stopped
        whether the read process was stopped through an external source.
      • m_Encoding

        protected BaseCharset m_Encoding
        the encoding to use.
      • m_LastError

        protected String m_LastError
        the last error that occurred.
    • Constructor Detail

      • AbstractSpreadSheetReader

        public AbstractSpreadSheetReader()
    • Method Detail

      • getDefaultSpreadSheet

        protected SpreadSheet getDefaultSpreadSheet()
        Returns the default spreadsheet type.
        Returns:
        the default
      • getDefaultDataRowType

        protected DataRow getDefaultDataRowType()
        Returns the default row type.
        Returns:
        the default
      • setEncoding

        public void setEncoding​(BaseCharset value)
        Sets the encoding to use.
        Specified by:
        setEncoding in interface EncodingSupporter
        Parameters:
        value - the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
      • getEncoding

        public BaseCharset getEncoding()
        Returns the encoding to use.
        Specified by:
        getEncoding in interface EncodingSupporter
        Returns:
        the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
      • encodingTipText

        public String encodingTipText()
        Returns the tip text for this property.
        Specified by:
        encodingTipText in interface EncodingSupporter
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setQuiet

        public void setQuiet​(boolean value)
        Sets whether to suppress logging output in the spreasdheet, e.g., from parsing errors of formulas.
        Parameters:
        value - true if to suppress
      • isQuiet

        public boolean isQuiet()
        Returns whether to suppress logging output in the spreasdheet, e.g., from parsing errors of formulas.
        Returns:
        true if to suppress
      • quietTipText

        public String quietTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setOnlyStoreFormulas

        public void setOnlyStoreFormulas​(boolean value)
        Sets whether to only store formulas and not evaluate them.
        Parameters:
        value - true to store only
      • getOnlyStoreFormulas

        public boolean getOnlyStoreFormulas()
        Returns whether to only store formulas and not evaluate them.
        Returns:
        true if only stored
      • onlyStoreFormulasTipText

        public String onlyStoreFormulasTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • read

        public SpreadSheet read​(File file)
        Reads the spreadsheet from the specified file.
        Specified by:
        read in interface SpreadSheetReader
        Parameters:
        file - the file to read from
        Returns:
        null in case of an error, otherwise the spreadsheet
      • getInputType

        protected abstract AbstractSpreadSheetReader.InputType getInputType()
        Returns how to read the data, from a file, stream or reader.
        Returns:
        how to read the data
      • canDecompress

        protected boolean canDecompress​(String filename)
        Returns whether the file should get decompressed, i.e., supportsCompressedInput() returns true and the filename ends with ".gz".
        Parameters:
        filename - the filename to check
        Returns:
        true if decompression should occur
      • check

        protected void check()
        Hook method to perform some checks before performing the actual read.

        Default implementation does nothing.
      • read

        public SpreadSheet read​(InputStream stream)
        Reads the spreadsheet from the stream. The caller must ensure to close the stream.
        Specified by:
        read in interface SpreadSheetReader
        Parameters:
        stream - the stream to read from
        Returns:
        the spreadsheet or null in case of an error
      • read

        public SpreadSheet read​(Reader r)
        Reads the spreadsheet from the given reader. The caller must ensure to close the reader.
        Specified by:
        read in interface SpreadSheetReader
        Parameters:
        r - the reader to read from
        Returns:
        the spreadsheet or null in case of an error
      • doRead

        protected SpreadSheet doRead​(Reader r)
        Performs the actual reading.

        Default implementation returns null.
        Parameters:
        r - the reader to read from
        Returns:
        the spreadsheet or null in case of an error
        See Also:
        getInputType()
      • doRead

        protected SpreadSheet doRead​(InputStream in)
        Performs the actual reading.

        Default implementation returns null.
        Parameters:
        in - the input stream to read from
        Returns:
        the spreadsheet or null in case of an error
        See Also:
        getInputType()
      • setLastError

        protected void setLastError​(String value)
        Sets the value for the last error that occurred during read.
        Parameters:
        value - the error string, null if none occurred
      • getReaders

        public static String[] getReaders()
        Returns a list with classnames of readers.
        Returns:
        the reader classnames
      • runReader

        public static void runReader​(Class env,
                                     Class reader,
                                     String[] args)
        Runs the reader from commandline.
        Parameters:
        env - the environment class to use
        reader - the reader to execute
        args - the commandline arguments, use --input to specify the input file/dir and --output-dir to specify directory to save them as .spec files