Class FlatFileParser.Data

java.lang.Object
net.sf.basedb.util.parser.FlatFileParser.Data
Direct Known Subclasses:
FlatFileParser.ExcelData
Enclosing class:
FlatFileParser

public static class FlatFileParser.Data extends Object
This class holds data about a line parsed by the FlatFileParser.hasMoreData() method.
Version:
2.0
Author:
Nicklas
See Also:
  • Field Details

    • lineNo

      private final int lineNo
    • dataLineNo

      private final int dataLineNo
    • result

      private final String[] result
    • line

      private final String line
    • emptyIsNull

      private final boolean emptyIsNull
    • nullIsNull

      private final boolean nullIsNull
    • trimWhiteSpace

      private final boolean trimWhiteSpace
  • Constructor Details

    • Data

      private Data(int lineNo, int dataLineNo, String line, String[] columns, boolean emptyIsNull, boolean nullIsNull, boolean trimWhiteSpace)
      Create a new data object.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • lineNo

      public int lineNo()
      The line number of the data in the input stream.
      Returns:
      The line number
    • dataLineNo

      public int dataLineNo()
      The line number of the data in the current section.
      Returns:
      The line number
    • line

      public String line()
      The entire line as it was read from the input stream.
      Returns:
      A string
    • columns

      public int columns()
      The number of columns as determined by the FlatFileParser.setDataSplitterRegexp(Pattern) regular expression.
      Returns:
      The number of columns in the data line
    • get

      @Deprecated public String get(int index)
      Deprecated.
      In 3.15, use getString(int) instead or one of the other getXxx() method to return a given data type directly
      Get the value in the specified column.
      Parameters:
      index - The index for the column, starting at 0
      Returns:
      The value in the column
    • data

      public String[] data()
      The data line as an array of strings.
      Since:
      2.15
    • getString

      public String getString(int index)
      Get the value in the specified column.
      Parameters:
      index - The index for the column, starting at 0
      Returns:
      The value in the column
    • fixString

      protected String fixString(String value)
      Fix the value string according to options for 'emptyIsNull', 'nullIsNull', etc.
      Since:
      3.15.1
    • getInt

      public Integer getInt(int index)
      Shortcut for getInt(index, null, true)
    • getInt

      public Integer getInt(int index, NumberFormat parser, boolean nullIfException)
      Get the value as an integer. The default implementation parses the string value with the given parser. If the source file is an Excel file, the numeric value may be retrieved directly.
      Since:
      3.15
    • getLong

      public Long getLong(int index, NumberFormat parser, boolean nullIfException)
      Get the value as a long. The default implementation parses the string value with the given parser. If the source file is an Excel file, the numeric value may be retrieved directly.
      Since:
      3.15
    • getFloat

      public Float getFloat(int index)
      Shortcut for getFloat(index, null, true)
    • getFloat

      public Float getFloat(int index, NumberFormat parser, boolean nullIfException)
      Get the value as a float. The default implementation parses the string value with the given parser. If the source file is an Excel file, the numeric value may be retrieved directly.
      Since:
      3.15
    • getDouble

      public Double getDouble(int index, NumberFormat parser, boolean nullIfException)
      Get the value as a double. The default implementation parses the string value with the given parser. If the source file is an Excel file, the numeric value may be retrieved directly.
      Since:
      3.15
    • getDate

      public Date getDate(int index, Formatter<Date> parser, boolean nullIfException)
      Get the value as a date. The default implementation parses the string value with the given parser. If the source file is an Excel file, the date value may be retrieved directly.
      Since:
      3.15