com.sibvisions.rad.remote
Class UniversalSerializer

java.lang.Object
  extended by com.sibvisions.rad.remote.UniversalSerializer
All Implemented Interfaces:
ISerializer

public final class UniversalSerializer
extends Object
implements ISerializer

The UniversalSerializer converts an object state into a byte stream in such a way that the byte stream can be converted back into a copy of the object.

See Also:
ISerializer

Constructor Summary
UniversalSerializer()
          Creates a new instance of UniversalSerializer with default serializer registrations.
 
Method Summary
 ITypeSerializer getTypeSerializer(Class<?> pTypeClass)
          Gets the ITypeSerializer for a type value.
 ITypeSerializer getTypeSerializer(int pTypeValue)
          Gets the ITypeSerializer for a type value.
 ITypeSerializer getTypeSerializer(Object pObject)
          Gets the ITypeSerializer for a type value.
 Object read(DataInputStream pIn)
          Reads in a serialized object from a stream.
 Object read(DataInputStream pIn, TypeCache pCache)
          Reads in a serialized object from a stream.
 void registerTypeSerializer(ITypeSerializer pTypeSerializer)
          Registers a type serializer.
 void unregisterTypeSerializer(ITypeSerializer pTypeSerializer)
          Unregisters a type serializer.
 void write(DataOutputStream pOut, Object pObject)
          Writes a serialized object to a stream.
 void write(DataOutputStream pOut, Object pObject, TypeCache pCache)
          Writes a serialized object to a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UniversalSerializer

public UniversalSerializer()
Creates a new instance of UniversalSerializer with default serializer registrations.

Method Detail

read

public final Object read(DataInputStream pIn)
                  throws Exception
Reads in a serialized object from a stream.

Specified by:
read in interface ISerializer
Parameters:
pIn - stream with serialized content
Returns:
deserialized object
Throws:
Exception - if deserialization fails

write

public final void write(DataOutputStream pOut,
                        Object pObject)
                 throws Exception
Writes a serialized object to a stream.

Specified by:
write in interface ISerializer
Parameters:
pOut - output stream for the object
pObject - serializable object
Throws:
Exception - if serialization fails

read

public final Object read(DataInputStream pIn,
                         TypeCache pCache)
                  throws Exception
Reads in a serialized object from a stream.

Parameters:
pIn - stream with serialized content
pCache - the cache for optimized bean transfer
Returns:
deserialized object
Throws:
Exception - if deserialization fails

write

public final void write(DataOutputStream pOut,
                        Object pObject,
                        TypeCache pCache)
                 throws Exception
Writes a serialized object to a stream.

Parameters:
pOut - output stream for the object
pObject - serializable object
pCache - the cache for optimized bean transfer
Throws:
Exception - if serialization fails

registerTypeSerializer

public void registerTypeSerializer(ITypeSerializer pTypeSerializer)
Registers a type serializer.

Parameters:
pTypeSerializer - the type serializer.
Throws:
IllegalArgumentException - if the byte range is already used

unregisterTypeSerializer

public void unregisterTypeSerializer(ITypeSerializer pTypeSerializer)
Unregisters a type serializer.

Parameters:
pTypeSerializer - the type serializer.

getTypeSerializer

public ITypeSerializer getTypeSerializer(int pTypeValue)
                                  throws IOException
Gets the ITypeSerializer for a type value.

Parameters:
pTypeValue - the type value.
Returns:
the ITypeSerializer.
Throws:
IOException - if the type value is unknown.

getTypeSerializer

public ITypeSerializer getTypeSerializer(Class<?> pTypeClass)
                                  throws IOException
Gets the ITypeSerializer for a type value.

Parameters:
pTypeClass - the type value.
Returns:
the ITypeSerializer.
Throws:
IOException - if the type value is unknown.

getTypeSerializer

public ITypeSerializer getTypeSerializer(Object pObject)
                                  throws IOException
Gets the ITypeSerializer for a type value.

Parameters:
pObject - the type value.
Returns:
the ITypeSerializer.
Throws:
IOException - if the type value is unknown.


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.