|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.excalibur.store.impl.AbstractReadWriteStore
org.apache.excalibur.store.impl.AbstractFilesystemStore
public abstract class AbstractFilesystemStore
Stores objects on the filesystem: String objects as text files, all other objects are serialized. This class must be subclassed in order to set the directory the store should work on.
Field Summary | |
---|---|
protected File |
m_directoryFile
The directory repository |
protected String |
m_directoryPath
|
Fields inherited from class org.apache.excalibur.store.impl.AbstractReadWriteStore |
---|
lock |
Fields inherited from interface org.apache.excalibur.store.Store |
---|
PERSISTENT_STORE, ROLE, TRANSIENT_STORE |
Constructor Summary | |
---|---|
AbstractFilesystemStore()
|
Method Summary | |
---|---|
protected void |
addKeys(org.apache.excalibur.store.impl.AbstractFilesystemStore.FSEnumeration enumer,
File directory)
|
protected int |
countKeys(File directory)
|
protected String |
decode(String filename)
Inverse of encode exept it do not use path. |
Object |
deserializeObject(File file)
This method deserializes an object from an input stream. |
String |
deserializeString(File file)
Load a text file contents as a String |
protected void |
doClear()
Clear the Store of all elements |
protected boolean |
doContainsKey(Object key)
Indicates if the given key is associated to a contained object. |
protected void |
doFree()
Try to free some used memory. |
protected Object |
doGet(Object key)
Get the File object associated with the given unique key name. |
protected Enumeration |
doGetKeys()
Returns the list of stored files as an Enumeration of Files |
protected int |
doGetSize()
Returns count of the objects in the store, or -1 if could not be obtained. |
protected void |
doRemove(Object key)
Remove the object associated to the given key. |
protected void |
doStore(Object key,
Object value)
Store the given object in a persistent state. |
protected String |
encode(String s)
Returns a String that uniquely identifies the object. |
protected File |
fileFromKey(Object key)
|
void |
free()
Frees some values of the data file. |
String |
getDirectoryPath()
Returns the repository's full pathname |
String |
getFullFilename(File file)
Get the complete filename corresponding to a (typically relative) File . |
Object |
getObject(Object key)
|
String |
getString(Object key)
|
void |
serializeObject(File file,
Object object)
This method serializes an object to an output stream. |
void |
serializeString(File file,
String string)
Dump a String to a text file. |
void |
setDirectory(File directory)
Sets the repository's location |
void |
setDirectory(String directory)
Sets the repository's location |
Methods inherited from class org.apache.excalibur.store.impl.AbstractReadWriteStore |
---|
clear, containsKey, get, getChildInstrumentables, getInstrumentableName, getInstruments, keys, remove, setInstrumentableName, size, store |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected File m_directoryFile
protected volatile String m_directoryPath
Constructor Detail |
---|
public AbstractFilesystemStore()
Method Detail |
---|
public void setDirectory(String directory) throws IOException
IOException
public void setDirectory(File directory) throws IOException
IOException
public String getDirectoryPath()
protected Object doGet(Object key)
doGet
in class AbstractReadWriteStore
protected void doStore(Object key, Object value) throws IOException
doStore
in class AbstractReadWriteStore
IOException
protected void doRemove(Object key)
doRemove
in class AbstractReadWriteStore
protected void doClear()
doClear
in class AbstractReadWriteStore
protected boolean doContainsKey(Object key)
doContainsKey
in class AbstractReadWriteStore
protected Enumeration doGetKeys()
doGetKeys
in class AbstractReadWriteStore
protected int doGetSize()
doGetSize
in class AbstractReadWriteStore
protected void addKeys(org.apache.excalibur.store.impl.AbstractFilesystemStore.FSEnumeration enumer, File directory)
protected int countKeys(File directory)
protected File fileFromKey(Object key)
public String getString(Object key) throws IOException
IOException
public void free()
AbstractReadWriteStore
free
in interface Store
free
in class AbstractReadWriteStore
protected void doFree()
AbstractReadWriteStore
doFree
in class AbstractReadWriteStore
public Object getObject(Object key) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
protected String decode(String filename)
protected String encode(String s)
public void serializeString(File file, String string) throws IOException
String
to a text file.
file
- The output filestring
- The string to be dumped
IOException
- IO Errorpublic String deserializeString(File file) throws IOException
String.
This method does not perform enconding conversions
- Parameters:
file
- The input file
- Returns:
- The file contents as a
String
- Throws:
IOException
- IO Error
public void serializeObject(File file, Object object) throws IOException
file
- The output fileobject
- The object to be serialized
IOException
- IOErrorpublic Object deserializeObject(File file) throws IOException, ClassNotFoundException
file
- The input file
IOException
- IOError
ClassNotFoundException
public String getFullFilename(File file)
File
.
This method accounts for the possibility of an error in getting
the filename's canonical path, returning the io/error-safe
absolute form instead
file
- The file
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |