Package net.solarnetwork.codec
Class JavaBeanXmlSerializer
java.lang.Object
net.solarnetwork.codec.JavaBeanXmlSerializer
- All Implemented Interfaces:
PropertySerializer
PropertySerializer that serializes JavaBean objects into XML strings.
This class can also be used in a stand-alone manner, calling the public methods exposed for generating XML from JavaBean objects.
The configurable properties of this class are:
- propertySerializerRegistrar
- An optional registrar of PropertySerializer instances that can be used to serialize specific objects into String values. This can be useful for formatting Date objects into strings, for example.
- Version:
- 2.0
- Author:
- matt
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionparseXml(InputStream in) Parse XML into a simple Map structure.voidrenderBean(Object bean, OutputStream out) Render a JavaBean object as XML serialized to a given OutputStream.voidrenderMap(Map<String, ?> model, OutputStream out) Render a Map as XML serialized to a given OutputStream.Serialize a property value.
-
Constructor Details
-
JavaBeanXmlSerializer
public JavaBeanXmlSerializer()
-
-
Method Details
-
serialize
Description copied from interface:PropertySerializerSerialize a property value.The
dataandpropertyNameparameters might not be used by different implementations, but allow for a single implementation to serialize more than one property of an object in different ways, if desired.- Specified by:
serializein interfacePropertySerializer- Parameters:
data- the source data being serialized, i.e. a JavaBeanpropertyName- the name of the property being serializedpropertyValue- the value of the property to serialize- Returns:
- the serialized value of the property
-
renderBean
Render a JavaBean object as XML serialized to a given OutputStream.- Parameters:
bean- the object to serialize as XMLout- the OutputStream to write the XML to
-
renderMap
Render a Map as XML serialized to a given OutputStream.- Parameters:
model- the data to serialize as XMLout- the OutputStream to write the XML to
-
parseXml
Parse XML into a simple Map structure.- Parameters:
in- the input stream to parse- Returns:
- a Map of the XML
-