Class 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 Detail

      • nullIfException

        private final boolean nullIfException
    • Constructor Detail

      • 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 Detail

      • 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