Class FixedLengthFieldFormat
- java.lang.Object
-
- org.beanio.internal.parser.format.flat.FlatFieldFormatSupport
-
- org.beanio.internal.parser.format.fixedlength.FixedLengthFieldFormat
-
- All Implemented Interfaces:
FieldFormat
,FlatFieldFormat
public class FixedLengthFieldFormat extends FlatFieldFormatSupport implements FieldFormat
AFieldFormat
implementation for a field in a fixed length formatted stream.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description FixedLengthFieldFormat()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
extract(UnmarshallingContext context, boolean reportErrors)
Extracts the field text from a record.java.lang.String
extractFieldText(UnmarshallingContext context, boolean reporting)
int
getSize()
Returns the size of the field.void
insertFieldText(MarshallingContext context, java.lang.String fieldText, boolean commit)
void
setKeepPadding(boolean keepPadding)
Set to true to keep field padding during unmarshalling.void
setLenientPadding(boolean lenientPadding)
Sets whether the padding length is enforced.-
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
-
-
-
-
Method Detail
-
extract
public java.lang.String extract(UnmarshallingContext context, boolean reportErrors)
Description copied from interface:FieldFormat
Extracts the field text from a record. Returnsnull
if the field was not present in the record.May return
Value.INVALID
if the field is invalid, orValue.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 interfaceFieldFormat
- Overrides:
extract
in classFlatFieldFormatSupport
- Parameters:
context
- theUnmarshallingContext
holding the record- Returns:
- the field text
-
extractFieldText
public java.lang.String extractFieldText(UnmarshallingContext context, boolean reporting)
- Specified by:
extractFieldText
in classFlatFieldFormatSupport
-
insertFieldText
public void insertFieldText(MarshallingContext context, java.lang.String fieldText, boolean commit)
- Specified by:
insertFieldText
in classFlatFieldFormatSupport
-
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 interfaceFieldFormat
- Overrides:
getSize
in classFlatFieldFormatSupport
- 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
-
setLenientPadding
public void setLenientPadding(boolean lenientPadding)
Sets whether the padding length is enforced.- Parameters:
lenientPadding
- true if not enforced, false otherwise- Since:
- 2.1.0
-
-