Package 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>ASerializerconverts objects to raw binary data and vice versa, enabling persistent storage of objects to files, HTTP cookies, or other mechanism. ASerializershould only do conversion, never change the data, such as encoding/decoding or encryption. These orthogonal concerns are handled elsewhere by Shiro, for example, viaCodecSupportandCipherServices.- Since:
- 0.9
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Tdeserialize(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 thedeserializemethod.- 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 occurs 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 previousserializemethod call.- Parameters:
serialized- the raw data resulting from a previousserializecall.- Returns:
- the Object that was previously serialized into the raw byte[] array.
- Throws:
SerializationException- if an error occurs converting the raw byte[] array back into an Object.
-
-