Package net.sf.basedb.util.parser
Class ColumnMapper
- java.lang.Object
-
- net.sf.basedb.util.parser.ColumnMapper
-
- All Implemented Interfaces:
Mapper
public class ColumnMapper extends Object implements Mapper
Returns the string found in the column given by the index set in the constructor. If the index is larger than the number of columns, an empty string is returned.- Version:
- 2.0
- Author:
- nicklas
- Last modified
- $Date: 2019-04-11 09:31:26 +0200 (tors, 11 apr. 2019) $
-
-
Field Summary
Fields Modifier and Type Field Description private Formatter<Date>
dateParser
private int
index
private String
name
private boolean
nullIfException
private NumberFormat
parser
-
Constructor Summary
Constructors Constructor Description ColumnMapper(int index, String name)
Create a new column mapper.ColumnMapper(int index, String name, NumberFormat parser, boolean nullIfException)
Deprecated.In 3.15, useColumnMapper(int, String, NumberFormat, Formatter, boolean)
insteadColumnMapper(int index, String name, NumberFormat parser, Formatter<Date> dateParser, boolean nullIfException)
Create a new column mapper using a specific number or date format.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods 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.String
toString()
-
-
-
Field Detail
-
index
private final int index
-
name
private final String name
-
parser
private final NumberFormat parser
-
nullIfException
private final boolean nullIfException
-
-
Constructor Detail
-
ColumnMapper
public ColumnMapper(int index, String name)
Create a new column mapper.- Parameters:
index
- The index of the data column to use, starting at 0name
- An optional name of the column, use in thetoString
method
-
ColumnMapper
@Deprecated public ColumnMapper(int index, String name, NumberFormat parser, boolean nullIfException)
Deprecated.In 3.15, useColumnMapper(int, String, NumberFormat, Formatter, boolean)
insteadCreate a new column mapper using a specific number format.- Parameters:
index
- The index of the data column to use, starting at 0name
- An optional name of the column, use in thetoString
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()- Since:
- 2.4
-
ColumnMapper
public ColumnMapper(int index, String name, NumberFormat parser, Formatter<Date> dateParser, boolean nullIfException)
Create a new column mapper using a specific number or date format.- Parameters:
index
- The index of the data column to use, starting at 0name
- An optional name of the column, use in thetoString
methodnullIfException
- If TRUE, the mapper returns null for unparsable numeric values, otherwise an excption is thrownparser
- The parser to use for numeric values or null to use Double.valueOf()dateParser
- The parser to use for date values- Since:
- 3.15
-
-
Method Detail
-
getValue
@Deprecated public String getValue(FlatFileParser.Data data)
Deprecated.Description copied from interface:Mapper
Get the value for the line of data.
-
getString
public String getString(FlatFileParser.Data data)
Description copied from interface:Mapper
Get the value for the line of data as a string.
-
getInt
public Integer getInt(FlatFileParser.Data data)
Description copied from interface:Mapper
Get the value for the line of data as an integer.
-
getLong
public Long getLong(FlatFileParser.Data data)
Description copied from interface:Mapper
Get the value for the line of data as a long.
-
getFloat
public Float getFloat(FlatFileParser.Data data)
Description copied from interface:Mapper
Get the value for the line of data as a float.
-
getDouble
public Double getDouble(FlatFileParser.Data data)
Description copied from interface:Mapper
Get the value for the line of data as a double.
-
getDate
public Date getDate(FlatFileParser.Data data)
Description copied from interface:Mapper
Get the value for the line of data as a date.
-
-