2.17.2: 2011-06-17

net.sf.basedb.util.parser
Class JepMapper

java.lang.Object
  extended by 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:


Field Summary
private  ColFunction colFunction
           
private  DataNoFunction dataNoFunction
           
private  String expression
           
private  boolean hasDataNo
           
private  boolean hasLineNo
           
private  LineNoFunction lineNoFunction
           
private  NumberFormat numberFormat
           
private  JEP parser
           
 
Constructor Summary
JepMapper(String expression, List<String> columnHeaders)
          Create a new JepMapper.
JepMapper(String expression, List<String> columnHeaders, NumberFormat numberFormat)
           
JepMapper(String expression, List<String> columnHeaders, NumberFormat numberFormat, boolean ignoreNonExistingColumns)
           
 
Method Summary
 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.
 String getValue(FlatFileParser.Data data)
          Get the value for the line of data.
private  void setData(FlatFileParser.Data data)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 expression
columnHeaders - 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)
Method Detail

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)

2.17.2: 2011-06-17