2.17.2: 2011-06-17

net.sf.basedb.util.parser
Class ConstantMapper

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

public class ConstantMapper
extends Object
implements Mapper

A constant string mapper. The getValue() always return the same string which is set in the contructor.

Version:
2.0
Author:
nicklas
Last modified
$Date: 2010-08-13 10:50:27 +0200 (Fri, 13 Aug 2010) $

Field Summary
private  Float asFloat
           
private  Integer asInteger
           
private  String constant
           
private  boolean needToParseNumeric
           
private  boolean nullIfException
           
private  NumberFormatException parseException
           
private  NumberFormat parser
           
 
Constructor Summary
ConstantMapper(Float constant)
           
ConstantMapper(Integer constant)
           
ConstantMapper(String constant)
          Create a constant mapper.
ConstantMapper(String constant, NumberFormat parser)
          Deprecated. Use ConstantMapper(String, NumberFormat, boolean)
ConstantMapper(String constant, NumberFormat parser, boolean nullIfException)
          Create a constant 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 the value for the line of data.
private  void parseNumeric()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

constant

private final String constant

parser

private final NumberFormat parser

nullIfException

private final boolean nullIfException

needToParseNumeric

private boolean needToParseNumeric

asFloat

private Float asFloat

asInteger

private Integer asInteger

parseException

private NumberFormatException parseException
Constructor Detail

ConstantMapper

public ConstantMapper(String constant)
Create a constant mapper.

Parameters:
constant - The constant expression.

ConstantMapper

public ConstantMapper(String constant,
                      NumberFormat parser)
Deprecated. Use ConstantMapper(String, NumberFormat, boolean)

Create a constant mapper using a specific number formatter as it's parser.

Parameters:
constant - The constant expression
parser - The number format to use or null to use Double.valueOf()
Since:
2.2

ConstantMapper

public ConstantMapper(String constant,
                      NumberFormat parser,
                      boolean nullIfException)
Create a constant mapper using a specific number formatter as it's parser.

Parameters:
constant - The constant expression
parser - The number format to use or null to use Double.valueOf()
nullIfException - If TRUE, the mapper returns null for unparsable numeric values, otherwise an excption is thrown
Since:
2.4

ConstantMapper

public ConstantMapper(Integer constant)

ConstantMapper

public ConstantMapper(Float constant)
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:
The string set in the constructor

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

parseNumeric

private void parseNumeric()

2.17.2: 2011-06-17