Top Description Fields Constructors Methods
org.springframework.core.serializer.support

public Class SerializationDelegate

extends Object
implements Serializer<Object>, Deserializer<Object>
Class Inheritance
All Implemented Interfaces
org.springframework.core.serializer.Deserializer, org.springframework.core.serializer.Serializer
Imports
java.io.IOException, .InputStream, .OutputStream, org.springframework.core.serializer.DefaultDeserializer, .DefaultSerializer, .Deserializer, .Serializer, org.springframework.util.Assert

A convenient delegate with pre-arranged configuration state for common serialization needs. Implements Serializer and Deserializer itself, so can also be passed into such more specific callback methods.
Author
Juergen Hoeller
Since
4.3

Field Summary

Modifier and TypeField and Description
private final Deserializer<Object>
private final Serializer<Object>

Constructor Summary

AccessConstructor and Description
public
SerializationDelegate(ClassLoader classLoader)

Create a SerializationDelegate with a default serializer/deserializer for the given ClassLoader.

public
SerializationDelegate(Serializer<Object>
the Serializer to use (never null)
serializer
,
Deserializer<Object>
the Deserializer to use (never null)
deserializer
)

Create a SerializationDelegate with the given serializer/deserializer.

Method Summary

Modifier and TypeMethod and Description
public Object
deserialize(InputStream
the input stream
inputStream
)

Implements org.springframework.core.serializer.Deserializer.deserialize.

Read (assemble) an object of type T from the given InputStream.

public void
serialize(Object
the object to serialize
object
,
OutputStream
the output stream
outputStream
)

Implements org.springframework.core.serializer.Serializer.serialize.

Write an object of type T to the given OutputStream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

deserializerback to summary
private final Deserializer<Object> deserializer
serializerback to summary
private final Serializer<Object> serializer

Constructor Detail

SerializationDelegateback to summary
public SerializationDelegate(ClassLoader classLoader)

Create a SerializationDelegate with a default serializer/deserializer for the given ClassLoader.

See Also
DefaultDeserializer, DefaultDeserializer#DefaultDeserializer(ClassLoader)
SerializationDelegateback to summary
public SerializationDelegate(Serializer<Object> serializer, Deserializer<Object> deserializer)

Create a SerializationDelegate with the given serializer/deserializer.

Parameters
serializer:Serializer<Object>

the Serializer to use (never null)

deserializer:Deserializer<Object>

the Deserializer to use (never null)

Method Detail

deserializeback to summary
public Object deserialize(InputStream inputStream) throws IOException

Implements org.springframework.core.serializer.Deserializer.deserialize.

Doc from org.springframework.core.serializer.Deserializer.deserialize.

Read (assemble) an object of type T from the given InputStream.

Note

Implementations should not close the given InputStream (or any decorators of that InputStream) but rather leave this up to the caller.

Parameters
inputStream:InputStream

the input stream

Returns:Object

the deserialized object

Annotations
@Override
Exceptions
IOException:
in case of errors reading from the stream
serializeback to summary
public void serialize(Object object, OutputStream outputStream) throws IOException

Implements org.springframework.core.serializer.Serializer.serialize.

Doc from org.springframework.core.serializer.Serializer.serialize.

Write an object of type T to the given OutputStream.

Note

Implementations should not close the given OutputStream (or any decorators of that OutputStream) but rather leave this up to the caller.

Parameters
object:Object

the object to serialize

outputStream:OutputStream

the output stream

Annotations
@Override
Exceptions
IOException:
in case of errors writing to the stream