Package net.sf.basedb.util.parser
Class ConstantMapper
java.lang.Object
net.sf.basedb.util.parser.ConstantMapper
- All Implemented Interfaces:
Mapper
public class ConstantMapper extends Object implements Mapper
A constant string mapper. The
getValue()
always
return the same string which is set in the contructor.- Version:
- 2.0
- Author:
- nicklas
- Last modified
- $Date: 2019-03-21 12:50:52 +0100 (tors, 21 mars 2019) $
-
Field Summary
Fields Modifier and Type Field Description private Date
asDate
private Double
asDouble
private Long
asLong
private String
constant
private Formatter<Date>
dateParser
private boolean
needToParseDate
private boolean
needToParseNumeric
private boolean
nullIfException
private RuntimeException
parseException
private NumberFormat
parser
-
Constructor Summary
Constructors Constructor Description ConstantMapper(Float constant)
ConstantMapper(Integer constant)
ConstantMapper(String constant)
Create a constant mapper.ConstantMapper(String constant, NumberFormat parser, boolean nullIfException)
Create a constant mapper using a specific number formatter as it's parser.ConstantMapper(String constant, NumberFormat parser, Formatter<Date> dateParser, boolean nullIfException)
Create a constant mapper using a specific number formatter as it's parser.ConstantMapper(Date constant, Formatter<Date> dateParser)
-
Method Summary
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 the value for the line of data as a string.String
getValue(FlatFileParser.Data data)
Deprecated.private void
parseDate()
private void
parseNumeric()
String
toString()
-
Field Details
-
constant
-
parser
-
dateParser
-
nullIfException
private final boolean nullIfException -
needToParseNumeric
private boolean needToParseNumeric -
needToParseDate
private boolean needToParseDate -
asDouble
-
asLong
-
asDate
-
parseException
-
-
Constructor Details
-
ConstantMapper
Create a constant mapper.- Parameters:
constant
- The constant expression.
-
ConstantMapper
Create a constant mapper using a specific number formatter as it's parser.- Parameters:
constant
- The constant expressionparser
- The number format to use or null to use Double.valueOf()nullIfException
- If TRUE, the mapper returns null for unparsable numeric values, otherwise an excption is thrown- Since:
- 2.4
-
ConstantMapper
public ConstantMapper(String constant, NumberFormat parser, Formatter<Date> dateParser, boolean nullIfException)Create a constant mapper using a specific number formatter as it's parser.- Parameters:
constant
- The constant expressionparser
- The number format to use or null to use Double.valueOf()nullIfException
- If TRUE, the mapper returns null for unparsable numeric values, otherwise an excption is thrown- Since:
- 3.15
-
ConstantMapper
-
ConstantMapper
-
ConstantMapper
-
-
Method Details
-
getValue
Deprecated.Description copied from interface:Mapper
Get the value for the line of data. -
getString
Description copied from interface:Mapper
Get the value for the line of data as a string. -
getInt
Description copied from interface:Mapper
Get the value for the line of data as an integer. -
getLong
Description copied from interface:Mapper
Get the value for the line of data as a long. -
getFloat
Description copied from interface:Mapper
Get the value for the line of data as a float. -
getDouble
Description copied from interface:Mapper
Get the value for the line of data as a double. -
getDate
Description copied from interface:Mapper
Get the value for the line of data as a date. -
toString
-
parseNumeric
private void parseNumeric() -
parseDate
private void parseDate()
-