com.penguinwerks.jodene.managers
Class GenericManager

java.lang.Object
  extended bycom.penguinwerks.jodene.managers.GenericManager

public class GenericManager
extends java.lang.Object

This is generic manager of objects inside the vault.

Author:
Paul Hoehne

Constructor Summary
GenericManager()
          Creates a new instance of GenericManager
 
Method Summary
 void addObject(java.io.Serializable obj, DataStorageTag tag, java.lang.String name)
          Add a managed object, passing in the object, the storage tag and the object name as a string.
 void addObject(java.io.Serializable obj, java.lang.String name)
          Add an object to be managed by the manager, passing in the object and the name.
 void cleanVault(java.lang.String extension)
          Cleans out the vault for the given file extension.
 java.lang.String getExtension()
          Returns the extension the manager will use.
 java.lang.Object getObject(java.lang.String name)
          Return an object from the vault.
 DataStorageTag getStorageTag(java.lang.String name)
          Returns the data storage tag for this object.
 java.lang.String getVaultDirectory()
          Returns the vault directory.
 java.util.List listFilenames()
          Lists the names of the stored objects.
 void removeFile(java.lang.String name)
          Removes the object from the vault.
 void setExtension(java.lang.String extension)
          Sets the file extension of the type of data to be stored.
 void setVaultDirectory(java.lang.String path)
          Sets the path to the object vault.
 void updateFile(java.io.Serializable data, DataStorageTag tag, java.lang.String name)
          Update the file with the given name, with new data storage tag and new data.
 void updateFile(java.lang.String name, java.io.Serializable data)
          Update the object with the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericManager

public GenericManager()
Creates a new instance of GenericManager

Method Detail

setExtension

public void setExtension(java.lang.String extension)
Sets the file extension of the type of data to be stored. Multiple types of files can share the same vault - but must have different extensions.

Parameters:
extension - The file extension.

getExtension

public java.lang.String getExtension()
Returns the extension the manager will use.

Returns:
The file extension.

addObject

public void addObject(java.io.Serializable obj,
                      DataStorageTag tag,
                      java.lang.String name)
               throws java.io.IOException,
                      java.io.FileNotFoundException
Add a managed object, passing in the object, the storage tag and the object name as a string.

Parameters:
obj - The object.
tag - The data storage tab.
name - The name used to identify the object.
Throws:
IOException - Thrown if there is a problem saving the object.
FileNotFoundException - Thrown if there is a problem saving the object.

addObject

public void addObject(java.io.Serializable obj,
                      java.lang.String name)
               throws java.io.FileNotFoundException,
                      java.io.IOException,
                      java.lang.ClassNotFoundException
Add an object to be managed by the manager, passing in the object and the name. The data storage tag is the default data storage tag.

Parameters:
obj - The object to maange.
name - The name of the object.
Throws:
FileNotFoundException - Thrown if there is a problem saving object.
IOException - Thrown if there is a problem saving the object.
java.lang.ClassNotFoundException - Thrown if there is a problem saving the object.

cleanVault

public void cleanVault(java.lang.String extension)
Cleans out the vault for the given file extension.

Parameters:
extension - The file extension to remove.

getObject

public java.lang.Object getObject(java.lang.String name)
                           throws java.io.IOException,
                                  java.lang.ClassNotFoundException
Return an object from the vault.

Parameters:
name - The name of the object.
Returns:
The object.
Throws:
IOException - Thrown if there is a problem reading the object.
java.lang.ClassNotFoundException - Thrown if there is a problem reading the object.

getStorageTag

public DataStorageTag getStorageTag(java.lang.String name)
                             throws java.io.FileNotFoundException,
                                    java.io.IOException,
                                    java.lang.ClassNotFoundException
Returns the data storage tag for this object.

Parameters:
name - The name of the object.
Returns:
The data storage tag.
Throws:
FileNotFoundException - Thrown if there is a problem reading the file.
IOException - Thrown if there is a problem reading the file.
java.lang.ClassNotFoundException - Thrown if there is a problem reading the file.

getVaultDirectory

public java.lang.String getVaultDirectory()
Returns the vault directory.

Returns:
The directory path for the vault.

setVaultDirectory

public void setVaultDirectory(java.lang.String path)
Sets the path to the object vault.

Parameters:
path - The file path to the vault.

listFilenames

public java.util.List listFilenames()
Lists the names of the stored objects.

Returns:
The list of stored objects.

removeFile

public void removeFile(java.lang.String name)
Removes the object from the vault.

Parameters:
name - The name of the object.

updateFile

public void updateFile(java.lang.String name,
                       java.io.Serializable data)
                throws java.io.FileNotFoundException,
                       java.io.IOException,
                       java.lang.ClassNotFoundException
Update the object with the given name.

Parameters:
name - The name of the object to update.
data - The object data.
Throws:
FileNotFoundException - Thrown if there is a problem reading the file.
IOException - Thrown if there is a problem reading the file.
java.lang.ClassNotFoundException - Thrown if there is a problem reading the file.

updateFile

public void updateFile(java.io.Serializable data,
                       DataStorageTag tag,
                       java.lang.String name)
                throws java.io.IOException
Update the file with the given name, with new data storage tag and new data.

Parameters:
data - The object data.
tag - The storage tab.
name - The name of the data object.
Throws:
IOException - Thrown if there is a problem updating the file.