Class FixedTabularSpreadSheetReader

  • All Implemented Interfaces:
    AdditionalInformationHandler, Destroyable, ErrorProvider, GlobalInfoSupporter, EncodingSupporter, FileFormatHandler, LoggingLevelHandler, LoggingSupporter, LocaleSupporter, OptionHandlingLocaleSupporter, OptionHandler, SizeOfHandler, Stoppable, StoppableWithFeedback, MissingValueSpreadSheetReader, NoHeaderSpreadSheetReader, SpreadSheetReader, WindowedSpreadSheetReader, DataRowTypeHandler, SpreadSheetTypeHandler, Serializable

    public class FixedTabularSpreadSheetReader
    extends AbstractSpreadSheetReaderWithMissingValueSupport
    implements OptionHandlingLocaleSupporter, NoHeaderSpreadSheetReader, WindowedSpreadSheetReader
    Reads simple tabular text files with fixed column widths, as used by dot matrix printers in days gone by.

    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
        min-user-mode: Expert
     
    -data-row-type <adams.data.spreadsheet.DataRow> (property: dataRowType)
        The type of row to use for the data.
        default: adams.data.spreadsheet.DenseDataRow
     
    -spreadsheet-type <adams.data.spreadsheet.SpreadSheet> (property: spreadSheetType)
        The type of spreadsheet to use for the data.
        default: adams.data.spreadsheet.DefaultSpreadSheet
     
    -missing <adams.core.base.BaseRegExp> (property: missingValue)
        The placeholder for missing values.
        default:
        more: https://docs.oracle.com/javase/tutorial/essential/regex/
        https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html
     
    -encoding <adams.core.base.BaseCharset> (property: encoding)
        The type of encoding to use when reading using a reader, leave empty for
        default.
        default: Default
     
    -column-width <adams.core.base.BaseInteger> [-column-width ...] (property: columnWidth)
        The width in characters to use for the columns; if only one is specified
        then this is used for all columns.
        default: 10
     
    -trim <boolean> (property: trim)
        If enabled, the content of the cells gets trimmed before added.
        default: false
     
    -text-columns <adams.core.Range> (property: textColumns)
        The range of columns to treat as text.
        default:
        example: A range is a comma-separated list of single 1-based indices or sub-ranges of indices ('start-end'); 'inv(...)' inverts the range '...'; the following placeholders can be used as well: first, second, third, last_2, last_1, last
     
    -datetime-columns <adams.core.Range> (property: dateTimeColumns)
        The range of columns to treat as date/time msec.
        default:
        example: A range is a comma-separated list of single 1-based indices or sub-ranges of indices ('start-end'); 'inv(...)' inverts the range '...'; the following placeholders can be used as well: first, second, third, last_2, last_1, last
     
    -datetime-format <adams.data.DateFormatString> (property: dateTimeFormat)
        The format for date/time msecs.
        default: yyyy-MM-dd HH:mm:ss
        more: https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html
     
    -datetime-lenient <boolean> (property: dateTimeLenient)
        Whether date/time msec parsing is lenient or not.
        default: false
     
    -datetime-type <TIME|TIME_MSEC|DATE|DATE_TIME|DATE_TIME_MSEC> (property: dateTimeType)
        How to interpret the date/time data.
        default: DATE_TIME
     
    -no-header <boolean> (property: noHeader)
        If enabled, all rows get added as data rows and a dummy header will get 
        inserted.
        default: false
     
    -custom-column-headers <java.lang.String> (property: customColumnHeaders)
        The custom headers to use for the columns instead (comma-separated list);
         ignored if empty.
        default: 
     
    -first-row <int> (property: firstRow)
        The index of the first row to retrieve (1-based).
        default: 1
        minimum: 1
     
    -num-rows <int> (property: numRows)
        The number of data rows to retrieve; use -1 for unlimited.
        default: -1
        minimum: -1
     
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_ColumnWidth

        protected BaseInteger[] m_ColumnWidth
        the column width.
      • m_TextColumns

        protected Range m_TextColumns
        the columns to treat as text.
      • m_DateTimeColumns

        protected Range m_DateTimeColumns
        the columns to treat as date/time.
      • m_DateTimeFormat

        protected DateFormatString m_DateTimeFormat
        the format string for the date/times.
      • m_DateTimeLenient

        protected boolean m_DateTimeLenient
        whether date/time parsing is lenient.
      • m_TimeZone

        protected TimeZone m_TimeZone
        the timezone to use.
      • m_Locale

        protected Locale m_Locale
        the locale to use.
      • m_NoHeader

        protected boolean m_NoHeader
        whether the file has a header or not.
      • m_CustomColumnHeaders

        protected String m_CustomColumnHeaders
        the comma-separated list of column header names.
      • m_Trim

        protected boolean m_Trim
        whether to trim the cells.
      • m_FirstRow

        protected int m_FirstRow
        the first row to retrieve (1-based).
      • m_NumRows

        protected int m_NumRows
        the number of rows to retrieve (less than 1 = unlimited).
      • m_FirstLine

        protected transient String m_FirstLine
        the internal buffer for the first row.
    • Constructor Detail

      • FixedTabularSpreadSheetReader

        public FixedTabularSpreadSheetReader()
    • Method Detail

      • setColumnWidth

        public void setColumnWidth​(BaseInteger[] value)
        Sets the column width.
        Parameters:
        value - the width in characters
      • getColumnWidth

        public BaseInteger[] getColumnWidth()
        Returns the column width.
        Returns:
        the width in characters
      • columnWidthTipText

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

        public void setTextColumns​(Range value)
        Sets the range of columns to treat as text.
        Parameters:
        value - the range
      • getTextColumns

        public Range getTextColumns()
        Returns the range of columns to treat as text.
        Returns:
        the range
      • textColumnsTipText

        public String textColumnsTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the gui
      • setDateTimeColumns

        public void setDateTimeColumns​(Range value)
        Sets the range of columns to treat as date/time msec.
        Parameters:
        value - the range
      • getDateTimeColumns

        public Range getDateTimeColumns()
        Returns the range of columns to treat as date/time msec.
        Returns:
        the range
      • dateTimeColumnsTipText

        public String dateTimeColumnsTipText()
        Returns the tip date for this property.
        Returns:
        tip date for this property suitable for displaying in the gui
      • setDateTimeFormat

        public void setDateTimeFormat​(DateFormatString value)
        Sets the format for date/time msec columns.
        Parameters:
        value - the format
      • getDateTimeFormat

        public DateFormatString getDateTimeFormat()
        Returns the format for date/time msec columns.
        Returns:
        the format
      • dateTimeFormatTipText

        public String dateTimeFormatTipText()
        Returns the tip date/time for this property.
        Returns:
        tip date for this property suitable for displaying in the gui
      • setDateTimeLenient

        public void setDateTimeLenient​(boolean value)
        Sets whether parsing of date/time msecs is to be lenient or not.
        Parameters:
        value - if true lenient parsing is used, otherwise not
        See Also:
        DateFormat.setLenient(boolean)
      • isDateTimeLenient

        public boolean isDateTimeLenient()
        Returns whether the parsing of date/time msecs is lenient or not.
        Returns:
        true if parsing is lenient
        See Also:
        DateFormat.isLenient()
      • dateTimeLenientTipText

        public String dateTimeLenientTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the gui
      • setDateTimeType

        public void setDateTimeType​(BasicDateTimeType value)
        Sets the type for date/time columns.
        Parameters:
        value - the type
      • getDateTimeType

        public BasicDateTimeType getDateTimeType()
        Returns the type for date/time columns.
        Returns:
        the type
      • dateTimeTypeTipText

        public String dateTimeTypeTipText()
        Returns the tip date/time for this property.
        Returns:
        tip date for this property suitable for displaying in the gui
      • setTimeZone

        public void setTimeZone​(TimeZone value)
        Sets the time zone to use.
        Parameters:
        value - the time zone
      • getTimeZone

        public TimeZone getTimeZone()
        Returns the time zone in use.
        Returns:
        the time zone
      • timeZoneTipText

        public String timeZoneTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the gui
      • setLocale

        public void setLocale​(Locale value)
        Sets the locale to use.
        Specified by:
        setLocale in interface LocaleSupporter
        Parameters:
        value - the locale
      • localeTipText

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

        public void setNoHeader​(boolean value)
        Sets whether the file contains a header row or not.
        Specified by:
        setNoHeader in interface NoHeaderSpreadSheetReader
        Parameters:
        value - true if no header row available
      • getNoHeader

        public boolean getNoHeader()
        Returns whether the file contains a header row or not.
        Specified by:
        getNoHeader in interface NoHeaderSpreadSheetReader
        Returns:
        true if no header row available
      • noHeaderTipText

        public String noHeaderTipText()
        Returns the tip text for this property.
        Specified by:
        noHeaderTipText in interface NoHeaderSpreadSheetReader
        Returns:
        tip text for this property suitable for displaying in the gui
      • setTrim

        public void setTrim​(boolean value)
        Sets whether to trim the cell content.
        Parameters:
        value - if true the content gets trimmed
      • getTrim

        public boolean getTrim()
        Returns whether to trim the cell content.
        Returns:
        true if to trim content
      • trimTipText

        public String trimTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the gui
      • setFirstRow

        public void setFirstRow​(int value)
        Sets the first row to return.
        Specified by:
        setFirstRow in interface WindowedSpreadSheetReader
        Parameters:
        value - the first row (1-based), greater than 0
      • getFirstRow

        public int getFirstRow()
        Returns the first row to return.
        Specified by:
        getFirstRow in interface WindowedSpreadSheetReader
        Returns:
        the first row (1-based), greater than 0
      • firstRowTipText

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

        public void setNumRows​(int value)
        Sets the number of data rows to return.
        Specified by:
        setNumRows in interface WindowedSpreadSheetReader
        Parameters:
        value - the number of rows, -1 for unlimited
      • getNumRows

        public int getNumRows()
        Returns the number of data rows to return.
        Specified by:
        getNumRows in interface WindowedSpreadSheetReader
        Returns:
        the number of rows, -1 for unlimited
      • numRowsTipText

        public String numRowsTipText()
        Returns the tip text for this property.
        Specified by:
        numRowsTipText in interface WindowedSpreadSheetReader
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.