Class CompoundMapper

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

public class CompoundMapper extends Object implements Mapper
A compound mapper that gets its value by invoking multiple other mappers which are set in the constructor. This type of mapper is used to combine constant strings with column values.
Version:
2.0
Author:
nicklas
Last modified
$Date: 2019-04-11 09:31:26 +0200 (tors, 11 apr. 2019) $
  • Field Details

    • mappers

      private final List<Mapper> mappers
    • parser

      private final NumberFormat parser
    • dateParser

      private final Formatter<Date> dateParser
    • nullIfException

      private final boolean nullIfException
  • Constructor Details

    • CompoundMapper

      public CompoundMapper(List<Mapper> mappers)
      Create a new compound mapper.
      Parameters:
      mappers - A list of other mappers that will be invoked in the order they appear in the list
    • CompoundMapper

      public CompoundMapper(List<Mapper> mappers, NumberFormat parser, boolean nullIfException)
      Create a new compound mapper, using a specific number formatter as it's parser.
      Parameters:
      mappers - A list of other mappers that will be invoked in the order they appear in the list
      parser - The number format to use or null to use Float.valueOf()
      nullIfException - If TRUE, the mapper returns null for unparsable numeric values, otherwise an excption is thrown
      Since:
      2.4
    • CompoundMapper

      public CompoundMapper(List<Mapper> mappers, NumberFormat parser, Formatter<Date> dateParser, boolean nullIfException)
      Create a new compound mapper, using a specific number formatter as it's parser.
      Parameters:
      mappers - A list of other mappers that will be invoked in the order they appear in the list
      parser - The date format to use
      nullIfException - If TRUE, the mapper returns null for unparsable numeric values, otherwise an excption is thrown
      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)
      Get a value by invoking each mapper in the order they appear in the list and concatenating the result.
      Specified by:
      getString in interface Mapper
      Parameters:
      data - The line of data
      Returns:
      The concatenated 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