public abstract static class Bean2XmlAppenders.Appender extends Object
Appender
appends children to a single node of the output
tree. One instance is created for each non-leaf node; different object
types use different appender classes, and the driver is responsible for
picking the appropriate appender.
This base class maintains options and other state, and provides common
services to subclasses. Subclasses implement the appendValue(java.lang.String, java.lang.Class<?>, java.lang.String)
and appendContainer(java.lang.String, java.lang.Class<?>)
methods, which are called by the driver.
Modifier | Constructor and Description |
---|---|
protected |
Bean2XmlAppenders.Appender(Bean2XmlAppenders.Appender parent,
Object nodeObject)
Constructor called by all other subclasses.
|
protected |
Bean2XmlAppenders.Appender(EnumSet<Bean2XmlOptions> options,
Object rootObject)
Constructor called by (@link DirectAppender).
|
Modifier and Type | Method and Description |
---|---|
abstract Element |
appendContainer(String name,
Class<?> klass)
Appends a container element to the current element.
|
abstract Element |
appendValue(String name,
Class<?> klass,
String value)
Appends a value element to the current element.
|
protected boolean |
isCircularReference(Object obj)
Determines whether the passed object is a circular reference.
|
protected boolean |
isOptionSet(Bean2XmlOptions option)
Hides the mechanism that we used to manage options.
|
void |
overrideType(Element elem,
String typedesc)
Updates the type attribute to the specified value, if types are in
use; otherwise does nothing.
|
protected void |
setType(Element elem,
Class<?> klass)
Optionally sets a type attribute on the generated element.
|
protected void |
setValue(Element elem,
String value)
Sets the value of the generated element.
|
protected boolean |
shouldSkip(Object value)
Returns
true to indicate whether the appender should not
output the passed value. |
protected Bean2XmlAppenders.Appender(EnumSet<Bean2XmlOptions> options, Object rootObject)
options
- Options controlling the conversion.rootObject
- The root object being converted.protected Bean2XmlAppenders.Appender(Bean2XmlAppenders.Appender parent, Object nodeObject)
parent
- The parent appender. May not be null
.nodeObject
- The object "owned" by this appender.protected boolean isOptionSet(Bean2XmlOptions option)
protected boolean isCircularReference(Object obj)
protected boolean shouldSkip(Object value)
true
to indicate whether the appender should not
output the passed value. Also tests for circular references.protected void setType(Element elem, Class<?> klass)
public void overrideType(Element elem, String typedesc)
protected void setValue(Element elem, String value)
public abstract Element appendValue(String name, Class<?> klass, String value)
name
- Name to be associated with the node.klass
- Java class for this node. May (depending on options)
be stored in the type
attribute.value
- The node's value. May be null
, in
which case the appender decides whether or not
to actually append the node.ConversionException
- if unable to append the node.