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.In 3.15, useJepMapper(String, List, NumberFormat, Formatter, boolean, JepFunction...)
insteadJepMapper(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
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.private void
setData(FlatFileParser.Data data, Type valueType)
String
toString()
-
-
-
Field Detail
-
expression
private final String expression
-
parser
private final JEP parser
-
colFunction
private final ColFunction colFunction
-
lineNoFunction
private final LineNoFunction lineNoFunction
-
hasLineNo
private final boolean hasLineNo
-
dataNoFunction
private final DataNoFunction dataNoFunction
-
hasDataNo
private final boolean hasDataNo
-
numberFormat
private final NumberFormat numberFormat
-
-
Constructor Detail
-
JepMapper
public JepMapper(String expression, List<String> columnHeaders)
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 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.
-
setData
private void setData(FlatFileParser.Data data, Type valueType)
-
-