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 Tdeserialize(byte[] serialized)This implementation deserializes the byte array using aObjectInputStreamusing a sourceByteArrayInputStreamconstructed with the argument byte array.byte[]serialize(T o)This implementation serializes the Object by using anObjectOutputStreambacked by aByteArrayOutputStream.
-
-
-
Method Detail
-
serialize
public byte[] serialize(T o) throws SerializationException
This implementation serializes the Object by using anObjectOutputStreambacked by aByteArrayOutputStream. TheByteArrayOutputStream's backing byte array is returned.- Specified by:
serializein 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 aIOExceptionif something goes wrong with the streams.
-
deserialize
public T deserialize(byte[] serialized) throws SerializationException
This implementation deserializes the byte array using aObjectInputStreamusing a sourceByteArrayInputStreamconstructed with the argument byte array.- Specified by:
deserializein interfaceSerializer<T>- Parameters:
serialized- the raw data resulting from a previousserializecall.- Returns:
- the deserialized/reconstituted object based on the given byte array
- Throws:
SerializationException- if anything goes wrong using the streams.
-
-