Class ColumnMapper

java.lang.Object
net.sf.basedb.util.parser.ColumnMapper
All Implemented Interfaces:
Mapper

public class ColumnMapper extends Object implements Mapper
Returns the string found in the column given by the index set in the constructor. If the index is larger than the number of columns, an empty string is returned.
Version:
2.0
Author:
nicklas
Last modified
$Date: 2019-04-11 09:31:26 +0200 (tors, 11 apr. 2019) $
  • Field Details

    • index

      private final int index
    • name

      private final String name
    • parser

      private final NumberFormat parser
    • dateParser

      private final Formatter<Date> dateParser
    • nullIfException

      private final boolean nullIfException
  • Constructor Details

    • ColumnMapper

      public ColumnMapper(int index, String name)
      Create a new column mapper.
      Parameters:
      index - The index of the data column to use, starting at 0
      name - An optional name of the column, use in the toString method
    • ColumnMapper

      @Deprecated public ColumnMapper(int index, String name, NumberFormat parser, boolean nullIfException)
      Create a new column mapper using a specific number format.
      Parameters:
      index - The index of the data column to use, starting at 0
      name - An optional name of the column, use in the toString method
      nullIfException - If TRUE, the mapper returns null for unparsable numeric values, otherwise an excption is thrown
      parser - The parser to use or null to use Double.valueOf()
      Since:
      2.4
    • ColumnMapper

      public ColumnMapper(int index, String name, NumberFormat parser, Formatter<Date> dateParser, boolean nullIfException)
      Create a new column mapper using a specific number or date format.
      Parameters:
      index - The index of the data column to use, starting at 0
      name - An optional name of the column, use in the toString method
      nullIfException - If TRUE, the mapper returns null for unparsable numeric values, otherwise an excption is thrown
      parser - The parser to use for numeric values or null to use Double.valueOf()
      dateParser - The parser to use for date values
      Since:
      3.15
  • Method Details

    • getValue

      @Deprecated public String getValue(FlatFileParser.Data data)
      Deprecated.
      Description copied from interface: Mapper
      Get the value for the line of data.
      Specified by:
      getValue in interface Mapper
      Parameters:
      data - The line of data
      Returns:
      A string value
    • getString

      public String getString(FlatFileParser.Data data)
      Description copied from interface: Mapper
      Get the value for the line of data as a string.
      Specified by:
      getString in interface Mapper
      Parameters:
      data - The line of data
      Returns:
      A string value
    • getInt

      public Integer getInt(FlatFileParser.Data data)
      Description copied from interface: Mapper
      Get the value for the line of data as an integer.
      Specified by:
      getInt in interface Mapper
      Parameters:
      data - The line of data
      Returns:
      The value as an integer
    • getLong

      public Long getLong(FlatFileParser.Data data)
      Description copied from interface: Mapper
      Get the value for the line of data as a long.
      Specified by:
      getLong in interface Mapper
      Parameters:
      data - The line of data
      Returns:
      The value as an long
    • getFloat

      public Float getFloat(FlatFileParser.Data data)
      Description copied from interface: Mapper
      Get the value for the line of data as a float.
      Specified by:
      getFloat in interface Mapper
      Parameters:
      data - The line of data
      Returns:
      The value as a float
    • getDouble

      public Double getDouble(FlatFileParser.Data data)
      Description copied from interface: Mapper
      Get the value for the line of data as a double.
      Specified by:
      getDouble in interface Mapper
      Parameters:
      data - The line of data
      Returns:
      The value as a double
    • getDate

      public Date getDate(FlatFileParser.Data data)
      Description copied from interface: Mapper
      Get the value for the line of data as a date.
      Specified by:
      getDate in interface Mapper
      Parameters:
      data - The line of data
      Returns:
      The value as a date
    • toString

      public String toString()
      Overrides:
      toString in class Object