public class Serializer
extends java.lang.Object
Constructor and Description |
---|
Serializer() |
Modifier and Type | Method and Description |
---|---|
static <T extends ByteSerializable> |
deserialize(java.lang.Class<T> type,
byte[] bytes)
Loads a ByteSerializable object's binary form and then instantiates a new
object using the SerializationInputStream constructor.
|
static <T extends ByteSerializable> |
deserializeFromStream(java.lang.Class<T> type,
SerializationInputStream in)
Deserializes and instantiates a ByteSerializable class from a stream.
|
static void |
persist(ByteSerializable obj,
java.io.File file)
Dumps a ByteSerializable object to a portable byte array and stores it on
disk.
|
static void |
persist(ByteSerializable obj,
java.lang.String fileName)
Dumps a ByteSerializable object to a portable byte array and stores it on
disk.
|
static <T extends ByteSerializable> |
restore(java.lang.Class<T> type,
java.io.File inFile)
Loads a ByteSerializable object's binary form from disk and
then instantiates a new object using the SerializationInputStream
constructor.
|
static <T extends ByteSerializable> |
restore(java.lang.Class<T> type,
java.lang.String fileName)
Loads a ByteSerializable object's binary form from disk and
then instantiates a new object using the SerializationInputStream
constructor.
|
static byte[] |
serialize(ByteSerializable obj)
Dumps a ByteSerializable object to a portable byte array.
|
public static byte[] serialize(ByteSerializable obj) throws java.io.IOException
obj
- The ByteSerializable object to serialize.java.io.IOException
public static <T extends ByteSerializable> T deserialize(java.lang.Class<T> type, byte[] bytes) throws java.io.IOException, SerializationException
type
- The type of object to create (deserialize).
For example, Something.class.bytes
- Binary form of the object being loaded.java.io.IOException
SerializationException
public static <T extends ByteSerializable> T deserializeFromStream(java.lang.Class<T> type, SerializationInputStream in) throws java.io.IOException, SerializationException
type
- The type of object to create (deserialize).
For example, Something.class.in
- SerializationInputStream containing a serialized instance of
the object being loaded.java.io.IOException
SerializationException
public static void persist(ByteSerializable obj, java.io.File file) throws java.io.IOException
obj
- The ByteSerializable object to serialize.file
- File to write the ByteSerializable object to.java.io.IOException
public static void persist(ByteSerializable obj, java.lang.String fileName) throws java.io.IOException
obj
- The ByteSerializable object to serialize.fileName
- path the object should be written to.java.io.IOException
public static <T extends ByteSerializable> T restore(java.lang.Class<T> type, java.io.File inFile) throws java.io.IOException, SerializationException
type
- The type of object to create (deserialize).
For example, Something.class.inFile
- File containing a serialized instance of the object being
loaded.java.io.IOException
SerializationException
public static <T extends ByteSerializable> T restore(java.lang.Class<T> type, java.lang.String fileName) throws java.io.IOException, SerializationException
type
- The type of object to create (deserialize).
For example, Something.class.fileName
- path the object should be read from.java.io.IOException
SerializationException