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
AFieldFormatimplementation 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.Stringextract(UnmarshallingContext context, boolean reportErrors)Extracts the field text from a record.java.lang.StringextractFieldText(UnmarshallingContext context, boolean reporting)intgetSize()Returns the size of the field.voidinsertFieldText(MarshallingContext context, java.lang.String fieldText, boolean commit)voidsetKeepPadding(boolean keepPadding)Set to true to keep field padding during unmarshalling.voidsetLenientPadding(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:FieldFormatExtracts the field text from a record. Returnsnullif the field was not present in the record.May return
Value.INVALIDif the field is invalid, orValue.NILif 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:
extractin interfaceFieldFormat- Overrides:
extractin classFlatFieldFormatSupport- Parameters:
context- theUnmarshallingContextholding the record- Returns:
- the field text
-
extractFieldText
public java.lang.String extractFieldText(UnmarshallingContext context, boolean reporting)
- Specified by:
extractFieldTextin classFlatFieldFormatSupport
-
insertFieldText
public void insertFieldText(MarshallingContext context, java.lang.String fieldText, boolean commit)
- Specified by:
insertFieldTextin classFlatFieldFormatSupport
-
getSize
public int getSize()
Description copied from interface:FieldFormatReturns the size of the field. Fixed length formats should return the field length, while other formats should simply return 1.- Specified by:
getSizein interfaceFieldFormat- Overrides:
getSizein 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
-
-