public interface ObjectSerializer
byte
s. Unlike usual serializing components, this one doesn't enforce the
serialized object to implement Serializable
. However, some implementations
might require that condition and throw IllegalArgumentException
if not
met.
Implementations are also responsible for the correct initialization of classes
implementing the DeserializationPostInitialisable
interface.
Unexpected behavior can result of deserializing objects that were generated with
a different implementation of ObjectSerializer
.
Implementations are required to be thread-safeModifier and Type | Method and Description |
---|---|
<T> T |
deserialize(byte[] bytes)
Deserializes the given bytes.
|
<T> T |
deserialize(byte[] bytes,
ClassLoader classLoader)
Deserializes the given bytes.
|
<T> T |
deserialize(InputStream inputStream)
Deserializes the given stream of bytes.
|
<T> T |
deserialize(InputStream inputStream,
ClassLoader classLoader)
Deserializes the given stream of bytes.
|
byte[] |
serialize(Object object)
Serializes the given object into a an array of
byte s |
void |
serialize(Object object,
OutputStream out)
Serializes the given object and writes the result into
out |
byte[] serialize(Object object) throws SerializationException
byte
sobject
- the object to be serialized. Might be null
byte
SerializationException
- in case of unexpected exceptionvoid serialize(Object object, OutputStream out) throws SerializationException
out
object
- the object to be serialized. Might be null
out
- an OutputStream
where the result will be writtenSerializationException
- in case of unexpected exception<T> T deserialize(byte[] bytes) throws SerializationException
DeserializationPostInitialisable
then this serializer will be responsible for properly initializing
the object before returning it.
Implementation will choose the ClassLoader
to use for deserialization.bytes
- an array of byte that an original object was serialized intoIllegalArgumentException
- if bytes
is null
SerializationException
- in case of unexpected exception<T> T deserialize(byte[] bytes, ClassLoader classLoader) throws SerializationException
DeserializationPostInitialisable
then this serializer will be responsible for properly initializing
the object before returning it.bytes
- an array of byte that an original object was serialized intoclassLoader
- the ClassLoader
to deserialize withIllegalArgumentException
- if bytes
is null
SerializationException
- in case of unexpected exception<T> T deserialize(InputStream inputStream) throws SerializationException
ClassLoader
to use for deserialization.
Even if deserialization fails, this method will close the
inputStream
If the obtained object implements DeserializationPostInitialisable
then this serializer will be responsible for properly initializing
the object before returning it.inputStream
- a stream of bytes that an original object was serialized intoIllegalArgumentException
- if inputStream
is null
SerializationException
- in case of unexpected exception<T> T deserialize(InputStream inputStream, ClassLoader classLoader) throws SerializationException
inputStream
If the obtained object implements DeserializationPostInitialisable
then this serializer will be responsible for properly initializing
the object before returning it.inputStream
- a stream of bytes that an original object was serialized intoclassLoader
- the ClassLoader
to deserialize withIllegalArgumentException
- if inputStream
is null
SerializationException
- in case of unexpected exceptionCopyright © 2003–2016 MuleSoft, Inc.. All rights reserved.