public class XStreamHelper extends Object
Title: XStream Helper Class
Description: Provides some static helper functions for dealing with serialisation
Copyright: Copyright (c) 2006-2009
| Modifier and Type | Method and Description |
|---|---|
static void |
addAlias(String alias,
Class aliasedClass)
Adds an alias to the internally cached XStream instance
|
static void |
addAlias(String alias,
Class aliasedClass,
Class defaultImplementation)
Adds an alias (including a default implementation) to the internally cached XStream instance
|
static <T> T |
clone(T obj)
Performs a deep clone.
|
static XSHelper |
create() |
static Object |
deserialise(File f)
Deserialises an Object from a File
|
static Object |
deserialise(InputStream stream)
Deserialises an InputStream into an Object using the default XStream instance
|
static Object |
deserialise(String xml)
Uses the default XStream instance to deserialise an XML document into an Object
|
static boolean |
getCacheXstream()
Determines whether XStream instance caching is currently enabled
|
static boolean |
getNoObjectGraph()
Returns the current state of object graph serialisation
|
static boolean |
getRegisterStandardTypeConverters()
Determines whether standard type converters have been enabled
|
static void |
registerConverter(com.thoughtworks.xstream.converters.Converter converter)
Registers a Converter with the internal XStream instance
|
static BooleanMessage |
serialise(File f,
Object o)
Uses the default XStream instance to serialise an object to a File
|
static String |
serialise(Object o)
Uses the default XStream instance to serialise an object to a String
|
static BooleanMessage |
serialise(OutputStream os,
Object o)
Uses the default XStream instance to serialise an object to an OutputStream
|
static void |
setCacheXstream(boolean val)
Enables or disables the caching of XStream instances internally When changed any cached xstream instance will be discarded
|
static void |
setNoObjectGraph(boolean val)
Enables or disabled object graph serialisation (whether the same object is duplicated or linked in the output XML
document)
|
static void |
setRegisterStandardTypeConverters(boolean val)
Sets whether the standard type converters (eg.
|
static void |
setXs(XSHelper xs)
Sets the internal XStream instance to use (provided caching is enabled)
|
static Class |
typeOf(com.thoughtworks.xstream.XStream xs,
String s)
Helper method to allow easy testing of the type of a serialised type.
|
static void |
useAttributeFor(Class<? extends Object> definedIn,
String fieldName) |
public static void setNoObjectGraph(boolean val)
val - True to disable object graph serialisation, otherwise false to enable itpublic static boolean getNoObjectGraph()
public static void setRegisterStandardTypeConverters(boolean val)
val - boolean - if true, the typpublic static boolean getRegisterStandardTypeConverters()
public static void setCacheXstream(boolean val)
val - public static boolean getCacheXstream()
public static void setXs(XSHelper xs)
xs - Error - if XStream caching is not enabledpublic static XSHelper create()
public static void useAttributeFor(Class<? extends Object> definedIn, String fieldName)
public static void addAlias(String alias, Class aliasedClass)
alias - The alias namealiasedClass - The class to be aliasedError - when XStream caching is disabledpublic static void addAlias(String alias, Class aliasedClass, Class defaultImplementation)
alias - The alias namealiasedClass - The class to be aliaseddefaultImplementation - The default implementationError - when XStream caching is disabledpublic static void registerConverter(com.thoughtworks.xstream.converters.Converter converter)
converter - The converter to registerError - when XStream caching is disabledpublic static String serialise(Object o)
o - The object to serialisepublic static BooleanMessage serialise(File f, Object o)
f - The file to serialise too - The object to serialisepublic static BooleanMessage serialise(OutputStream os, Object o)
os - the stream to output too - The object to serialisepublic static Object deserialise(File f)
f - The file to deserialisepublic static Object deserialise(String xml)
xml - The XML document to deserialisepublic static Object deserialise(InputStream stream)
stream - The InputStreampublic static Class typeOf(com.thoughtworks.xstream.XStream xs, String s)
xs - the XStream instance to uses - The string representing the serialised objectpublic static <T> T clone(T obj)
XSHelper.cloneT - obj - Copyright © 2015. All rights reserved.