org.biojava.bio.taxa
Class SimpleTaxonFactory

java.lang.Object
  extended byorg.biojava.bio.taxa.SimpleTaxonFactory
All Implemented Interfaces:
TaxonFactory

public class SimpleTaxonFactory
extends java.lang.Object
implements TaxonFactory

A no-frills implementation of TaxaFactory that builds an in-memory Taxa tree.

Author:
Matthew Pocock

Field Summary
static SimpleTaxonFactory GLOBAL
          The TaxonFactory that the biojava system should use for storing the taxonomy used by swissprot and embl as in-memory objects.
 
Constructor Summary
SimpleTaxonFactory(java.lang.String name)
           
 
Method Summary
 Taxon addChild(Taxon parent, Taxon child)
          Add a taxon as a child to a parent.
 Taxon createTaxon(java.lang.String scientificName, java.lang.String commonName)
          Create a new orphan Taxon with a given scientific and common name.
 java.lang.String getName()
          Name for this TaxonFactory.
 Taxon getRoot()
          Retrieve the root upon which all rooted Taxon that this factory knows about are rooted.
 Taxon importTaxon(Taxon taxon)
          Import a Taxon and all its children into the implementation provided by this factory.
 Taxon removeChild(Taxon parent, Taxon child)
          Remove a Taxon as a child to this one.
 Taxon search(java.lang.Object id)
          Retrieve a Taxon that matches some ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GLOBAL

public static final SimpleTaxonFactory GLOBAL
The TaxonFactory that the biojava system should use for storing the taxonomy used by swissprot and embl as in-memory objects.

Constructor Detail

SimpleTaxonFactory

public SimpleTaxonFactory(java.lang.String name)
Method Detail

getRoot

public Taxon getRoot()
Description copied from interface: TaxonFactory

Retrieve the root upon which all rooted Taxon that this factory knows about are rooted.

Specified by:
getRoot in interface TaxonFactory
Returns:
the 'root' Taxon

getName

public java.lang.String getName()
Description copied from interface: TaxonFactory

Name for this TaxonFactory.

Specified by:
getName in interface TaxonFactory
Returns:
the name of this TaxonFactory

importTaxon

public Taxon importTaxon(Taxon taxon)
Description copied from interface: TaxonFactory

Import a Taxon and all its children into the implementation provided by this factory.

The return value of this method should be .equals() and .hasCode() compatable with the taxon parameter. It may not be implemented by the same underlying implementation.

Specified by:
importTaxon in interface TaxonFactory
Parameters:
taxon - the Taxon to copy
Returns:
a new Taxon

createTaxon

public Taxon createTaxon(java.lang.String scientificName,
                         java.lang.String commonName)
Description copied from interface: TaxonFactory

Create a new orphan Taxon with a given scientific and common name.

Specified by:
createTaxon in interface TaxonFactory
Parameters:
scientificName - the scientificName to give the Taxon
commonName - the common name to give the Taxon
Returns:
a new Taxon with no parent and no children

addChild

public Taxon addChild(Taxon parent,
                      Taxon child)
Description copied from interface: TaxonFactory

Add a taxon as a child to a parent.

The TaxonFactory may chose to add the child directly, or make a new object which is .equals() compatable with child. The actual Taxon instance inserted into the child set is returned by the add method.

Specified by:
addChild in interface TaxonFactory
Parameters:
parent - the parent Taxon to add the child to
child - the Taxon to add as a child
Returns:
the Taxon object actualy present as the child

removeChild

public Taxon removeChild(Taxon parent,
                         Taxon child)
Description copied from interface: TaxonFactory

Remove a Taxon as a child to this one.

This Taxon should attempt to remove a child that is .equals() compatable with child. If it is sucessful, it should return the Taxon instance that was removed. If not, it should return null.

Specified by:
removeChild in interface TaxonFactory
Parameters:
parent - the parent Taxon to remove the child from
child - the Taxon to remove as a child
Returns:
the actual Taxon removed, or null if none were removed

search

public Taxon search(java.lang.Object id)
Description copied from interface: TaxonFactory

Retrieve a Taxon that matches some ID.

This method is here out of desperation. It's nasty and should be replaced by some propper querying API. Without having different methods for every TaxonFactory I don't know what to do. All ideas appreciated.

Specified by:
search in interface TaxonFactory
Parameters:
id - the Object identifying a Taxon
Returns:
the Taxon matching the ID, or null if none match