Package net.sf.basedb.util.parser
Class JepMapper
java.lang.Object
net.sf.basedb.util.parser.JepMapper
- All Implemented Interfaces:
Mapper
public class JepMapper extends Object implements 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
Fields Modifier and Type Field Description private ColFunction
colFunction
private DataNoFunction
dataNoFunction
private Formatter<Date>
dateFormat
private String
expression
private boolean
hasDataNo
private boolean
hasLineNo
private LineNoFunction
lineNoFunction
private NumberFormat
numberFormat
private JEP
parser
-
Constructor Summary
Constructors Constructor Description JepMapper(String expression, List<String> columnHeaders)
Create 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 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.private void
setData(FlatFileParser.Data data, Type valueType)
String
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