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.ColumnMapper(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
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 Details
-
index
private final int index -
name
-
parser
-
dateParser
-
nullIfException
private final boolean nullIfException
-
-
Constructor Details
-
ColumnMapper
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 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
-
ColumnMapper(int, String, NumberFormat, Formatter, boolean)
instead