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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DefaultSerializer
public DefaultSerializer()
serialize
public byte[] serialize(T o)
throws SerializationException
- This implementation serializes the Object by using an
ObjectOutputStream
backed by a
ByteArrayOutputStream
. The ByteArrayOutputStream
's backing byte array is returned.
- Specified by:
serialize
in interface Serializer<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 a IOException
if something goes wrong with the streams.
deserialize
public T deserialize(byte[] serialized)
throws SerializationException
- This implementation deserializes the byte array using a
ObjectInputStream
using a source
ByteArrayInputStream
constructed with the argument byte array.
- Specified by:
deserialize
in interface Serializer<T>
- Parameters:
serialized
- the raw data resulting from a previous serialize
call.
- Returns:
- the deserialized/reconstituted object based on the given byte array
- Throws:
SerializationException
- if anything goes wrong using the streams.
Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.