Class SerializerHelper
java.lang.Object
org.pentaho.reporting.libraries.serializer.SerializerHelper
The SerializeHelper is used to make implementing custom serialization handlers easier. Handlers for certain object
types need to be added to this helper before this implementation is usable.
- Author:
- Thomas Morgner
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ClassComparatorReturns the class comparator instance used to find correct super classes.static SerializerHelperReturns or creates a new SerializerHelper.protected HashMapReturns the collection of all registered serialize methods.protected SerializeMethodLooks up the SerializeMethod for the given class or null if there is no SerializeMethod for the given class.protected SerializeMethodLooks up the SerializeMethod for the given class or null if there is no SerializeMethod for the given class.booleanReads the object from the object input stream.voidregisterMethod(SerializeMethod method) Registers a new SerializeMethod with this SerializerHelper.protected voidTraverses the configuration and registers all serialization handlers in this factory.voidunregisterMethod(SerializeMethod method) Deregisters a new SerializeMethod with this SerializerHelper.voidwriteObject(Object o, ObjectOutputStream out) Writes a serializable object description to the given object output stream.
-
Constructor Details
-
SerializerHelper
public SerializerHelper()Creates a new SerializerHelper.
-
-
Method Details
-
getInstance
Returns or creates a new SerializerHelper. When a new instance is created by this method, all known SerializeMethods are registered.- Returns:
- the SerializerHelper singleton instance.
-
registerMethod
Registers a new SerializeMethod with this SerializerHelper.- Parameters:
method- the method that should be registered.
-
registerMethods
protected void registerMethods()Traverses the configuration and registers all serialization handlers in this factory. -
unregisterMethod
Deregisters a new SerializeMethod with this SerializerHelper.- Parameters:
method- the method that should be deregistered.
-
getMethods
Returns the collection of all registered serialize methods.- Returns:
- a collection of the registered serialize methods.
-
getComparator
Returns the class comparator instance used to find correct super classes.- Returns:
- the class comparator.
-
getSerializer
Looks up the SerializeMethod for the given class or null if there is no SerializeMethod for the given class.- Parameters:
c- the class for which we want to lookup a serialize method.- Returns:
- the method or null, if there is no registered method for the class.
-
getSuperClassObjectDescription
Looks up the SerializeMethod for the given class or null if there is no SerializeMethod for the given class. This method searches all superclasses.- Parameters:
d- the class for which we want to lookup a serialize method.- Returns:
- the method or null, if there is no registered method for the class.
-
writeObject
Writes a serializable object description to the given object output stream. This method selects the best serialize helper method for the given object.- Parameters:
o- the to be serialized object.out- the outputstream that should receive the object.- Throws:
IOException- if an I/O error occured.
-
isSerializable
-
readObject
Reads the object from the object input stream. This object selects the best serializer to read the object. Make sure, that you use the same configuration (library and class versions, registered methods in the SerializerHelper) for reading as you used for writing.- Parameters:
in- the object input stream from where to read the serialized data.- Returns:
- the generated object.
- Throws:
IOException- if reading the stream failed.ClassNotFoundException- if serialized object class cannot be found.
-