gov.llnl.babel.repository

Class FileRepository

Implemented Interfaces:
Repository, SymbolResolver, SymbolWriter

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(String repository, Context context)
The constructor takes a file directory path to the repository.

Method Summary

boolean
equals(Object obj)
Set
getAllSymbols()
Retrieve all symbols currently in the repository.
Symbol
lookupSymbol(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(Set symbol_names)
Write the symbols in the Set from the symbol table to the file repository.

Constructor Details

FileRepository

public FileRepository(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.

Method Details

equals

public boolean equals(Object obj)

getAllSymbols

public 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.

lookupSymbol

public Symbol lookupSymbol(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

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

writeSymbols

public void writeSymbols(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