public class SerializationHelper extends Object implements RevisionHandler
Modifier and Type | Field and Description |
---|---|
static String |
SERIAL_VERSION_UID
the field name of serialVersionUID.
|
Constructor and Description |
---|
SerializationHelper() |
Modifier and Type | Method and Description |
---|---|
String |
getRevision()
Returns the revision string.
|
static long |
getUID(Class c)
reads or creates the serialVersionUID for the given class.
|
static long |
getUID(String classname)
reads or creates the serialVersionUID for the given class.
|
static boolean |
hasUID(Class c)
checks whether the given class contains a serialVersionUID.
|
static boolean |
hasUID(String classname)
checks whether the given class contains a serialVersionUID.
|
static boolean |
isSerializable(Class c)
checks whether a class is serializable.
|
static boolean |
isSerializable(String classname)
checks whether a class is serializable.
|
static void |
main(String[] args)
Outputs information about a class on the commandline, takes class
name as arguments.
|
static boolean |
needsUID(Class c)
checks whether a class needs to declare a serialVersionUID, i.e., it
implements the java.io.Serializable interface but doesn't declare a
serialVersionUID.
|
static boolean |
needsUID(String classname)
checks whether a class needs to declare a serialVersionUID, i.e., it
implements the java.io.Serializable interface but doesn't declare a
serialVersionUID.
|
static Object |
read(InputStream stream)
deserializes from the given stream and returns the object from it.
|
static Object |
read(String filename)
deserializes the given file and returns the object from it.
|
static Object[] |
readAll(InputStream stream)
deserializes from the given stream and returns the object from it.
|
static Object[] |
readAll(String filename)
deserializes the given file and returns the objects from it.
|
static void |
write(OutputStream stream,
Object o)
serializes the given object to the specified stream.
|
static void |
write(String filename,
Object o)
serializes the given object to the specified file.
|
static void |
writeAll(OutputStream stream,
Object[] o)
serializes the given objects to the specified stream.
|
static void |
writeAll(String filename,
Object[] o)
serializes the given objects to the specified file.
|
public static final String SERIAL_VERSION_UID
public static boolean isSerializable(String classname)
classname
- the class to checkpublic static boolean isSerializable(Class c)
c
- the class to checkpublic static boolean hasUID(String classname)
classname
- the class to checkpublic static boolean hasUID(Class c)
c
- the class to checkpublic static boolean needsUID(String classname)
classname
- the class to checkpublic static boolean needsUID(Class c)
c
- the class to checkpublic static long getUID(String classname)
classname
- the class to get the serialVersionUID forpublic static long getUID(Class c)
c
- the class to get the serialVersionUID forpublic static void write(String filename, Object o) throws Exception
filename
- the file to write the object too
- the object to serializeException
- if serialization failspublic static void write(OutputStream stream, Object o) throws Exception
stream
- the stream to write the object too
- the object to serializeException
- if serialization failspublic static void writeAll(String filename, Object[] o) throws Exception
filename
- the file to write the object too
- the objects to serializeException
- if serialization failspublic static void writeAll(OutputStream stream, Object[] o) throws Exception
stream
- the stream to write the object too
- the objects to serializeException
- if serialization failspublic static Object read(String filename) throws Exception
filename
- the file to deserialize fromException
- if deserialization failspublic static Object read(InputStream stream) throws Exception
stream
- the stream to deserialize fromException
- if deserialization failspublic static Object[] readAll(String filename) throws Exception
filename
- the file to deserialize fromException
- if deserialization failspublic static Object[] readAll(InputStream stream) throws Exception
stream
- the stream to deserialize fromException
- if deserialization failspublic String getRevision()
getRevision
in interface RevisionHandler
Copyright © 2016 University of Waikato, Hamilton, NZ. All Rights Reserved.