org.biojava.bio.program.indexdb
Class BioStore

java.lang.Object
  extended by org.biojava.bio.program.indexdb.BioStore
All Implemented Interfaces:
IndexStore

public class BioStore
extends java.lang.Object
implements IndexStore

BioStores represent directory and file structures which index flat files according to the OBDA specification. The preferred method of constructing new instances is to use BioStoreFactory.

Author:
Matthew Pocock, Keith James

Constructor Summary
BioStore(java.io.File location, boolean cache)
          Creates a new BioStore flatfile index at the specified location with the specified caching behaviour.
 
Method Summary
 void commit()
          commit writes an index to disk.
 Record get(java.lang.String id)
          get returns a record specified by a primary identifier.
 java.util.List get(java.lang.String id, java.lang.String namespace)
          get returns a list of Records by searching against the primary identifiers if the namespace argument is equal to the primary namespace or otherwise by searching the secondary namespaces.
 java.io.File getLocation()
          getLocation returns the directory where the index is located.
 Annotation getMetaData()
          getMetaData returns a data structure which represents an OBDA "config.dat" flatfile indexing configuration file.
 java.lang.String getName()
          The name of this store or null if the name has not been set.
 java.util.List getRecordList()
          getRecordList returns all the Records in the index.
 void writeRecord(RAF file, long offset, int length, java.lang.String id, java.util.Map secIDs)
          writeRecord creates and writes a new Record
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BioStore

public BioStore(java.io.File location,
                boolean cache)
         throws java.io.IOException,
                BioException
Creates a new BioStore flatfile index at the specified location with the specified caching behaviour.

Parameters:
location - a File indicating the index directory.
cache - a boolean indicating whether the implementation should cache its state.
Throws:
java.io.IOException - if an error occurs.
BioException - if an error occurs.
Method Detail

getName

public java.lang.String getName()
The name of this store or null if the name has not been set.


getLocation

public java.io.File getLocation()
getLocation returns the directory where the index is located.

Returns:
a File.

getMetaData

public Annotation getMetaData()
Description copied from interface: IndexStore
getMetaData returns a data structure which represents an OBDA "config.dat" flatfile indexing configuration file.

Specified by:
getMetaData in interface IndexStore
Returns:
an Annotation.

get

public Record get(java.lang.String id)
Description copied from interface: IndexStore
get returns a record specified by a primary identifier.

Specified by:
get in interface IndexStore
Parameters:
id - a String primary ID.
Returns:
a Record.

get

public java.util.List get(java.lang.String id,
                          java.lang.String namespace)
                   throws BioException
Description copied from interface: IndexStore
get returns a list of Records by searching against the primary identifiers if the namespace argument is equal to the primary namespace or otherwise by searching the secondary namespaces. The list of Record instances retuned may be empty, but is never null.

Specified by:
get in interface IndexStore
Parameters:
id - a String primary ID.
namespace - a String.
Returns:
a List of Records.
Throws:
BioException - if an error occurs.

writeRecord

public void writeRecord(RAF file,
                        long offset,
                        int length,
                        java.lang.String id,
                        java.util.Map secIDs)
Description copied from interface: IndexStore
writeRecord creates and writes a new Record

Specified by:
writeRecord in interface IndexStore
Parameters:
file - a RAF file.
offset - a long byte offset.
length - an int byte record length.
id - a String primary ID.
secIDs - a Map of primary ID to a List of secondary IDs.

getRecordList

public java.util.List getRecordList()
getRecordList returns all the Records in the index.

Returns:
a List of Records.

commit

public void commit()
            throws CommitFailure
commit writes an index to disk.

Throws:
CommitFailure - if an error occurs.