public class SerializedObjectManager
extends java.lang.Object
SerializedObjectManager
class can be used to save,
load, delete, and get a list of serialized objects. The objects
are stored as GZIP compressed files in a user-specified directory.Constructor and Description |
---|
SerializedObjectManager(java.io.File objectDir)
Creates a new manager to handle serialized objects in the
specified directory.
|
Modifier and Type | Method and Description |
---|---|
void |
deleteObject(java.lang.String objectName)
Deletes the specified object.
|
java.util.List |
getObjectNames()
Gets the list of object names available.
|
java.lang.Object |
loadObject(java.lang.String objectName)
Loads the specified serialized object.
|
void |
saveObject(java.lang.Object object,
java.lang.String objectName)
Serializes and saves the specified object.
|
public SerializedObjectManager(java.io.File objectDir)
objectDir
- the directory used to perform all serialized
object operations.public java.util.List getObjectNames()
public java.lang.Object loadObject(java.lang.String objectName) throws java.io.IOException, java.lang.ClassNotFoundException
objectName
- the object name, which must be a valid name
obtained from the getObjectNames()
method.java.io.IOException
- if an error occurred reading the object file.java.lang.ClassNotFoundException
- if the object class read is unknown.public void saveObject(java.lang.Object object, java.lang.String objectName) throws java.io.IOException
object
- the object to save.objectName
- the object name. This is the name that may be
used later to retrieve the object.java.io.IOException
- if an error occurred writing the object file.public void deleteObject(java.lang.String objectName) throws java.io.IOException
getObjectNames()
will not include thie specified
name in the list.java.io.IOException
- if an error occurred deleting the object file.