EAF 7.4 Implementation

com.lutris.util
Class FilePersistentStore

java.lang.Object
  extended by com.lutris.util.FilePersistentStore
All Implemented Interfaces:
com.lutris.util.PersistentStore

public class FilePersistentStore
extends java.lang.Object
implements com.lutris.util.PersistentStore

File system implementation of PersistentStore.

Author:
Kyle Clark

Constructor Summary
FilePersistentStore()
          Public constructor.
FilePersistentStore(java.lang.ClassLoader loader)
          Public constructor.
FilePersistentStore(java.lang.String storeDirectory)
          Public constructor that allows one to specify the directory (repository) where objects are stored/retrieved.
FilePersistentStore(java.lang.String storeDirectory, java.lang.ClassLoader loader)
          Public constructor that allows one to specify the directory (repository) where objects are stored/retrieved.
 
Method Summary
 void delete(java.lang.String key)
          Method to delete a a key.
 boolean exists(java.lang.String key)
          Method to query if an an object is stored.
 java.lang.String getStoreDirectory()
          Returns the location where objects are stored/retrieved.
 java.util.Enumeration keys()
          Method that returns an enumration of the keys of this persistent store.
 java.lang.Object remove(java.lang.String key)
          Method to simultaneously retrieve and remove an object from persistent store.
 java.lang.Object retrieve(java.lang.String key)
          Method to retrieve a stored object.
 void store(java.lang.String key, java.io.Serializable obj)
          Method to store and object (persistent).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilePersistentStore

public FilePersistentStore()
                    throws com.lutris.util.PersistentStoreException
Public constructor. Sets the storeDirectory, the directory (repository) where objects are stored/retreived to /tmp.

Throws:
java.io.IOException - If /tmp already exists but is not a directory. Or if /tmp does not exist and could not be created.
java.lang.SecurityException - If a security manager is running but /tmp could not be created due to inappropriate permissions.
com.lutris.util.PersistentStoreException

FilePersistentStore

public FilePersistentStore(java.lang.ClassLoader loader)
                    throws java.io.IOException,
                           java.lang.SecurityException,
                           com.lutris.util.PersistentStoreException
Public constructor. Sets the storeDirectory, the directory (repository) where objects are stored/retreived to /tmp.

Parameters:
loader - the class loader to use when reading in serialized data.
Throws:
java.io.IOException - If /tmp already exists but is not a directory. Or if /tmp does not exist and could not be created.
java.lang.SecurityException - If a security manager is running but /tmp could not be created due to inappropriate permissions.
com.lutris.util.PersistentStoreException

FilePersistentStore

public FilePersistentStore(java.lang.String storeDirectory)
                    throws com.lutris.util.PersistentStoreException
Public constructor that allows one to specify the directory (repository) where objects are stored/retrieved. If the specified directory doesn't exist then it is created.

Parameters:
storeDirectory - The repository (directory) for storing and retrieving objects.
Throws:
java.io.IOException - If storeDirectory already exists but is not a directory. Or if the storeDirectory does not exist and could not be created.
java.lang.SecurityException - If a security manager is running but storeDirectory could not be created due to inappropriate permissions.
com.lutris.util.PersistentStoreException

FilePersistentStore

public FilePersistentStore(java.lang.String storeDirectory,
                           java.lang.ClassLoader loader)
                    throws com.lutris.util.PersistentStoreException
Public constructor that allows one to specify the directory (repository) where objects are stored/retrieved. If the specified directory doesn't exist then it is created.

Parameters:
storeDirectory - The repository (directory) for storing and retrieving objects.
Throws:
java.io.IOException - If storeDirectory already exists but is not a directory. Or if the storeDirectory does not exist and could not be created.
java.lang.SecurityException - If a security manager is running but storeDirectory could not be created due to inappropriate permissions.
com.lutris.util.PersistentStoreException
Method Detail

getStoreDirectory

public java.lang.String getStoreDirectory()
Returns the location where objects are stored/retrieved.

Returns:
The directory (repository) where objects are stored/retrieved.

store

public void store(java.lang.String key,
                  java.io.Serializable obj)
           throws com.lutris.util.PersistentStoreException
Method to store and object (persistent).

Specified by:
store in interface com.lutris.util.PersistentStore
Parameters:
key - The key by which to identify the stored object. The key name has some system constraints. Its length must not exceed half the maximum file name length on the system. If it does, an exception is thrown.
obj - The serializable object to store.
Throws:
PersistentStoreException - if the object cannot cannot be stored.

retrieve

public java.lang.Object retrieve(java.lang.String key)
                          throws com.lutris.util.PersistentStoreException
Method to retrieve a stored object.

Specified by:
retrieve in interface com.lutris.util.PersistentStore
Parameters:
key - The key of the object that is to be retreived.
Returns:
The stored object. If an object is not stored under key, then null is returned.
Throws:
PersistentStoreException - if the object could not be retrieved.
See Also:
remove(java.lang.String)

exists

public boolean exists(java.lang.String key)
               throws com.lutris.util.PersistentStoreException
Method to query if an an object is stored.

Specified by:
exists in interface com.lutris.util.PersistentStore
Parameters:
key - The key by which to identify the stored object.
Returns:
True if an object is stored under key.
Throws:
PersistentStoreException - If The exsitence of object could not be determined.

remove

public java.lang.Object remove(java.lang.String key)
                        throws com.lutris.util.PersistentStoreException
Method to simultaneously retrieve and remove an object from persistent store. If an object is not stored under key, then null is returned.

Specified by:
remove in interface com.lutris.util.PersistentStore
Parameters:
key - The key by which to identify the stored object that is to be removed.
Returns:
The object that has been removed.
Throws:
PersistentStoreException - If the object could not be retrieved before being deleted.

delete

public void delete(java.lang.String key)
Method to delete a a key. Any objects stored under key are also removed. If key is not defined, then this method does nothing.

Specified by:
delete in interface com.lutris.util.PersistentStore
Parameters:
key - The key to remove.

keys

public java.util.Enumeration keys()
                           throws com.lutris.util.PersistentStoreException
Method that returns an enumration of the keys of this persistent store.

Specified by:
keys in interface com.lutris.util.PersistentStore
Throws:
com.lutris.util.PersistentStoreException - if the enumeration could not be determined.

EAF 7.4 Implementation