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:
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
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
public JepMapper(String expression,
List<String> columnHeaders,
NumberFormat numberFormat)
JepMapper
public JepMapper(String expression,
List<String> columnHeaders,
NumberFormat numberFormat,
boolean ignoreNonExistingColumns)
getValue
public String getValue(FlatFileParser.Data data)
- Description copied from interface:
Mapper
- Get the value for the line of data.
- Specified by:
getValue
in interface Mapper
- Parameters:
data
- The line of data
- Returns:
- A string value
getInt
public Integer getInt(FlatFileParser.Data data)
- Description copied from interface:
Mapper
- Get the value for the line of data as an integer.
- Specified by:
getInt
in interface Mapper
- Parameters:
data
- The line of data
- Returns:
- The value as an integer
getFloat
public Float getFloat(FlatFileParser.Data data)
- Description copied from interface:
Mapper
- Get the value for the line of data as a float.
- Specified by:
getFloat
in interface Mapper
- Parameters:
data
- The line of data
- Returns:
- The value as a float
toString
public String toString()
- Overrides:
toString
in class Object
setData
private void setData(FlatFileParser.Data data)