|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface SerializationManager
A SerializationManager is an object capable of both converting an
object into an OutputStream and recovering it from an
InputStream
This interface does not make any assumption regarding the strategy and format in which the object is serialized, it may be in plain text, like JSON, or in some kind of binary format. That should be specified by subinterfaces and/or implementors.
The only constraint a SerializationManager must meet regarding the
stream format is that serialize(Object, OutputStream) and
deserialize(InputStream) methods must be compatible, that means that
it must grant that if an input object is serialized and then deserialized
using the same instance of this manager, the output object must have the same
relevant estate that the original one. For every objects that follow
Value contract - either they implement that interface or not - the
following invariant must be satisfied by any implementor:
Value valueObject = (...); SerializationManager sm = (...); ByteArrayOutputStream out = new ByteArrayOutputStream(); sm.serialize(valueObject, out); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); assert(valueObject.equals(sm.deserialize(in)));
SerializationManager are not required to be able to serialize and
deserialize every possible object, and implementors may impose additional
restrictions to the kind of objects that are serilizable.
| Method Summary | ||
|---|---|---|
|
deserialize(File input)
|
|
|
deserialize(InputStream inputStream)
This method does not close the inputStream |
|
void |
serialize(Object target,
File output)
|
|
void |
serialize(Object target,
OutputStream outputStream)
Writes the given target object to the given
outputStream. |
|
| Method Detail |
|---|
void serialize(Object target,
OutputStream outputStream)
throws org.apache.commons.lang.SerializationException
target object to the given
outputStream.
This method does not close the outputStream
target - outputStream -
org.apache.commons.lang.SerializationException
<T> T deserialize(InputStream inputStream)
throws org.apache.commons.lang.SerializationException
T - inputStream -
org.apache.commons.lang.SerializationException
{@link - ClassCastException}<T> T deserialize(File input)
void serialize(Object target,
File output)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||