2.17.2: 2011-06-17

net.sf.basedb.util.parser
Class CompoundMapper

java.lang.Object
  extended by net.sf.basedb.util.parser.CompoundMapper
All Implemented Interfaces:
Mapper

public class CompoundMapper
extends Object
implements Mapper

A compound mapper that gets its value by invoking multiple other mappers which are set in the constructor. This type of mapper is used to combine constant strings with column values.

Version:
2.0
Author:
nicklas
Last modified
$Date: 2008-09-11 22:08:14 +0200 (Thu, 11 Sep 2008) $

Field Summary
private  List<Mapper> mappers
           
private  boolean nullIfException
           
private  NumberFormat parser
           
 
Constructor Summary
CompoundMapper(List<Mapper> mappers)
          Create a new compound mapper.
CompoundMapper(List<Mapper> mappers, NumberFormat parser)
          Deprecated. Use CompoundMapper(List, NumberFormat, boolean)
CompoundMapper(List<Mapper> mappers, NumberFormat parser, boolean nullIfException)
          Create a new compound mapper, using a specific number formatter as it's parser.
 
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 a value by invoking each mapper in the order they appear in the list and concatenating the result.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mappers

private final List<Mapper> mappers

parser

private final NumberFormat parser

nullIfException

private final boolean nullIfException
Constructor Detail

CompoundMapper

public CompoundMapper(List<Mapper> mappers)
Create a new compound mapper.

Parameters:
mappers - A list of other mappers that will be invoked in the order they appear in the list

CompoundMapper

public CompoundMapper(List<Mapper> mappers,
                      NumberFormat parser)
Deprecated. Use CompoundMapper(List, NumberFormat, boolean)

Create a new compound mapper, using a specific number formatter as it's parser.

Parameters:
mappers - A list of other mappers that will be invoked in the order they appear in the list
parser - The number format to use or null to use Float.valueOf()
Since:
2.2.3

CompoundMapper

public CompoundMapper(List<Mapper> mappers,
                      NumberFormat parser,
                      boolean nullIfException)
Create a new compound mapper, using a specific number formatter as it's parser.

Parameters:
mappers - A list of other mappers that will be invoked in the order they appear in the list
parser - The number format to use or null to use Float.valueOf()
nullIfException - If TRUE, the mapper returns null for unparsable numeric values, otherwise an excption is thrown
Since:
2.4
Method Detail

getValue

public String getValue(FlatFileParser.Data data)
Get a value by invoking each mapper in the order they appear in the list and concatenating the result.

Specified by:
getValue in interface Mapper
Parameters:
data - The line of data
Returns:
The concatenated 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

2.17.2: 2011-06-17