2.17.2: 2011-06-17

net.sf.basedb.util.parser
Class CropStringMapper

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

public class CropStringMapper
extends Object
implements Mapper

A mapper that crops a string if it is longer than a specified length. The actual mapping is delegated to a parent mapper.

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

Field Summary
private  int maxLength
           
private  Mapper parent
           
 
Constructor Summary
CropStringMapper(Mapper parent, int maxLength)
          Create a new CropStringMapper.
 
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)
          Use the parent mapper to get the string value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

private final Mapper parent

maxLength

private final int maxLength
Constructor Detail

CropStringMapper

public CropStringMapper(Mapper parent,
                        int maxLength)
Create a new CropStringMapper.

Parameters:
parent - The parent mapper that does the actual mapping
maxLength - The maximum length of stings
Method Detail

getValue

public String getValue(FlatFileParser.Data data)
Use the parent mapper to get the string value. Then check the length against the maximum length and crop if neccessary.

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

2.17.2: 2011-06-17