|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sdsu.io.LocalRepository
A Repository is a hashtable like interface to a persistent storage medium. Items are placed into the repository via the put method, retrieved via the get method. The items in the repository are preserved between invocations of the programs that access the repository. Each item in the repository has a key (or label) which identifies the item, and an optional comment. LocalRepository stores each item in a separate file. The name of the file is in the format "key.class", where key = key for the item, class is the short name of the class of the item. This version of LocalRepository supports instances of: String, java.util.Properties, sdsu.util.Stringizable (which includes sdsu.util.List, sdsu.util.LabeledData, sdsu.util.Table, sdsu.util.LabeledTable) and any class that implements java.io.Serializable. If a class supports Serializable and another supported type (string for example) the non-serializable format is selected over serializable. If you wish to force such an object to be saved via serialization, use putSerializable. See sdsu.io.ASCIIFileRepository for file formats of these items. ASCIIFileRepository is designed to support files created by hand for configuration files. These files can contain persistant comments.
Repository
Constructor Summary | |
LocalRepository(java.io.File repositoryLocation)
Open a ASCIIFileRepository. |
|
LocalRepository(java.lang.String directoryName)
Open a ASCIIFileRepository. |
Method Summary | |
boolean |
containsKey(java.lang.String key)
Returns true is the repostitory or a subrepository contains data at the given key |
boolean |
containsSubrepository(java.lang.String name)
Returns true if the repostitory contains the given subrepository |
boolean |
create()
|
boolean |
createSubrepository(java.lang.String name)
Create a subrepository. |
boolean |
exists()
Returns true if the repository exists. |
java.lang.Object |
get(java.lang.String key)
Retreive the item in the repository or a subrepository stored under the given key. |
java.util.Enumeration |
getSubrepositories()
Return an enumeration of the subrepositories. |
Repository |
getSubrepository(java.lang.String name)
Return a subrepository. |
boolean |
isEmpty()
Returns true if the repository contains no keys or subrepositories |
java.util.Enumeration |
keys()
Returns an enumeration of the keys in the top level repository |
int |
length()
Returns the number of keys and subrepositories in the repository. |
void |
put(java.lang.String key,
java.lang.Object value)
Add the object "value" to the repository or a subrepository with the given key. |
void |
put(java.lang.String key,
java.lang.Object value,
java.lang.String comment)
Add the object "value" to the repository or a subrepository with the given key. |
void |
putSerializable(java.lang.String key,
java.io.Serializable value)
Add the object "value" to the repository with the given key. |
void |
putSerializable(java.lang.String key,
java.io.Serializable value,
java.lang.String comment)
Add the object "value" to the repository with the given key. |
boolean |
remove(java.lang.String key)
Removes the given key and corresponding value from the repository or subrepository. |
void |
setNameSeparator(char newSeparator)
The name separator is the char used to separate the name of a Repository and a subrepository or key. |
int |
size()
Returns the number of keys and subrepositories in the repository. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public LocalRepository(java.lang.String directoryName)
directoryName
- The directory containing the repository files.
If the directory does not exist, it is not created. In this case
You must call create() to create the underlying storage before using
the Repository.public LocalRepository(java.io.File repositoryLocation)
directoryName
- The directory containing the repository files.
If the directory does not exist, it is not created. In this case
You must call create() to create the underlying storage before using
the Repository.Method Detail |
public boolean exists()
public boolean create()
public boolean createSubrepository(java.lang.String name)
public void put(java.lang.String key, java.lang.Object value) throws java.io.IOException
value
- Currently limited to String, java.util.Properties,
sdsu.util.Stringizable (which includes
sdsu.util.List, sdsu.util.LabeledData, sdsu.util.Table,
sdsu.util.LabeledTable) Will handle all other types, but not
very intelligently.public void put(java.lang.String key, java.lang.Object value, java.lang.String comment) throws java.io.IOException
value
- Currently limited to String, java.util.Properties,
sdsu.util.Stringizable (which includes
sdsu.util.List, sdsu.util.LabeledData, sdsu.util.Table,
sdsu.util.LabeledTable) Will handle all other types, but not
very intelligently.key
- can contain reference to subrepositories. For example
"Roger.Sam.key"public void putSerializable(java.lang.String key, java.io.Serializable value) throws java.io.IOException
public void putSerializable(java.lang.String key, java.io.Serializable value, java.lang.String comment) throws java.io.IOException
public java.lang.Object get(java.lang.String key) throws java.io.IOException
key
- can contain reference to subrepositories. For example
"Roger.Sam.key"public Repository getSubrepository(java.lang.String name)
name
- can contain reference to subrepositories. For example
"Roger.Sam.Pete"public java.util.Enumeration getSubrepositories()
public boolean containsKey(java.lang.String key)
key
- can contain reference to subrepositories. For example
"Roger.Sam.key"public boolean containsSubrepository(java.lang.String name)
name
- can contain reference to subrepositories. For example
"Roger.Sam"public java.util.Enumeration keys()
public boolean isEmpty()
public int size()
public int length()
public boolean remove(java.lang.String key)
public void setNameSeparator(char newSeparator)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |