Class SerializedObjectManager

java.lang.Object
noaa.coastwatch.io.SerializedObjectManager

public class SerializedObjectManager extends Object
The 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.
Since:
3.1.7
Author:
Peter Hollemans
  • Constructor Details

    • SerializedObjectManager

      public SerializedObjectManager(File objectDir)
      Creates a new manager to handle serialized objects in the specified directory.
      Parameters:
      objectDir - the directory used to perform all serialized object operations.
  • Method Details

    • getObjectNames

      public List getObjectNames()
      Gets the list of object names available.
    • loadObject

      public Object loadObject(String objectName) throws IOException, ClassNotFoundException
      Loads the specified serialized object.
      Parameters:
      objectName - the object name, which must be a valid name obtained from the getObjectNames() method.
      Returns:
      the deserialized object read.
      Throws:
      IOException - if an error occurred reading the object file.
      ClassNotFoundException - if the object class read is unknown.
    • saveObject

      public void saveObject(Object object, String objectName) throws IOException
      Serializes and saves the specified object.
      Parameters:
      object - the object to save.
      objectName - the object name. This is the name that may be used later to retrieve the object.
      Throws:
      IOException - if an error occurred writing the object file.
    • deleteObject

      public void deleteObject(String objectName) throws IOException
      Deletes the specified object. A subsequent call to getObjectNames() will not include thie specified name in the list.
      Throws:
      IOException - if an error occurred deleting the object file.