Class XStreamSerializer

  • Direct Known Subclasses:
    XMLSerializer

    public abstract class XStreamSerializer
    extends java.lang.Object
    Serializes/deserializes XML using XStream.
    See Also:
    XStream
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected XStreamSerializer​(java.lang.String driverId, com.thoughtworks.xstream.io.HierarchicalStreamDriver driver)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addAlias​(java.lang.String name, java.lang.Class<?> type)
      Makes name an alias for the class type.
      void addAliasType​(java.lang.String name, java.lang.Class<?> type)
      Makes name an alias for the class type.
      java.lang.Object deserialize​(java.io.InputStream is)
      Creates an object from XML.
      java.lang.Object deserialize​(java.io.Reader r)
      Creates an object from XML.
      java.lang.Object deserialize​(java.lang.String xml)
      Creates an object from XML.
      java.lang.Object deserialize​(org.dom4j.Document doc)
      Deserializes an object from a DOM4J Document
      java.lang.Object deserialize​(org.dom4j.Element elem)
      Deserializes an object from a DOM4J Element
      java.lang.Object deserialize​(org.w3c.dom.Element elem)
      Deserializes an object from a DOM4J Document
      com.thoughtworks.xstream.converters.Converter getConverter​(java.lang.Class<?> clazz)
      Gets a converter (or null) for the type.
      boolean isCompact()
      Tells whether the mode is 'compact'
      void registerConverter​(java.lang.Class<? extends AbstractConverter> converterType)
      Registers a custom converter.
      java.lang.String serialize​(java.lang.Object o)
      Serializes an object to XML.
      java.lang.String serialize​(java.lang.Object o, boolean compact)
      Serializes an object to XML.
      void serialize​(java.lang.Object o, java.io.OutputStream os)
      Serializes an object to XML.
      void serialize​(java.lang.Object o, java.io.OutputStream os, boolean compact)
      Serializes an object to XML.
      void serialize​(java.lang.Object o, java.io.Writer w)
      Serializes an object to XML.
      void serialize​(java.lang.Object o, java.io.Writer w, boolean compact)
      Serializes an object to XML.
      void setCompact​(boolean compact)
      Sets the 'compact' mode to "on".
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • XStreamSerializer

        protected XStreamSerializer​(java.lang.String driverId,
                                    com.thoughtworks.xstream.io.HierarchicalStreamDriver driver)
        Constructor
        Parameters:
        driverId - the driver ID
        driver - the hierarchical stream driver
    • Method Detail

      • deserialize

        public java.lang.Object deserialize​(java.io.InputStream is)
                                     throws java.lang.ClassNotFoundException
        Creates an object from XML.
        Parameters:
        is - input stream
        Returns:
        the deserialized object
        Throws:
        java.lang.ClassNotFoundException
      • deserialize

        public java.lang.Object deserialize​(java.io.Reader r)
                                     throws java.lang.ClassNotFoundException
        Creates an object from XML.
        Parameters:
        r - reader
        Returns:
        the deserialized object
        Throws:
        java.lang.ClassNotFoundException
      • deserialize

        public java.lang.Object deserialize​(java.lang.String xml)
                                     throws java.lang.ClassNotFoundException
        Creates an object from XML.
        Parameters:
        xml - XML
        Returns:
        the deserialized object
        Throws:
        java.lang.ClassNotFoundException
      • deserialize

        public java.lang.Object deserialize​(org.dom4j.Document doc)
                                     throws java.lang.ClassNotFoundException
        Deserializes an object from a DOM4J Document
        Parameters:
        doc - the document
        Returns:
        the deserialized object
        Throws:
        java.lang.ClassNotFoundException
      • deserialize

        public java.lang.Object deserialize​(org.w3c.dom.Element elem)
                                     throws java.lang.ClassNotFoundException
        Deserializes an object from a DOM4J Document
        Parameters:
        elem - the element to deserialize from
        Returns:
        the deserialized object
        Throws:
        java.lang.ClassNotFoundException
      • deserialize

        public java.lang.Object deserialize​(org.dom4j.Element elem)
                                     throws java.lang.ClassNotFoundException
        Deserializes an object from a DOM4J Element
        Parameters:
        elem - the element
        Returns:
        the deserialized object
        Throws:
        java.lang.ClassNotFoundException
      • serialize

        public void serialize​(java.lang.Object o,
                              java.io.OutputStream os)
        Serializes an object to XML.
        Parameters:
        o - object the object
        os - output stream
        Throws:
        java.io.UnsupportedEncodingException
      • serialize

        public void serialize​(java.lang.Object o,
                              java.io.OutputStream os,
                              boolean compact)
        Serializes an object to XML.
        Parameters:
        o - object the object
        os - output stream
        Throws:
        java.io.UnsupportedEncodingException
      • serialize

        public void serialize​(java.lang.Object o,
                              java.io.Writer w)
        Serializes an object to XML.
        Parameters:
        o - object the object
        w - writer the writer to write to
      • serialize

        public void serialize​(java.lang.Object o,
                              java.io.Writer w,
                              boolean compact)
        Serializes an object to XML.
        Parameters:
        o - object the object
        w - writer the writer to write to
        compact - true if the output should be serialized in a compact/non-prettyprint style.
      • serialize

        public java.lang.String serialize​(java.lang.Object o)
        Serializes an object to XML.
        Parameters:
        o - the object
        Returns:
        the XML
      • serialize

        public java.lang.String serialize​(java.lang.Object o,
                                          boolean compact)
        Serializes an object to XML.
        Parameters:
        o - the object
        Returns:
        the XML
      • isCompact

        public boolean isCompact()
        Tells whether the mode is 'compact'
        Returns:
        true if the mode is 'compact'
      • setCompact

        public void setCompact​(boolean compact)
        Sets the 'compact' mode to "on".
        Parameters:
        compact - true to set the compact mode to "on"
      • addAlias

        public void addAlias​(java.lang.String name,
                             java.lang.Class<?> type)
        Makes name an alias for the class type.
        Parameters:
        name -
        type -
      • addAliasType

        public void addAliasType​(java.lang.String name,
                                 java.lang.Class<?> type)
        Makes name an alias for the class type.
        Parameters:
        name -
        type -
      • registerConverter

        public void registerConverter​(java.lang.Class<? extends AbstractConverter> converterType)
        Registers a custom converter.
        Parameters:
        converterType -
      • getConverter

        public com.thoughtworks.xstream.converters.Converter getConverter​(java.lang.Class<?> clazz)
        Gets a converter (or null) for the type.