public class JodaBeanXmlWriter extends Object
This class contains mutable state and cannot be used from multiple threads. A new instance must be created for each message.
The XML consists of a root level 'bean' element with a 'type' attribute. At each subsequent level, a bean is output using the property name. Where necessary, the 'type' attribute is used to clarify a type.
Simple types, defined by Joda-Convert, are output as strings. Beans are output recursively within the parent property element. Collections are output using 'item' elements within the property element. The 'item' elements will use 'key' for map keys, 'count' for multiset counts and 'null=true' for null entries. Note that map keys must be simple types.
If a collection contains a collection then more information is written. A 'metatype' attribute is added to define the high level type, such as List. At this level, the data read back may not be identical to that written.
Type names are shortened by the package of the root type if possible. Certain basic types are also handled, such as String, Integer, File and URI.
| Constructor and Description |
|---|
JodaBeanXmlWriter(JodaBeanSer settings)
Creates an instance.
|
JodaBeanXmlWriter(JodaBeanSer settings,
StringBuilder builder)
Creates an instance.
|
| Modifier and Type | Method and Description |
|---|---|
String |
write(Bean bean)
Writes the bean to a string.
|
String |
write(Bean bean,
boolean rootType)
Writes the bean to a string.
|
StringBuilder |
writeToBuilder(Bean bean)
Writes the bean to the
StringBuilder. |
StringBuilder |
writeToBuilder(Bean bean,
boolean rootType)
Writes the bean to the
StringBuilder. |
public JodaBeanXmlWriter(JodaBeanSer settings)
settings - the settings to use, not nullpublic JodaBeanXmlWriter(JodaBeanSer settings, StringBuilder builder)
settings - the settings to use, not nullbuilder - the builder to output to, not nullpublic String write(Bean bean)
The type of the bean will be set in the message.
bean - the bean to output, not nullpublic String write(Bean bean, boolean rootType)
bean - the bean to output, not nullrootType - true to output the root typepublic StringBuilder writeToBuilder(Bean bean)
StringBuilder.
The type of the bean will be set in the message.
bean - the bean to output, not nullpublic StringBuilder writeToBuilder(Bean bean, boolean rootType)
StringBuilder.bean - the bean to output, not nullrootType - true to output the root typeCopyright © 2007–2017 Joda.org. All rights reserved.