sdsu.io
Interface Repository

All Known Implementing Classes:
ASCIIFileRepository, LocalRepository

public abstract interface 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. The comment is stored with the object. In future releases the storage meduim could be local files, files on remote machines, or a database. In this release only local files are supported.

A nested repository can contain other (subrepository) repositories. Different implementations may organize nested repositories in different ways.

A top level repository can access keys of a subrepository. For example let Roger and Sam be repositories, let Roger contain the keys left and right and the repository Sam, let Sam contain the keys right and wrong. Also let the variable roger be a reference to the repository Roger. Then:

 	roger.get( "right" ); returns object in Roger stored at "right"
 	roger.get( "Sam.right"); returns object in Sam stored at "right"
 
The char '.' is used as the default name separator.

Version:
0.8 5 June 1998
Author:
Roger Whitney (whitney@cs.sdsu.edu)
See Also:
LocalRepository

Method Summary
 boolean containsKey(java.lang.String key)
          Returns true if the repostitory contains data at the given key
 boolean containsSubrepository(java.lang.String name)
          Returns true if the repostitory contains the given subrepository
 boolean create()
          Create the required storage structures for the repository.
 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 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 values
 java.util.Enumeration keys()
          Returns an enumeration of the keys in the repository
 int length()
          Returns the number of keys in the repository.
 void put(java.lang.String key, java.lang.Object value)
          Add the object "value" to the repository 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 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.
 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 in the repository.
 

Method Detail

exists

public boolean exists()
Returns true if the repository exists

create

public boolean create()
Create the required storage structures for the repository. Returns true if create was successful, false otherwise.

put

public void put(java.lang.String key,
                java.lang.Object value)
         throws java.io.IOException
Add the object "value" to the repository with the given key.

put

public void put(java.lang.String key,
                java.lang.Object value,
                java.lang.String comment)
         throws java.io.IOException
Add the object "value" to the repository with the given key. The object is stored with the given comment.

putSerializable

public void putSerializable(java.lang.String key,
                            java.io.Serializable value)
                     throws java.io.IOException
Add the object "value" to the repository with the given key. Value is stored using Java's serialization process.

putSerializable

public void putSerializable(java.lang.String key,
                            java.io.Serializable value,
                            java.lang.String comment)
                     throws java.io.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 java.lang.Object get(java.lang.String key)
                     throws java.io.IOException
Retreive the item in the repository stored under the given key. Returns null if no object is mapped to the key.

containsKey

public boolean containsKey(java.lang.String key)
Returns true if the repostitory contains data at the given key

keys

public java.util.Enumeration keys()
Returns an enumeration of the keys in the repository

isEmpty

public boolean isEmpty()
Returns true if the repository contains no keys or values

size

public int size()
Returns the number of keys in the repository. Same as length

length

public int length()
Returns the number of keys in the repository. Same as size.

remove

public boolean remove(java.lang.String key)
Removes the given key and corresponding value from the repository.

createSubrepository

public boolean createSubrepository(java.lang.String name)
Create a subrepository. Returns true if create was successful, false otherwise.

getSubrepository

public Repository getSubrepository(java.lang.String name)
Return a subrepository. Returns null if repository does not exist.

getSubrepositories

public java.util.Enumeration getSubrepositories()
Return an enumeration of the subrepositories. The enumeration does not directly contain sub-subrepositories.

containsSubrepository

public boolean containsSubrepository(java.lang.String name)
Returns true if the repostitory contains the given 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 '.'