Class XmlFieldFormat
- java.lang.Object
-
- org.beanio.internal.parser.format.xml.XmlFieldFormat
-
- All Implemented Interfaces:
FieldFormat,XmlNode
- Direct Known Subclasses:
XmlAttributeField,XmlElementField,XmlTextField
public abstract class XmlFieldFormat extends java.lang.Object implements FieldFormat, XmlNode
Base class for XMLFieldFormatimplementations.- Since:
- 2.0
-
-
Field Summary
-
Fields inherited from interface org.beanio.internal.parser.format.xml.XmlNode
XML_TYPE_ATTRIBUTE, XML_TYPE_ELEMENT, XML_TYPE_NONE, XML_TYPE_TEXT
-
-
Constructor Summary
Constructors Constructor Description XmlFieldFormat()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Stringextract(UnmarshallingContext context, boolean reportErrors)Extracts the field text from a record.protected abstract java.lang.StringextractText(XmlUnmarshallingContext context)Extracts a field from a record during unmarshalling.java.lang.StringgetName()Returns the field name.FieldPaddinggetPadding()Returns the field padding, or null if the field text is not padded.intgetSize()Returns the size of the field.voidinsertField(MarshallingContext context, java.lang.String fieldText)Inserts field text into a record.protected abstract voidinsertText(XmlMarshallingContext context, java.lang.String text)Inserts a field into the record during marshalling.booleaninsertValue(MarshallingContext context, java.lang.Object value)Inserts a value into a record.booleanisLazy()TODO rename isLazy to something better?? Returns whether this field is optionally present in the record.voidsetLazy(boolean lazy)voidsetName(java.lang.String name)Sets the field name.voidsetPadding(FieldPadding padding)Sets the field padding.protected voidtoParamString(java.lang.StringBuilder s)Called bytoString()to append attributes of this field.java.lang.StringtoString()-
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
isNillable
-
Methods inherited from interface org.beanio.internal.parser.format.xml.XmlNode
getLocalName, getNamespace, getPrefix, getType, isNamespaceAware, isNillable, isRepeating
-
-
-
-
Method Detail
-
insertValue
public boolean insertValue(MarshallingContext context, java.lang.Object value)
Description copied from interface:FieldFormatInserts a value into a record. This method is called before type conversion. If the method returns false, type conversion is invoked andFieldFormat.insertField(MarshallingContext, String)is called. If the method returns true,FieldFormat.insertField(MarshallingContext, String)is not invoked.- Specified by:
insertValuein interfaceFieldFormat- Parameters:
context- theMarshallingContextvalue- the value to insert into the record- Returns:
- true if type conversion is required and
FieldFormat.insertField(MarshallingContext, String)must be invoked, false otherwise
-
insertField
public void insertField(MarshallingContext context, java.lang.String fieldText)
Description copied from interface:FieldFormatInserts field text into a record.- Specified by:
insertFieldin interfaceFieldFormat- Parameters:
context- theMarshallingContextholding the recordfieldText- the field text to insert into the record
-
insertText
protected abstract void insertText(XmlMarshallingContext context, java.lang.String text)
Inserts a field into the record during marshalling.- Parameters:
context- theXmlMarshallingContextholding the recordtext- the field text to insert
-
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- Parameters:
context- theUnmarshallingContextholding the record- Returns:
- the field text
-
extractText
protected abstract java.lang.String extractText(XmlUnmarshallingContext context)
Extracts a field from a record during unmarshalling.- Parameters:
context- theXmlUnmarshallingContextholding the record- Returns:
- the extracted field text
-
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- Returns:
- the size of the field
-
getName
public java.lang.String getName()
Returns the field name.- Returns:
- the field name
-
setName
public void setName(java.lang.String name)
Sets the field name.- Parameters:
name- the field name
-
isLazy
public boolean isLazy()
Description copied from interface:FieldFormatTODO rename isLazy to something better?? Returns whether this field is optionally present in the record.- Specified by:
isLazyin interfaceFieldFormat- Returns:
- true if lazy, false otherwise
-
setLazy
public void setLazy(boolean lazy)
-
getPadding
public FieldPadding getPadding()
Returns the field padding, or null if the field text is not padded.- Returns:
- the field padding or null
-
setPadding
public void setPadding(FieldPadding padding)
Sets the field padding.- Parameters:
padding- the field padding
-
toParamString
protected void toParamString(java.lang.StringBuilder s)
Called bytoString()to append attributes of this field.- Parameters:
s- the text to append
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-