Package net.sf.basedb.util.parser
Class ConstantMapper
java.lang.Object
net.sf.basedb.util.parser.ConstantMapper
- All Implemented Interfaces:
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
Modifier and TypeFieldDescriptionprivate Date
private Double
private Long
private final String
private boolean
private boolean
private final boolean
private RuntimeException
private final NumberFormat
-
Constructor Summary
ConstructorDescriptionConstantMapper
(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 TypeMethodDescriptiongetDate
(FlatFileParser.Data data) Get the value for the line of data as a date.getDouble
(FlatFileParser.Data data) Get the value for the line of data as a double.getFloat
(FlatFileParser.Data data) Get the value for the line of data as a float.getInt
(FlatFileParser.Data data) Get the value for the line of data as an integer.getLong
(FlatFileParser.Data data) Get the value for the line of data as a long.getString
(FlatFileParser.Data data) Get the value for the line of data as a string.getValue
(FlatFileParser.Data data) Deprecated.private void
private void
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()
-