Package net.sf.basedb.util.parser
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-05 14:19:47 +0200 (fre, 05 apr. 2019) $
-
-
Field Summary
Fields Modifier and Type Field Description private Formatter<Date>
dateParser
private List<Mapper>
mappers
private boolean
nullIfException
private NumberFormat
parser
-
Constructor Summary
Constructors Constructor Description CompoundMapper(List<Mapper> mappers)
Create a new compound mapper.CompoundMapper(List<Mapper> mappers, NumberFormat parser, boolean nullIfException)
Create a new compound mapper, using a specific number formatter as it's parser.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Date
getDate(FlatFileParser.Data data)
Get the value for the line of data as a date.Double
getDouble(FlatFileParser.Data data)
Get the value for the line of data as a double.Float
getFloat(FlatFileParser.Data data)
Get the value for the line of data as a float.Integer
getInt(FlatFileParser.Data data)
Get the value for the line of data as an integer.Long
getLong(FlatFileParser.Data data)
Get the value for the line of data as a long.String
getString(FlatFileParser.Data data)
Get a value by invoking each mapper in the order they appear in the list and concatenating the result.String
getValue(FlatFileParser.Data data)
Deprecated.String
toString()
-
-
-
Field Detail
-
parser
private final NumberFormat parser
-
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 listparser
- 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 listparser
- The date format to usenullIfException
- If TRUE, the mapper returns null for unparsable numeric values, otherwise an excption is thrown- Since:
- 3.15
-
-
Method Detail
-
getValue
@Deprecated public String getValue(FlatFileParser.Data data)
Deprecated.Description copied from interface:Mapper
Get the value for the line of data.
-
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.
-
getInt
public Integer getInt(FlatFileParser.Data data)
Description copied from interface:Mapper
Get the value for the line of data 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.
-
getFloat
public Float getFloat(FlatFileParser.Data data)
Description copied from interface:Mapper
Get the value for the line of data 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.
-
getDate
public Date getDate(FlatFileParser.Data data)
Description copied from interface:Mapper
Get the value for the line of data as a date.
-
-