All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sdsu.io.ASCIIFileRepository

java.lang.Object
   |
   +----sdsu.io.ASCIIFileRepository

public class ASCIIFileRepository
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. The ASCIIFileRepository stores each item in a separate ASCII 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. Items in an ASCIIFileRepository can be 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. When created by the ASCIIFileRepository a file contains comments and metadata. Comments are lines starting with '#' and end at the end of the line. Metadata are on lines starting with "#!". Metadata includes the key and class of the item in the file. The file starts with comment lines, then metadata lines, then comment lines, then a string version of the item. If the file is created by hand the comments and metadata are not required.

Version:
0.9 June 1998
Author:
Roger Whitney (whitney@cs.sdsu.edu)

Constructor Index

 o ASCIIFileRepository(File)
Open a ASCIIFileRepository.
 o ASCIIFileRepository(String)
Open a ASCIIFileRepository.

Method Index

 o containsKey(String)
Returns true is the repostitory contains data at the given key
 o containsSubrepository(String)
Returns false as does not support subrepositories
 o create()
Create the required storage structures for the repository.
 o createSubrepository(String)
Returns false as does not support subrepositories.
 o exists()
Returns true if the repository exists
 o get(String)
Retreive the item in the repository stored under the given key.
 o getSubrepositories()
Returns null as does not support subrepositories
 o getSubrepository(String)
Returns a null as subrepository are not supported.
 o isEmpty()
Returns true if the repository contains no keys or values
 o keys()
Returns an enumeration of the keys in the repository
 o length()
Returns the number of keys in the repository.
 o put(String, Object)
Add the object "value" to the repository with the given key.
 o put(String, Object, String)
 o putSerializable(String, Serializable)
Add the object "value" to the repository with the given key.
 o putSerializable(String, Serializable, String)
 o remove(String)
Removes the given key and corresponding value from the repository.
 o setNameSeparator(char)
The name separator is the char used to separate the name of a Repository and a subrepository or key.
 o size()
Returns the number of keys in the repository.

Constructors

 o ASCIIFileRepository
 public ASCIIFileRepository(String directoryName)
Open a ASCIIFileRepository.

Parameters:
directoryName - The directory containing the repository files.
 o ASCIIFileRepository
 public ASCIIFileRepository(File repositoryDirectory)
Open a ASCIIFileRepository.

Parameters:
repositoryDirectory - The directory containing the repository files.

Methods

 o exists
 public boolean exists()
Returns true if the repository exists

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

 o createSubrepository
 public boolean createSubrepository(String name)
Returns false as does not support subrepositories.

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

 o put
 public void put(String key,
                 Object value,
                 String comment) throws IOException
 o 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

 o putSerializable
 public void putSerializable(String key,
                             Serializable value,
                             String comment) throws IOException
 o get
 public Object get(String key) throws IOException
Retreive the item in the repository stored under the given key.

 o getSubrepository
 public Repository getSubrepository(String name)
Returns a null as subrepository are not supported.

 o containsKey
 public boolean containsKey(String key)
Returns true is the repostitory contains data at the given key

 o containsSubrepository
 public boolean containsSubrepository(String name)
Returns false as does not support subrepositories

 o 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 '.'

 o getSubrepositories
 public Enumeration getSubrepositories()
Returns null as does not support subrepositories

 o keys
 public Enumeration keys()
Returns an enumeration of the keys in the repository

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

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

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

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


All Packages  Class Hierarchy  This Package  Previous  Next  Index