All Packages Class Hierarchy This Package Previous Next Index
Class sdsu.io.LocalRepository
java.lang.Object
|
+----sdsu.io.LocalRepository
- public class LocalRepository
- extends Object
- implements Repository
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.
- Version:
- 0.9 8 June 1998
- Author:
- Roger Whitney
(whitney@cs.sdsu.edu)
- See Also:
- Repository
-
LocalRepository(File)
- Open a ASCIIFileRepository.
-
LocalRepository(String)
- Open a ASCIIFileRepository.
-
containsKey(String)
- Returns true is the repostitory or a subrepository
contains data at the given key
-
containsSubrepository(String)
- Returns true if the repostitory contains the given subrepository
-
create()
-
-
createSubrepository(String)
- Create a subrepository.
-
exists()
- Returns true if the repository exists.
-
get(String)
- Retreive the item in the repository or a subrepository
stored under the given key.
-
getSubrepositories()
- Return an enumeration of the subrepositories.
-
getSubrepository(String)
- Return a subrepository.
-
isEmpty()
- Returns true if the repository contains no keys or subrepositories
-
keys()
- Returns an enumeration of the keys in the top level repository
-
length()
- Returns the number of keys and subrepositories in the repository.
-
put(String, Object)
- Add the object "value" to the repository or a subrepository with
the given key.
-
put(String, Object, String)
- Add the object "value" to the repository or a subrepository with
the given key.
-
putSerializable(String, Serializable)
- Add the object "value" to the repository with the
given key.
-
putSerializable(String, Serializable, String)
- Add the object "value" to the repository with the
given key.
-
remove(String)
- Removes the given key and corresponding value from the repository
or subrepository.
-
setNameSeparator(char)
- The name separator is the char used to separate the name of a
Repository and a subrepository or key.
-
size()
- Returns the number of keys and subrepositories in the repository.
LocalRepository
public LocalRepository(String directoryName)
- Open a ASCIIFileRepository.
- Parameters:
- 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.
LocalRepository
public LocalRepository(File repositoryLocation)
- Open a ASCIIFileRepository.
- Parameters:
- 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.
exists
public boolean exists()
- Returns true if the repository exists. If repository does
not exist, use create to create it.
create
public boolean create()
createSubrepository
public boolean createSubrepository(String name)
- Create a subrepository.
Returns true if create was successful, false otherwise.
put
public void put(String key,
Object value) throws IOException
- Add the object "value" to the repository or a subrepository with
the given key.
- Parameters:
- 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.
- Throws: IOException
- on any IO error in saving the object
put
public void put(String key,
Object value,
String comment) throws IOException
- Add the object "value" to the repository or a subrepository with
the given key.
- Parameters:
- 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"
- Throws: IOException
- on any IO error in saving the object
putSerializable
public void putSerializable(String key,
Serializable value) throws IOException
- Add the object "value" to the repository with the
given key. Value is stored using Java's serialization process.
putSerializable
public void putSerializable(String key,
Serializable value,
String comment) throws IOException
- Add the object "value" to the repository with the
given key. The object is stored with the given comment.
Value is stored using Java's serialization process.
get
public Object get(String key) throws IOException
- Retreive the item in the repository or a subrepository
stored under the given key.
- Parameters:
- key - can contain reference to subrepositories. For example
"Roger.Sam.key"
getSubrepository
public Repository getSubrepository(String name)
- Return a subrepository. Returns null if repository does
not exist.
- Parameters:
- name - can contain reference to subrepositories. For example
"Roger.Sam.Pete"
getSubrepositories
public Enumeration getSubrepositories()
- Return an enumeration of the subrepositories. The enumeration
does not directly contain sub-subrepositories.
containsKey
public boolean containsKey(String key)
- Returns true is the repostitory or a subrepository
contains data at the given key
- Parameters:
- key - can contain reference to subrepositories. For example
"Roger.Sam.key"
containsSubrepository
public boolean containsSubrepository(String name)
- Returns true if the repostitory contains the given subrepository
- Parameters:
- name - can contain reference to subrepositories. For example
"Roger.Sam"
keys
public Enumeration keys()
- Returns an enumeration of the keys in the top level repository
isEmpty
public boolean isEmpty()
- Returns true if the repository contains no keys or subrepositories
size
public int size()
- Returns the number of keys and subrepositories in the repository.
Same as length.
length
public int length()
- Returns the number of keys and subrepositories in the repository.
Same as size.
remove
public boolean remove(String key)
- Removes the given key and corresponding value from the repository
or subrepository.
setNameSeparator
public void setNameSeparator(char newSeparator)
- The name separator is the char used to separate the name of a
Repository and a subrepository or key. The default char used is a
'.'
All Packages Class Hierarchy This Package Previous Next Index