Package net.sf.basedb.util.parser
Class JepMapper
java.lang.Object
net.sf.basedb.util.parser.JepMapper
- All Implemented Interfaces:
Mapper
A mapper that uses Jep to calculate the final value. It should be used
for numerical values that needs to be transformed before beeing inserted
into the database. For example, if a file contains the radius of a spot
instead of the diameter, it could be mapped as
=2 * col('Radius')
.
It can also be used for concatenating string values but syntax with backslashes has better performance. The following mapping expressions are equivalent, but we recommend using the first one:
\Name\:\ID\ =col('Name')+':'+col('ID') =\Name\+':'+\ID\
- Version:
- 2.0
- Author:
- nicklas
- Last modified
- $Date: 2019-03-21 12:50:52 +0100 (tors, 21 mars 2019) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ColFunction
private final DataNoFunction
private final String
private final boolean
private final boolean
private final LineNoFunction
private final NumberFormat
private final JEP
-
Constructor Summary
ConstructorDescriptionCreate a new JepMapper.JepMapper
(String expression, List<String> columnHeaders, NumberFormat numberFormat) Deprecated.JepMapper
(String expression, List<String> columnHeaders, NumberFormat numberFormat, boolean ignoreNonExistingColumns) Deprecated.In 3.15, useJepMapper(String, List, NumberFormat, Formatter, boolean, JepFunction...)
insteadJepMapper
(String expression, List<String> columnHeaders, NumberFormat numberFormat, boolean ignoreNonExistingColumns, JepFunction... functions) Deprecated.In 3.15, useJepMapper(String, List, NumberFormat, Formatter, boolean, JepFunction...)
insteadJepMapper
(String expression, List<String> columnHeaders, NumberFormat numberFormat, Formatter<Date> dateFormat, boolean ignoreNonExistingColumns, JepFunction... functions) -
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.private void
setData
(FlatFileParser.Data data, Type valueType) toString()
-
Field Details
-
expression
-
parser
-
colFunction
-
lineNoFunction
-
hasLineNo
private final boolean hasLineNo -
dataNoFunction
-
hasDataNo
private final boolean hasDataNo -
numberFormat
-
dateFormat
-
-
Constructor Details
-
JepMapper
Create a new JepMapper.- Parameters:
expression
- The JEP expressioncolumnHeaders
- A map from column names to column indexes
-
JepMapper
@Deprecated public JepMapper(String expression, List<String> columnHeaders, NumberFormat numberFormat) Deprecated.In 3.15, useJepMapper(String, List, NumberFormat, Formatter, boolean, JepFunction...)
instead -
JepMapper
@Deprecated public JepMapper(String expression, List<String> columnHeaders, NumberFormat numberFormat, boolean ignoreNonExistingColumns) Deprecated.In 3.15, useJepMapper(String, List, NumberFormat, Formatter, boolean, JepFunction...)
instead -
JepMapper
@Deprecated public JepMapper(String expression, List<String> columnHeaders, NumberFormat numberFormat, boolean ignoreNonExistingColumns, JepFunction... functions) Deprecated.In 3.15, useJepMapper(String, List, NumberFormat, Formatter, boolean, JepFunction...)
instead- Since:
- 3.1
-
JepMapper
public JepMapper(String expression, List<String> columnHeaders, NumberFormat numberFormat, Formatter<Date> dateFormat, boolean ignoreNonExistingColumns, JepFunction... functions) - 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
-
setData
-
JepMapper(String, List, NumberFormat, Formatter, boolean, JepFunction...)
instead