Package org.duracloud.common.xml
Class XmlSerializer<T>
- java.lang.Object
-
- org.duracloud.common.xml.XmlSerializer<T>
-
public class XmlSerializer<T> extends Object
Handles the transfer of java beans to XML and back through JAXB
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedXmlSerializer(Class clazz, String schemaName, String schemaVersion)Creates a serializer which will be used to handle serializations to and from the given top level class, using the given schema.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tdeserialize(InputStream stream)De-serializes XML from an InputStream into an object structure.Tdeserialize(String xml)De-serializes XML into an object structure.Stringserialize(T obj)Serializes the data stored within a java bean to XML.
-
-
-
Constructor Detail
-
XmlSerializer
protected XmlSerializer(Class clazz, String schemaName, String schemaVersion)
Creates a serializer which will be used to handle serializations to and from the given top level class, using the given schema.- Parameters:
clazz- class which should be annotated as an XmlRootElementschemaName- name of the schema to use for validationschemaVersion- version of the schema expected
-
-
Method Detail
-
serialize
public String serialize(T obj)
Serializes the data stored within a java bean to XML. The bean and any ancillary beans should include JAXB binding annotations.- Parameters:
obj- to serialize- Returns:
- XML
-
deserialize
public T deserialize(String xml)
De-serializes XML into an object structure.- Parameters:
xml- to de-serialize- Returns:
- de-serialized object
-
deserialize
public T deserialize(InputStream stream)
De-serializes XML from an InputStream into an object structure.- Parameters:
stream- containing XML to de-serialize- Returns:
- de-serialized object
-
-