|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.core.SerializationHelper
public class SerializationHelper
A helper class for determining serialVersionUIDs and checking whether classes contain one and/or need one. One can also serialize and deserialize objects to and fro files or streams.
Field Summary | |
---|---|
static java.lang.String |
SERIAL_VERSION_UID
the field name of serialVersionUID. |
Constructor Summary | |
---|---|
SerializationHelper()
|
Method Summary | |
---|---|
java.lang.String |
getRevision()
Returns the revision string. |
static long |
getUID(java.lang.Class c)
reads or creates the serialVersionUID for the given class. |
static long |
getUID(java.lang.String classname)
reads or creates the serialVersionUID for the given class. |
static boolean |
hasUID(java.lang.Class c)
checks whether the given class contains a serialVersionUID. |
static boolean |
hasUID(java.lang.String classname)
checks whether the given class contains a serialVersionUID. |
static boolean |
isSerializable(java.lang.Class c)
checks whether a class is serializable. |
static boolean |
isSerializable(java.lang.String classname)
checks whether a class is serializable. |
static void |
main(java.lang.String[] args)
Outputs information about a class on the commandline, takes class name as arguments. |
static boolean |
needsUID(java.lang.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(java.lang.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 java.lang.Object |
read(java.io.InputStream stream)
deserializes from the given stream and returns the object from it. |
static java.lang.Object |
read(java.lang.String filename)
deserializes the given file and returns the object from it. |
static java.lang.Object[] |
readAll(java.io.InputStream stream)
deserializes from the given stream and returns the object from it. |
static java.lang.Object[] |
readAll(java.lang.String filename)
deserializes the given file and returns the objects from it. |
static void |
write(java.io.OutputStream stream,
java.lang.Object o)
serializes the given object to the specified stream. |
static void |
write(java.lang.String filename,
java.lang.Object o)
serializes the given object to the specified file. |
static void |
writeAll(java.io.OutputStream stream,
java.lang.Object[] o)
serializes the given objects to the specified stream. |
static void |
writeAll(java.lang.String filename,
java.lang.Object[] o)
serializes the given objects to the specified file. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String SERIAL_VERSION_UID
Constructor Detail |
---|
public SerializationHelper()
Method Detail |
---|
public static boolean isSerializable(java.lang.String classname)
classname
- the class to check
public static boolean isSerializable(java.lang.Class c)
c
- the class to check
public static boolean hasUID(java.lang.String classname)
classname
- the class to check
public static boolean hasUID(java.lang.Class c)
c
- the class to check
public static boolean needsUID(java.lang.String classname)
classname
- the class to check
public static boolean needsUID(java.lang.Class c)
c
- the class to check
public static long getUID(java.lang.String classname)
classname
- the class to get the serialVersionUID for
public static long getUID(java.lang.Class c)
c
- the class to get the serialVersionUID for
public static void write(java.lang.String filename, java.lang.Object o) throws java.lang.Exception
filename
- the file to write the object too
- the object to serialize
java.lang.Exception
- if serialization failspublic static void write(java.io.OutputStream stream, java.lang.Object o) throws java.lang.Exception
stream
- the stream to write the object too
- the object to serialize
java.lang.Exception
- if serialization failspublic static void writeAll(java.lang.String filename, java.lang.Object[] o) throws java.lang.Exception
filename
- the file to write the object too
- the objects to serialize
java.lang.Exception
- if serialization failspublic static void writeAll(java.io.OutputStream stream, java.lang.Object[] o) throws java.lang.Exception
stream
- the stream to write the object too
- the objects to serialize
java.lang.Exception
- if serialization failspublic static java.lang.Object read(java.lang.String filename) throws java.lang.Exception
filename
- the file to deserialize from
java.lang.Exception
- if deserialization failspublic static java.lang.Object read(java.io.InputStream stream) throws java.lang.Exception
stream
- the stream to deserialize from
java.lang.Exception
- if deserialization failspublic static java.lang.Object[] readAll(java.lang.String filename) throws java.lang.Exception
filename
- the file to deserialize from
java.lang.Exception
- if deserialization failspublic static java.lang.Object[] readAll(java.io.InputStream stream) throws java.lang.Exception
stream
- the stream to deserialize from
java.lang.Exception
- if deserialization failspublic java.lang.String getRevision()
getRevision
in interface RevisionHandler
public static void main(java.lang.String[] args) throws java.lang.Exception
args
- the classnames to check
java.lang.Exception
- if something goes wrong
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |