public class ColumnMapper extends Object implements Mapper
Modifier and Type | Field and Description |
---|---|
private int |
index |
private String |
name |
private boolean |
nullIfException |
private NumberFormat |
parser |
private ParsePosition |
pos |
Constructor and Description |
---|
ColumnMapper(int index,
String name)
Create a new column mapper.
|
ColumnMapper(int index,
String name,
NumberFormat parser,
boolean nullIfException)
Create a new column mapper using a specific number format.
|
Modifier and Type | Method and Description |
---|---|
private Double |
getDouble(String value) |
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.
|
String |
getValue(FlatFileParser.Data data)
Get the value in the data objects column with the index specified
in the constructor.
|
String |
toString() |
private final int index
private final String name
private final NumberFormat parser
private final ParsePosition pos
private final boolean nullIfException
public ColumnMapper(int index, 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, String name, 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 String getValue(FlatFileParser.Data data)
public Integer getInt(FlatFileParser.Data data)
Mapper
public Float getFloat(FlatFileParser.Data data)
Mapper