com.openharbor.beck.marshal
Class ExpansionMarshaller
java.lang.Object
com.openharbor.beck.marshal.DefaultMarshaller
com.openharbor.beck.marshal.JavaBeanMarshaller
com.openharbor.beck.marshal.ExpansionMarshaller
- All Implemented Interfaces:
- Configurable, Marshaller
- public class ExpansionMarshaller
- extends JavaBeanMarshaller
- implements Configurable
Used in conjunction with ExpansionGetter
to marshal several properties to an element with several attributes or
sub-elements.
This marshaller works like JavaBeanMarshaller
, except it selects
the subset of properties whose names begin with a certain prefix, and
it removes that prefix from their names before mapping the names to XML.
If there are no such properties, or they don't map to XML (e.g. because
their XML is not permitted by the current Model
),
this marshaller writes no XML, not even an element for the parent JavaBean.
(A TentativeXMLWriter
is used to implement this.)
The original property name (including the prefix, if any) is used to choose
the marshaller for each selected property.
The prefix may be configured <choose marshaller="ExpansionMarshaller" prefix="foo"/>.
If prefix="" is configured, all properties will be mapped to XML,
with XML names mapped from the complete property names.
The default prefix (if none is configured) is the name of the parent
JavaBean, which works well with ExpansionGetter.
Fields inherited from interface com.openharbor.beck.configure.Configurable |
ATTRIBUTE, CLASS_IS_ARRAY, DIRECTION, ELEMENT, JAVA_TO_XML, NAMESPACE, NONE, PARENT_CLASS, PARENT_ELEMENT, PREDICATE, PREFIX, SCHEMA_LOCATION, TEXT, XML_TO_JAVA |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ExpansionMarshaller
public ExpansionMarshaller()
getConfiguration
public java.util.Map getConfiguration()
- Specified by:
getConfiguration
in interface Configurable
setConfiguration
public void setConfiguration(java.util.Map configuration)
- Specified by:
setConfiguration
in interface Configurable
getXMLSource
public java.lang.Object getXMLSource(MapToXML mapper,
java.lang.Object parent,
Getter getter)
- Return null to indicate that there is no object corresponding to this XML.
- Specified by:
getXMLSource
in interface Marshaller
- Overrides:
getXMLSource
in class DefaultMarshaller
writeAsElement
protected void writeAsElement(MapToXML mapper,
java.lang.Object parent,
Getter getter,
java.lang.Object source,
XMLThing tag,
XMLWriter writer)
throws java.lang.Exception
- Overrides:
writeAsElement
in class JavaBeanMarshaller
- Throws:
java.lang.Exception