|
ProgramixGenericLib v5.0.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.programix.io.SerializationTools
public class SerializationTools
Handy tools for doing common object serialization tasks.
Nested Class Summary | |
---|---|
static class |
SerializationTools.SerializationException
Used to indicate that something went wrong in one of the SerializationTools functions. |
Method Summary | ||
---|---|---|
static Object |
fromByteArray(byte[] data)
|
|
static
|
fromInputStream(InputStream rawIn,
Class<T> targetType)
Deserializes, source bytes do not need to be decompressed. |
|
static
|
fromInputStream(InputStream rawIn,
Class<T> targetType,
boolean compressed)
|
|
static
|
makeClone(T obj)
Make a deep "clone" by serializing and then deserializing a new instance. |
|
static ByteArrayOutputStream |
toBAOS(Object obj)
Serializes to a ByteArrayOutputStream without doing any compression. |
|
static ByteArrayOutputStream |
toBAOS(Object obj,
boolean compress)
|
|
static byte[] |
toByteArray(Object obj)
Serializes without doing any compression. |
|
static Object |
unwrap(TransferWrapper tw)
|
|
static
|
unwrap(TransferWrapper tw,
Class<T> targetType)
Deserializes the byte representation of an object inside the wrapper. |
|
static TransferWrapper |
wrap(Object payload)
Serializes the payload and potentially compresses the resulting bytes. |
|
static TransferWrapper |
wrap(Object payload,
int compressionThreshold)
Serializes the payload and potentially compresses the resulting bytes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ByteArrayOutputStream toBAOS(Object obj, boolean compress) throws SerializationTools.SerializationException
SerializationTools.SerializationException
public static ByteArrayOutputStream toBAOS(Object obj) throws SerializationTools.SerializationException
SerializationTools.SerializationException
public static byte[] toByteArray(Object obj) throws SerializationTools.SerializationException
SerializationTools.SerializationException
public static Object fromByteArray(byte[] data) throws SerializationTools.SerializationException
SerializationTools.SerializationException
public static <T> T fromInputStream(InputStream rawIn, Class<T> targetType, boolean compressed) throws SerializationTools.SerializationException
SerializationTools.SerializationException
public static <T> T fromInputStream(InputStream rawIn, Class<T> targetType) throws SerializationTools.SerializationException
SerializationTools.SerializationException
public static <T> T makeClone(T obj) throws SerializationTools.SerializationException
SerializationTools.SerializationException
public static TransferWrapper wrap(Object payload, int compressionThreshold) throws SerializationTools.SerializationException
payload
- the object to be serialized.compressionThreshold
- if the serialized object's byte count is
below the threshold, no compression will be done. If at or above,
then compression is performed.
SerializationTools.SerializationException
- if there are problems
serializing the payloadpublic static TransferWrapper wrap(Object payload) throws SerializationTools.SerializationException
payload
- the object to be serialized.
SerializationTools.SerializationException
- if there are problems
serializing the payloadpublic static <T> T unwrap(TransferWrapper tw, Class<T> targetType) throws SerializationTools.SerializationException
tw
- the source of the bytes and the compression settingtargetType
- if null, then no checking is done and
any type of object is returned (including null). If not
null, then the deserialized object must not be null and must
be of the specified type (or a subtype of the specified type).
SerializationTools.SerializationException
- if there are problems
during deserialization, if the specified targetType is not matched, or
is a targetType is specified, but the deserialized object is null.public static Object unwrap(TransferWrapper tw) throws SerializationTools.SerializationException
SerializationTools.SerializationException
|
ProgramixGenericLib v5.0.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |