public class ColumnMapper extends java.lang.Object implements Mapper
Modifier and Type | Field and Description |
---|---|
private int |
index |
private java.lang.String |
name |
private boolean |
nullIfException |
private java.text.NumberFormat |
parser |
private java.text.ParsePosition |
pos |
Constructor and Description |
---|
ColumnMapper(int index,
java.lang.String name)
Create a new column mapper.
|
ColumnMapper(int index,
java.lang.String name,
java.text.NumberFormat parser,
boolean nullIfException)
Create a new column mapper using a specific number format.
|
Modifier and Type | Method and Description |
---|---|
private java.lang.Double |
getDouble(java.lang.String value) |
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 in the data objects column with the index specified
in the constructor.
|
java.lang.String |
toString() |
private final int index
private final java.lang.String name
private final java.text.NumberFormat parser
private final java.text.ParsePosition pos
private final boolean nullIfException
public ColumnMapper(int index, java.lang.String name)
index
- The index of the data column to use, starting at 0name
- An optional name of the column, use in the toString
methodpublic ColumnMapper(int index, java.lang.String name, java.text.NumberFormat parser, boolean nullIfException)
index
- The index of the data column to use, starting at 0name
- An optional name of the column, use in the toString
methodnullIfException
- If TRUE, the mapper returns null for unparsable numeric
values, otherwise an excption is thrownparser
- The parser to use or null to use Double.valueOf()public java.lang.String getValue(FlatFileParser.Data data)
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 java.lang.Double getDouble(java.lang.String value)