de.unikassel.android.sdcframework.data.independent
Class GlobalSerializer

Package class diagram package GlobalSerializer
java.lang.Object
  extended by org.simpleframework.xml.core.Persister
      extended by de.unikassel.android.sdcframework.data.independent.GlobalSerializer
All Implemented Interfaces:
org.simpleframework.xml.Serializer

public final class GlobalSerializer
extends org.simpleframework.xml.core.Persister

The global serializer does hold the global Persister instance of the Simple XML framework. It does provide static methods for serialization and deserialization purpose.


Field Summary
private static org.simpleframework.xml.core.Persister serializer
          The global serializer instance
 
Constructor Summary
GlobalSerializer()
           
 
Method Summary
static
<T> T
fromXML(Class<T> c, String xml)
          Deserialization from the XML representation to the type
static
<T> T
serializeFromFile(Class<T> c, File file)
          Deserialization from the XML file to the type
static
<T> T
serializeFromStream(Class<T> c, InputStream is)
          Deserialization from an input stream to the type
static void serializeToFile(Object source, File file)
          Method to serialize an object into a file
static void serializeToStream(Object source, OutputStream os)
          Method to serialize an object into an output stream
static String toXml(Object source)
          Method to serialize an object
 
Methods inherited from class org.simpleframework.xml.core.Persister
read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, validate, validate, validate, validate, validate, validate, validate, validate, validate, validate, write, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serializer

private static final org.simpleframework.xml.core.Persister serializer
The global serializer instance

Constructor Detail

GlobalSerializer

public GlobalSerializer()
Method Detail

toXml

public static String toXml(Object source)
                    throws Exception
Method to serialize an object

Parameters:
source - the source object to serialize
Returns:
the serialized object as string
Throws:
Exception - if the schema for the object is not valid

serializeToFile

public static void serializeToFile(Object source,
                                   File file)
                            throws Exception
Method to serialize an object into a file

Parameters:
source - the source object to serialize
file - the file to write serialized object into
Throws:
Exception - if the schema for the object is not valid

serializeToStream

public static void serializeToStream(Object source,
                                     OutputStream os)
                              throws Exception
Method to serialize an object into an output stream

Parameters:
source - the source object to serialize
os - the output stream to write serialized object into
Throws:
Exception - if the schema for the object is not valid

serializeFromFile

public static <T> T serializeFromFile(Class<T> c,
                                      File file)
                           throws Exception
Deserialization from the XML file to the type

Type Parameters:
T - the type to deserialize
Parameters:
c - the class of the type to deserialize
file - the XML file
Returns:
the deserialized instance of the class
Throws:
Exception - if the object cannot be fully deserialized

serializeFromStream

public static <T> T serializeFromStream(Class<T> c,
                                        InputStream is)
                             throws Exception
Deserialization from an input stream to the type

Type Parameters:
T - the type to deserialize
Parameters:
c - the class of the type to deserialize
is - the input stream
Returns:
the deserialized instance of the class
Throws:
Exception - if the object cannot be fully deserialized

fromXML

public static <T> T fromXML(Class<T> c,
                            String xml)
                 throws Exception
Deserialization from the XML representation to the type

Type Parameters:
T - the type to deserialize
Parameters:
c - the class of the type to deserialize
xml - the XML representation of the type as string
Returns:
the deserialized instance of this class
Throws:
Exception - if the object cannot be fully deserialized