org.apache.shiro.io
Interface Serializer<T>

Type Parameters:
T - The type of the object being serialized and deserialized.
All Known Implementing Classes:
DefaultSerializer, XmlSerializer

public interface Serializer<T>

A Serializer converts objects to raw binary data and vice versa, enabling persistent storage of objects to files, HTTP cookies, or other mechanism.

A Serializer should only do conversion, never change the data, such as encoding/decoding or encryption. These orthogonal concerns are handled elsewhere by Shiro, for example, via CodecSupport and CipherServices.

Since:
0.9

Method Summary
 T deserialize(byte[] serialized)
          Converts the specified raw byte[] array back into an original Object form.
 byte[] serialize(T o)
          Converts the specified Object into a byte[] array.
 

Method Detail

serialize

byte[] serialize(T o)
                 throws SerializationException
Converts the specified Object into a byte[] array. This byte[] array must be able to be reconstructed back into the original Object form via the deserialize method.

Parameters:
o - the Object to convert into a byte[] array.
Returns:
a byte[] array representing the Object's state that can be restored later.
Throws:
SerializationException - if an error occurrs converting the Object into a byte[] array.

deserialize

T deserialize(byte[] serialized)
              throws SerializationException
Converts the specified raw byte[] array back into an original Object form. This byte[] array is expected to be the output of a previous serialize method call.

Parameters:
serialized - the raw data resulting from a previous serialize call.
Returns:
the Object that was previously serialized into the raw byte[] array.
Throws:
SerializationException - if an error occurrs converting the raw byte[] array back into an Object.


Copyright © 2004-2014 The Apache Software Foundation. All Rights Reserved.