|
||||||||||
| 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 String |
SERIAL_VERSION_UID
the field name of serialVersionUID. |
| Constructor Summary | |
|---|---|
SerializationHelper()
|
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String SERIAL_VERSION_UID
| Constructor Detail |
|---|
public SerializationHelper()
| Method Detail |
|---|
public static boolean isSerializable(String classname)
classname - the class to check
public static boolean isSerializable(Class c)
c - the class to check
public static boolean hasUID(String classname)
classname - the class to check
public static boolean hasUID(Class c)
c - the class to check
public static boolean needsUID(String classname)
classname - the class to check
public static boolean needsUID(Class c)
c - the class to check
public static long getUID(String classname)
classname - the class to get the serialVersionUID for
public static long getUID(Class c)
c - the class to get the serialVersionUID for
public static void write(String filename,
Object o)
throws Exception
filename - the file to write the object too - the object to serialize
Exception - if serialization fails
public static void write(OutputStream stream,
Object o)
throws Exception
stream - the stream to write the object too - the object to serialize
Exception - if serialization fails
public static void writeAll(String filename,
Object[] o)
throws Exception
filename - the file to write the object too - the objects to serialize
Exception - if serialization fails
public static void writeAll(OutputStream stream,
Object[] o)
throws Exception
stream - the stream to write the object too - the objects to serialize
Exception - if serialization fails
public static Object read(String filename)
throws Exception
filename - the file to deserialize from
Exception - if deserialization fails
public static Object read(InputStream stream)
throws Exception
stream - the stream to deserialize from
Exception - if deserialization fails
public static Object[] readAll(String filename)
throws Exception
filename - the file to deserialize from
Exception - if deserialization fails
public static Object[] readAll(InputStream stream)
throws Exception
stream - the stream to deserialize from
Exception - if deserialization failspublic String getRevision()
getRevision in interface RevisionHandler
public static void main(String[] args)
throws Exception
args - the classnames to check
Exception - if something goes wrong
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||