BeanIO 2.0.4

org.beanio.internal.parser.format.fixedlength
Class FixedLengthFieldFormat

java.lang.Object
  extended by org.beanio.internal.parser.format.flat.FlatFieldFormatSupport
      extended by org.beanio.internal.parser.format.fixedlength.FixedLengthFieldFormat
All Implemented Interfaces:
FieldFormat, FlatFieldFormat

public class FixedLengthFieldFormat
extends FlatFieldFormatSupport
implements FieldFormat

A FieldFormat implementation for a field in a fixed length formatted stream.

Since:
2.0
Author:
Kevin Seim

Constructor Summary
FixedLengthFieldFormat()
          Constructs a new FixedLengthFieldFormat.
 
Method Summary
 String extract(UnmarshallingContext context, boolean reportErrors)
          Extracts the field text from a record.
 String extractFieldText(UnmarshallingContext context, boolean reporting)
           
 int getSize()
          Returns the size of the field.
 void insertFieldText(MarshallingContext context, String fieldText, boolean commit)
           
 void setKeepPadding(boolean keepPadding)
          Set to true to keep field padding during unmarshalling.
 
Methods inherited from class org.beanio.internal.parser.format.flat.FlatFieldFormatSupport
getName, getPadding, getPosition, getUntil, insertField, insertValue, isLazy, isNillable, setLazy, setName, setPadding, setPosition, setUntil, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.beanio.internal.parser.FieldFormat
insertField, insertValue, isLazy, isNillable
 

Constructor Detail

FixedLengthFieldFormat

public FixedLengthFieldFormat()
Constructs a new FixedLengthFieldFormat.

Method Detail

extract

public String extract(UnmarshallingContext context,
                      boolean reportErrors)
Description copied from interface: FieldFormat
Extracts the field text from a record. Returns null if the field was not present in the record.

May return Value.INVALID if the field is invalid, or Value.NIL if the field is explicitly set to nil or null such as in an XML or JSON formatted stream.

Implementations should also remove any field padding before returning the text.

Specified by:
extract in interface FieldFormat
Overrides:
extract in class FlatFieldFormatSupport
Parameters:
context - the UnmarshallingContext holding the record
Returns:
the field text

extractFieldText

public String extractFieldText(UnmarshallingContext context,
                               boolean reporting)
Specified by:
extractFieldText in class FlatFieldFormatSupport

insertFieldText

public void insertFieldText(MarshallingContext context,
                            String fieldText,
                            boolean commit)
Specified by:
insertFieldText in class FlatFieldFormatSupport

getSize

public int getSize()
Description copied from interface: FieldFormat
Returns the size of the field. Fixed length formats should return the field length, while other formats should simply return 1.

Specified by:
getSize in interface FieldFormat
Overrides:
getSize in class FlatFieldFormatSupport
Returns:
the size of the field

setKeepPadding

public void setKeepPadding(boolean keepPadding)
Set to true to keep field padding during unmarshalling.

Parameters:
keepPadding - true to keep padding
Since:
2.0.2

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim