public class ConstantMapper extends java.lang.Object implements Mapper
getValue()
always
return the same string which is set in the contructor.Modifier and Type | Field and Description |
---|---|
private java.lang.Float |
asFloat |
private java.lang.Integer |
asInteger |
private java.lang.String |
constant |
private boolean |
needToParseNumeric |
private boolean |
nullIfException |
private java.lang.NumberFormatException |
parseException |
private java.text.NumberFormat |
parser |
Constructor and Description |
---|
ConstantMapper(java.lang.Float constant) |
ConstantMapper(java.lang.Integer constant) |
ConstantMapper(java.lang.String constant)
Create a constant mapper.
|
ConstantMapper(java.lang.String constant,
java.text.NumberFormat parser,
boolean nullIfException)
Create a constant mapper using a specific number formatter as it's parser.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Float |
getFloat(FlatFileParser.Data data)
Get the value for the line of data as a float.
|
java.lang.Integer |
getInt(FlatFileParser.Data data)
Get the value for the line of data as an integer.
|
java.lang.String |
getValue(FlatFileParser.Data data)
Get the value for the line of data.
|
private void |
parseNumeric() |
java.lang.String |
toString() |
private final java.lang.String constant
private final java.text.NumberFormat parser
private final boolean nullIfException
private boolean needToParseNumeric
private java.lang.Float asFloat
private java.lang.Integer asInteger
private java.lang.NumberFormatException parseException
public ConstantMapper(java.lang.String constant)
constant
- The constant expression.public ConstantMapper(java.lang.String constant, java.text.NumberFormat parser, boolean nullIfException)
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 thrownpublic ConstantMapper(java.lang.Integer constant)
public ConstantMapper(java.lang.Float constant)
public java.lang.String getValue(FlatFileParser.Data data)
Mapper
public java.lang.Integer getInt(FlatFileParser.Data data)
Mapper
public java.lang.Float getFloat(FlatFileParser.Data data)
Mapper
public java.lang.String toString()
toString
in class java.lang.Object
private void parseNumeric()