public abstract class XmlFieldFormat extends Object implements FieldFormat, XmlNode
FieldFormat
implementations.XML_TYPE_ATTRIBUTE, XML_TYPE_ELEMENT, XML_TYPE_NONE, XML_TYPE_TEXT
Constructor and Description |
---|
XmlFieldFormat()
Constructs a new XmlFieldFormat.
|
Modifier and Type | Method and Description |
---|---|
String |
extract(UnmarshallingContext context,
boolean reportErrors)
Extracts the field text from a record.
|
protected abstract String |
extractText(XmlUnmarshallingContext context)
Extracts a field from a record during unmarshalling.
|
String |
getName()
Returns the field name.
|
FieldPadding |
getPadding()
Returns the field padding, or null if the field text is not padded.
|
int |
getSize()
Returns the size of the field.
|
void |
insertField(MarshallingContext context,
String fieldText)
Inserts field text into a record.
|
protected abstract void |
insertText(XmlMarshallingContext context,
String text)
Inserts a field into the record during marshalling.
|
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.
|
void |
setLazy(boolean lazy) |
void |
setName(String name)
Sets the field name.
|
void |
setPadding(FieldPadding padding)
Sets the field padding.
|
protected void |
toParamString(StringBuilder s)
Called by
toString() to append attributes of this field. |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isNillable
getLocalName, getNamespace, getPrefix, getType, isNamespaceAware, isNillable, isRepeating
public boolean insertValue(MarshallingContext context, Object value)
FieldFormat
FieldFormat.insertField(MarshallingContext, String)
is called. If the method returns true, FieldFormat.insertField(MarshallingContext, String)
is not invoked.insertValue
in interface FieldFormat
context
- the MarshallingContext
value
- the value to insert into the recordFieldFormat.insertField(MarshallingContext, String)
must be invoked, false otherwisepublic void insertField(MarshallingContext context, String fieldText)
FieldFormat
insertField
in interface FieldFormat
context
- the MarshallingContext
holding the recordfieldText
- the field text to insert into the recordprotected abstract void insertText(XmlMarshallingContext context, String text)
context
- the XmlMarshallingContext
holding the recordtext
- the field text to insertpublic String extract(UnmarshallingContext context, boolean reportErrors)
FieldFormat
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.
extract
in interface FieldFormat
context
- the UnmarshallingContext
holding the recordprotected abstract String extractText(XmlUnmarshallingContext context)
context
- the XmlUnmarshallingContext
holding the recordpublic int getSize()
FieldFormat
getSize
in interface FieldFormat
public String getName()
public void setName(String name)
name
- the field namepublic boolean isLazy()
FieldFormat
isLazy
in interface FieldFormat
public void setLazy(boolean lazy)
public FieldPadding getPadding()
public void setPadding(FieldPadding padding)
padding
- the field paddingprotected void toParamString(StringBuilder s)
toString()
to append attributes of this field.s
- the text to append