de.enough.polish.io
Class Serializer

java.lang.Object
  extended by de.enough.polish.io.Serializer

public final class Serializer
extends java.lang.Object

The serializer class is used for serializing and de-serializing objects in a unified way.

High level serialization components like the RmsStorage use this helper class for the actual serialization.

Copyright Enough Software 2006 - 2008

 history
        Mar 31, 2006 - rob creation
 

Author:
Robert Virkus, j2mepolish@enough.de

Method Summary
static java.lang.Object deserialize(java.io.DataInputStream in)
          Deserializes an object from the given stream.
static void serialize(java.lang.Object object, java.io.DataOutputStream out)
          Serializes the specified object.
static void serialize(java.lang.Object object, java.io.DataOutputStream out, boolean useObfuscation)
          WARNING: Can only be used in JavaSE environments! Serializes the specified object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

serialize

public static void serialize(java.lang.Object object,
                             java.io.DataOutputStream out)
                      throws java.io.IOException
Serializes the specified object. Any class implementing Serializable can be serialized, additionally classes like java.lang.Integer, java.util.Date, javax.util.Vector, javax.microedition.lcdui.Image etc. can be serialized.

Parameters:
object - the object
out - the stream into which the object should be serialized
Throws:
java.io.IOException - when serialization data could not be written or when encountering an object that cannot be serialized
See Also:
for deseralizing objects

serialize

public static void serialize(java.lang.Object object,
                             java.io.DataOutputStream out,
                             boolean useObfuscation)
                      throws java.io.IOException
WARNING: Can only be used in JavaSE environments! Serializes the specified object.

Parameters:
object - the object
out - the stream into which the object should be serialized
useObfuscation - true when classnames are obfuscated
Throws:
java.io.IOException - when serialization data could not be written or when encountering an object that cannot be serialized

deserialize

public static java.lang.Object deserialize(java.io.DataInputStream in)
                                    throws java.io.IOException
Deserializes an object from the given stream.

Parameters:
in - the data input stream, from which the object is deserialized
Returns:
the serializable object
Throws:
java.io.IOException - when serialization data could not be read or the Serializable class could not get instantiated