All Packages Class Hierarchy This Package Previous Next Index
au.com.pharos.packing.Packing
Generally, each packing Packing should be reflexive: that is, converting any object to and from an array of bytes should yield the same object, or an object appropriately equivalent.
Some Packing subclasses may not be able to pack all
objects, or may not be able to unpack an object from some byte
arrays. For example, only Strings can safely be stored as string
representations, and not all arrays are valid Java serialization
forms. In this case, the Packing object should throw an
IllegalArgumentException
from toBytes()
or toBytes()
.
In both cases, null references should be passed through unchanged.
Example:
Packing strategy = new StringPacking(); byte[] raw = strategy.toBytes("Hello world"); ... store and retrieve raw[] String result = (String) strategy.fromBytes(raw)
public Packing()
public abstract byte[] toBytes(Object obj) throws IllegalArgumentException
public abstract Object fromBytes(byte raw[]) throws IllegalArgumentException
protected IllegalArgumentException cantConvert(Object obj)
All Packages Class Hierarchy This Package Previous Next Index