Class XStreamUtil


  • public class XStreamUtil
    extends Object
    • Constructor Detail

      • XStreamUtil

        public XStreamUtil()
    • Method Detail

      • getDataClassNamesForIdRepresentation

        public static Set<String> getDataClassNamesForIdRepresentation()
      • setDataClassNamesForIdRepresentation

        public static void setDataClassNamesForIdRepresentation​(Set<String> classNames)
        Parameters:
        classNames - custom and system data class names of the data objects for which only the objectId should be serialized (if one exists)
      • getXStreamInstance

        public static com.thoughtworks.xstream.XStream getXStreamInstance()
      • resetXStreamInstance

        public static void resetXStreamInstance()
      • getXStreamInstance

        public static com.thoughtworks.xstream.XStream getXStreamInstance​(boolean useDataObjectIdRepresentation)
      • resetXStreamInstance

        public static void resetXStreamInstance​(boolean useDataObjectIdRepresentation)
      • getXStreamInstanceJson

        public static com.thoughtworks.xstream.XStream getXStreamInstanceJson()
      • resetXStreamInstanceJson

        public static void resetXStreamInstanceJson()
      • getXStreamInstanceJson

        public static com.thoughtworks.xstream.XStream getXStreamInstanceJson​(boolean useDataObjectIdRepresentation)
      • resetXStreamInstanceJson

        public static void resetXStreamInstanceJson​(boolean useDataObjectIdRepresentation)
      • toXML

        public static String toXML​(Object o)
        Parameters:
        o - object to be serialized
        Returns:
        string
      • toJSON

        public static String toJSON​(Object o)
        Parameters:
        o - object to be serialized
        Returns:
        string
      • toXML

        public static String toXML​(Object o,
                                   boolean useDataObjectIdRepresentation)
        Parameters:
        o - object to be serialized
        useDataObjectIdRepresentation - if true, only the objectId of a data object is serialized (if one exists). Make sure to register the data class names before with XStreamUtil.setDataClassNamesForIdRepresentation()
        Returns:
        string
      • toJSON

        public static String toJSON​(Object o,
                                    boolean useDataObjectIdRepresentation)
        Parameters:
        o - object to be serialized
        useDataObjectIdRepresentation - if true, only the objectId of a data object is serialized (if one exists). Make sure to register the data class names before with XStreamUtil.setDataClassNamesForIdRepresentation()
        Returns:
        string
      • fromXML

        public static <T> T fromXML​(String xml)
        Parameters:
        xml - string to be deserialized
        Returns:
        object
      • fromXML

        public static <T> T fromXML​(String xml,
                                    boolean useDataObjectIdRepresentation)
        Parameters:
        xml - string to be deserialized
        useDataObjectIdRepresentation - if true, only the objectId of a data object is serialized (if one exists). Make sure to register the data class names before with XStreamUtil.setDataClassNamesForIdRepresentation()
        Returns:
        object
      • fromJSON

        public static <T> T fromJSON​(String json)
        Parameters:
        json - string to be deserialized
        Returns:
        object
      • fromJSON

        public static <T> T fromJSON​(String json,
                                     boolean useDataObjectIdRepresentation)
        Parameters:
        json - string to be deserialized
        useDataObjectIdRepresentation - if true, only the objectId of a data object is serialized (if one exists). Make sure to register the data class names before with XStreamUtil.setDataClassNamesForIdRepresentation()
        Returns:
        object