Package net.sf.basedb.util.parser
Class ColumnMapper
java.lang.Object
net.sf.basedb.util.parser.ColumnMapper
- All Implemented Interfaces:
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
Modifier and TypeFieldDescriptionprivate final int
private final String
private final boolean
private final NumberFormat
-
Constructor Summary
ConstructorDescriptionColumnMapper
(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 TypeMethodDescriptiongetDate
(FlatFileParser.Data data) Get the value for the line of data as a date.getDouble
(FlatFileParser.Data data) Get the value for the line of data as a double.getFloat
(FlatFileParser.Data data) Get the value for the line of data as a float.getInt
(FlatFileParser.Data data) Get the value for the line of data as an integer.getLong
(FlatFileParser.Data data) Get the value for the line of data as a long.getString
(FlatFileParser.Data data) Get the value for the line of data as a string.getValue
(FlatFileParser.Data data) Deprecated.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