gov.llnl.babel.repository
Class FileRepository

java.lang.Object
  extended by gov.llnl.babel.repository.FileRepository
All Implemented Interfaces:
Repository, SymbolWriter, SymbolResolver

public class FileRepository
extends java.lang.Object
implements Repository

The FileRepository class implements a simple repository for sidl symbols using XML files stored in a single root directory. Each symbol is mapped to a file in that directory of the generic form NAME-vVERSION.xml, where NAME and VERSION are taken from the symbol identifier. This class does not cache the symbols in the file repository directory because external writers may change the repository.


Constructor Summary
FileRepository(java.lang.String repository, Context context)
          The constructor takes a file directory path to the repository.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.util.Set getAllSymbols()
          Retrieve all symbols currently in the repository.
 Symbol lookupSymbol(java.lang.String fqn)
          Look up a symbol based on the fully qualified name and retrieve the most recent version that matches the symbol name.
 Symbol lookupSymbol(SymbolID id)
          Look up the symbol based on the fully qualified name and version in the file repository.
 void writeSymbols(java.util.Set symbol_names)
          Write the symbols in the Set from the symbol table to the file repository.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileRepository

public FileRepository(java.lang.String repository,
                      Context context)
               throws RepositoryException
The constructor takes a file directory path to the repository. If the path is not a directory or does not exist, then a repository exception will be thrown by the constructor.

Throws:
RepositoryException
Method Detail

lookupSymbol

public Symbol lookupSymbol(SymbolID id)
Look up the symbol based on the fully qualified name and version in the file repository. If the symbol name is not found, the versions do not match, or there is a problem with the XML format, then null is returned. Note that since version 1.0 is the same as 1.0.0, we need to construct all versions that match the name and then search for the one equal to the symbol identifier.

Specified by:
lookupSymbol in interface SymbolResolver

lookupSymbol

public Symbol lookupSymbol(java.lang.String fqn)
Look up a symbol based on the fully qualified name and retrieve the most recent version that matches the symbol name. If the symbol name is not found or the XML file is invalid, then null is returned. Note that if there is a format problem with the most recent version, this routine will try older versions until a well-formed version is found.

Specified by:
lookupSymbol in interface SymbolResolver

getAllSymbols

public java.util.Set getAllSymbols()
Retrieve all symbols currently in the repository. The symbols are returned in a Set in which each set element is an object of type SymbolID. The return argument will not be null but may contain no objects.


writeSymbols

public void writeSymbols(java.util.Set symbol_names)
                  throws RepositoryException
Write the symbols in the Set from the symbol table to the file repository. Each set entry is a SymbolID of the symbol to be written.

Specified by:
writeSymbols in interface SymbolWriter
Throws:
RepositoryException

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object