Package org.apache.shiro.lang.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
s.
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
invalid @link
CipherService
- Since:
- 0.9
-
Method Summary
Modifier and TypeMethodDescriptiondeserialize(byte[] serialized) Converts the specified raw byte[] array back into an original Object form.byte[]Converts the specified Object into a byte[] array.
-
Method Details
-
serialize
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
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.
-