|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjimm.twice.util.Persistence
This class is used to implement persistence. It uses the file system,
creating a file for every key. The contents of the file are lines of
text data. Within each line, values are separated by the
SEPARATOR
string. A few important simplifying
assumptions:
This persistence mechanism is outside of the hierarchy of ICE classes because this particular persistence mechanism is very simplistic and should be replaced with something more robust (like a database) in real implementations.
Field Summary | |
protected java.lang.String |
dirPath
|
protected static java.lang.String |
SEPARATOR
|
Constructor Summary | |
Persistence(java.lang.String storageDirPath)
|
Method Summary | |
java.io.BufferedReader |
getBufferedReader(java.lang.String key)
Returns a collection containing lists of strings. |
java.io.FileInputStream |
getFileInputStream(java.lang.String key)
|
java.io.FileOutputStream |
getFileOutputStream(java.lang.String key)
|
java.io.PrintWriter |
getPrintWriter(java.lang.String key)
Stores the lists contained within the values collection as lines within a file. |
boolean |
hasKey(java.lang.String key)
Returns true if a permanent storage file already exists
for the specified key. |
java.util.Set |
keySet()
Returns a set containing all of the keys. |
protected java.lang.String |
makeSafe(java.lang.String key)
Key values are mutated when used as file names. |
void |
remove(java.lang.String key)
Removes the permanent storage associated with the specified key. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final java.lang.String SEPARATOR
protected java.lang.String dirPath
Constructor Detail |
public Persistence(java.lang.String storageDirPath)
Method Detail |
public boolean hasKey(java.lang.String key)
true
if a permanent storage file already exists
for the specified key.
public void remove(java.lang.String key)
public java.util.Set keySet()
public java.io.BufferedReader getBufferedReader(java.lang.String key)
null
if there is no file corresponding to the specified key.
public java.io.FileInputStream getFileInputStream(java.lang.String key)
public java.io.PrintWriter getPrintWriter(java.lang.String key)
public java.io.FileOutputStream getFileOutputStream(java.lang.String key)
protected java.lang.String makeSafe(java.lang.String key)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |