BeanIO 2.0.4

org.beanio.internal.parser
Interface FieldFormat

All Known Subinterfaces:
FlatFieldFormat
All Known Implementing Classes:
DelimitedFieldFormat, FixedLengthFieldFormat, FlatFieldFormatSupport, JsonFieldFormat, XmlAttributeField, XmlElementField, XmlFieldFormat, XmlTextField

public interface FieldFormat

A FieldFormat provides format specific processing for a Field parser.

Implementations of this interface must be thread-safe.

Since:
2.0
Author:
Kevin Seim

Method Summary
 String extract(UnmarshallingContext context, boolean reportErrors)
          Extracts the field text from a record.
 int getSize()
          Returns the size of the field.
 void insertField(MarshallingContext context, String text)
          Inserts field text into a record.
 boolean insertValue(MarshallingContext context, Object value)
          Inserts a value into a record.
 boolean isLazy()
          TODO rename isLazy to something better?? Returns whether this field is optionally present in the record.
 boolean isNillable()
          Returns whether this field is nillable.
 

Method Detail

extract

String extract(UnmarshallingContext context,
               boolean reportErrors)
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.

Parameters:
context - the UnmarshallingContext holding the record
Returns:
the field text

insertValue

boolean insertValue(MarshallingContext context,
                    Object value)
Inserts a value into a record. This method is called before type conversion. If the method returns false, type conversion is invoked and insertField(MarshallingContext, String) is called. If the method returns true, insertField(MarshallingContext, String) is not invoked.

Parameters:
context - the MarshallingContext
value - the value to insert into the record
Returns:
true if type conversion is required and insertField(MarshallingContext, String) must be invoked, false otherwise

insertField

void insertField(MarshallingContext context,
                 String text)
Inserts field text into a record.

Parameters:
context - the MarshallingContext holding the record
text - the field text to insert into the record

getSize

int getSize()
Returns the size of the field. Fixed length formats should return the field length, while other formats should simply return 1.

Returns:
the size of the field

isNillable

boolean isNillable()
Returns whether this field is nillable.

Returns:
true if nillable, false otherwise

isLazy

boolean isLazy()
TODO rename isLazy to something better?? Returns whether this field is optionally present in the record.

Returns:
true if lazy, false otherwise

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim