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 Details

    • 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 XmlRootElement
      schemaName - name of the schema to use for validation
      schemaVersion - version of the schema expected
  • Method Details

    • 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