Package org.biojavax.bio.db
Class HashBioEntryDB
- java.lang.Object
-
- org.biojava.utils.AbstractChangeable
-
- org.biojavax.bio.db.AbstractBioEntryDB
-
- org.biojavax.bio.db.HashBioEntryDB
-
- All Implemented Interfaces:
Changeable
,BioEntryDB
,BioEntryDBLite
public class HashBioEntryDB extends AbstractBioEntryDB implements BioEntryDB
An implementation of RichSequenceDB that uses an underlying HashMap to store the RichSequence objects.- Since:
- 1.5
- Author:
- Matthew Pocock, Gerald Loeffler, Richard Holland
-
-
Field Summary
-
Fields inherited from interface org.biojavax.bio.db.BioEntryDBLite
BIOENTRYS
-
-
Constructor Summary
Constructors Constructor Description HashBioEntryDB()
Generate a HashRichSequenceDB object that will use byName to generate ids for sequences and have a null name.HashBioEntryDB(String name)
Generate a HashRichSequenceDB object that will use byName to generate ids and will have the requested name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addBioEntry(String id, BioEntry seq)
void
addBioEntry(BioEntry seq)
Add a BioEntry, the name of the BioEntry will be used as the IDBioEntry
getBioEntry(String id)
Retrieve a single BioEntry by its id.BioEntryDB
getBioEntrys(Set ids)
Retrieve multiple BioEntry by their ids.BioEntryDB
getBioEntrys(Set ids, BioEntryDB db)
Retrieve multiple BioEntry into a specific sequence database.String
getName()
Get the name of this sequence database.Set
ids()
Get an immutable set of all of the IDs in the database.void
removeBioEntry(String id)
Remove the BioEntry associated with an ID from the database.-
Methods inherited from class org.biojavax.bio.db.AbstractBioEntryDB
getBioEntryIterator
-
Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.biojavax.bio.db.BioEntryDB
getBioEntryIterator
-
-
-
-
Constructor Detail
-
HashBioEntryDB
public HashBioEntryDB()
Generate a HashRichSequenceDB object that will use byName to generate ids for sequences and have a null name.
-
HashBioEntryDB
public HashBioEntryDB(String name)
Generate a HashRichSequenceDB object that will use byName to generate ids and will have the requested name.- Parameters:
name
- the name for this database
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:BioEntryDBLite
Get the name of this sequence database.- Specified by:
getName
in interfaceBioEntryDBLite
- Returns:
- the name of the sequence database, which may be null.
-
getBioEntry
public BioEntry getBioEntry(String id) throws BioException, IllegalIDException
Description copied from interface:BioEntryDBLite
Retrieve a single BioEntry by its id.- Specified by:
getBioEntry
in interfaceBioEntryDBLite
- Parameters:
id
- the id to retrieve by- Returns:
- the BioEntry with that id
- Throws:
IllegalIDException
- if the database doesn't know about the idBioException
- if there was a failure in retrieving the BioEntry
-
getBioEntrys
public BioEntryDB getBioEntrys(Set ids) throws BioException, IllegalIDException
Description copied from interface:BioEntryDBLite
Retrieve multiple BioEntry by their ids.- Specified by:
getBioEntrys
in interfaceBioEntryDBLite
- Parameters:
ids
- a set of ids to retrieve by- Returns:
- the BioEntrys with those ids
- Throws:
IllegalIDException
- if the database doesn't know about the idBioException
-
getBioEntrys
public BioEntryDB getBioEntrys(Set ids, BioEntryDB db) throws BioException, IllegalIDException
Description copied from interface:BioEntryDBLite
Retrieve multiple BioEntry into a specific sequence database. If that database is null, a new HashBioEntryDB is used.- Specified by:
getBioEntrys
in interfaceBioEntryDBLite
- Parameters:
ids
- a set of ids to retrieve bydb
- a database to load the seqs into- Returns:
- the BioEntrys with that id
- Throws:
IllegalIDException
- if the database doesn't know about the idBioException
-
ids
public Set ids()
Description copied from interface:BioEntryDB
Get an immutable set of all of the IDs in the database. The ids are legal arguments to getBioEntry.- Specified by:
ids
in interfaceBioEntryDB
- Returns:
- a Set of ids - at the moment, strings
-
addBioEntry
public void addBioEntry(BioEntry seq) throws IllegalIDException, BioException, ChangeVetoException
Add a BioEntry, the name of the BioEntry will be used as the ID- Specified by:
addBioEntry
in interfaceBioEntryDBLite
- Overrides:
addBioEntry
in classAbstractBioEntryDB
- Parameters:
seq
- the BioEntry to add- Throws:
ChangeVetoException
- if this addition was vetoedIllegalIDException
- if a uniqe ID could not be generated for BioEntryBioException
- if something goes wrong with adding the BioEntry
-
addBioEntry
protected void addBioEntry(String id, BioEntry seq) throws IllegalIDException, BioException, ChangeVetoException
-
removeBioEntry
public void removeBioEntry(String id) throws IllegalIDException, BioException, ChangeVetoException
Description copied from interface:BioEntryDBLite
Remove the BioEntry associated with an ID from the database.- Specified by:
removeBioEntry
in interfaceBioEntryDBLite
- Overrides:
removeBioEntry
in classAbstractBioEntryDB
- Parameters:
id
- the ID of the BioEntry to remove- Throws:
IllegalIDException
- if there is no BioEntry for the IDBioException
- if something failed while removing the BioEntry for that IDChangeVetoException
- if either the database does not allow BioEntrys to be removed or the modification was vetoed
-
-