public class XStreamHelper
extends java.lang.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(java.lang.String alias,
java.lang.Class aliasedClass)
Adds an alias to the internally cached XStream instance
|
static void |
addAlias(java.lang.String alias,
java.lang.Class aliasedClass,
java.lang.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 java.lang.Object |
deserialise(java.io.File f)
Deserialises an Object from a File
|
static java.lang.Object |
deserialise(java.io.InputStream stream)
Deserialises an InputStream into an Object using the default XStream instance
|
static java.lang.Object |
deserialise(java.lang.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(java.io.File f,
java.lang.Object o)
Uses the default XStream instance to serialise an object to a File
|
static java.lang.String |
serialise(java.lang.Object o)
Uses the default XStream instance to serialise an object to a String
|
static BooleanMessage |
serialise(java.io.OutputStream os,
java.lang.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 java.lang.Class |
typeOf(com.thoughtworks.xstream.XStream xs,
java.lang.String s)
Helper method to allow easy testing of the type of a serialised type.
|
static void |
useAttributeFor(java.lang.Class<? extends java.lang.Object> definedIn,
java.lang.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 - java.lang.Error - if XStream caching is not enabledpublic static XSHelper create()
public static void useAttributeFor(java.lang.Class<? extends java.lang.Object> definedIn,
java.lang.String fieldName)
public static void addAlias(java.lang.String alias,
java.lang.Class aliasedClass)
alias - The alias namealiasedClass - The class to be aliasedjava.lang.Error - when XStream caching is disabledpublic static void addAlias(java.lang.String alias,
java.lang.Class aliasedClass,
java.lang.Class defaultImplementation)
alias - The alias namealiasedClass - The class to be aliaseddefaultImplementation - The default implementationjava.lang.Error - when XStream caching is disabledpublic static void registerConverter(com.thoughtworks.xstream.converters.Converter converter)
converter - The converter to registerjava.lang.Error - when XStream caching is disabledpublic static java.lang.String serialise(java.lang.Object o)
o - The object to serialisepublic static BooleanMessage serialise(java.io.File f, java.lang.Object o)
f - The file to serialise too - The object to serialisepublic static BooleanMessage serialise(java.io.OutputStream os, java.lang.Object o)
os - the stream to output too - The object to serialisepublic static java.lang.Object deserialise(java.io.File f)
f - The file to deserialisepublic static java.lang.Object deserialise(java.lang.String xml)
xml - The XML document to deserialisepublic static java.lang.Object deserialise(java.io.InputStream stream)
stream - The InputStreampublic static java.lang.Class typeOf(com.thoughtworks.xstream.XStream xs,
java.lang.String s)
xs - the XStream instance to uses - The string representing the serialised objectpublic static <T> T clone(T obj)
XSHelper.cloneT - obj - Copyright © 2014. All Rights Reserved.