Package org.apache.shiro.io
Class DefaultSerializer<T>
- java.lang.Object
-
- org.apache.shiro.io.DefaultSerializer<T>
-
- All Implemented Interfaces:
Serializer<T>
public class DefaultSerializer<T> extends Object implements Serializer<T>
Serializer implementation that uses the default JVM serialization mechanism (Object Input/Output Streams).- Since:
- 0.9
-
-
Constructor Summary
Constructors Constructor Description DefaultSerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
deserialize(byte[] serialized)
This implementation deserializes the byte array using aObjectInputStream
using a sourceByteArrayInputStream
constructed with the argument byte array.byte[]
serialize(T o)
This implementation serializes the Object by using anObjectOutputStream
backed by aByteArrayOutputStream
.
-
-
-
Constructor Detail
-
DefaultSerializer
public DefaultSerializer()
-
-
Method Detail
-
serialize
public byte[] serialize(T o) throws SerializationException
This implementation serializes the Object by using anObjectOutputStream
backed by aByteArrayOutputStream
. TheByteArrayOutputStream
's backing byte array is returned.- Specified by:
serialize
in interfaceSerializer<T>
- Parameters:
o
- the Object to convert into a byte[] array.- Returns:
- the bytes representing the serialized object using standard JVM serialization.
- Throws:
SerializationException
- wrapping aIOException
if something goes wrong with the streams.
-
deserialize
public T deserialize(byte[] serialized) throws SerializationException
This implementation deserializes the byte array using aObjectInputStream
using a sourceByteArrayInputStream
constructed with the argument byte array.- Specified by:
deserialize
in interfaceSerializer<T>
- Parameters:
serialized
- the raw data resulting from a previousserialize
call.- Returns:
- the deserialized/reconstituted object based on the given byte array
- Throws:
SerializationException
- if anything goes wrong using the streams.
-
-