dlife.sys
Class SerializationBase
java.lang.Object
dlife.sys.SerializationBase
- All Implemented Interfaces:
- Serializable
- Direct Known Subclasses:
- BluetoothNameMap, Individual, NeuralNetwork, PlayerSimulation, PlayerSimulation.PlayerSimulationPuck, PlayerSimulation.PlayerSimulationRobot, Population, ServerPortMap, TDLearner, VisionServerDeviceList, VisionServerMap, VisionServerMap.VideoSourceInfo
public class SerializationBase
- extends Object
- implements Serializable
This base class supports serialization throughout the dLife package.
It provides methods for writing and reading objects using the Java
Serialization mechanism. Within dLife, any object belonging to a class that extends
this class can be saved and restored by invoking the write/read methods.
Any class that extends this class must ensure that all of its fields
are primitive values, implement the Serializable interface or are declared transient.
Fields that are primitives or are Serializable will be saved and restored when
write/read are called. Fields that are transient will not be saved or restored
but will contain default values.
- Version:
- Jun 19, 2007
- Author:
- Grant Braught, Dickinson College
- See Also:
- Serialized Form
|
Method Summary |
static Object |
read(String filename)
Read and return the object contained in the specified filename using Java's
object serialization mechanism. |
void |
write(String filename)
Write this object to the indicated file using Java's object
serialization mechanism. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SerializationBase
public SerializationBase()
write
public void write(String filename)
throws SerializationError
- Write this object to the indicated file using Java's object
serialization mechanism.
- Parameters:
filename - the full path of the file to which to write this object.
- Throws:
SerializationError - if there is a problem writing the object.
read
public static Object read(String filename)
throws SerializationError
- Read and return the object contained in the specified filename using Java's
object serialization mechanism. It is the caller's responsibility to cast
the returned object to the correct type.
- Parameters:
filename - the full path of the file from which to read the object.
- Returns:
- the object read from the specified file.
- Throws:
SerializationError - if there is a problem reading the object.