org.biojava.bio.taxa
Class WeakTaxon
java.lang.Object
org.biojava.utils.AbstractChangeable
org.biojava.bio.taxa.AbstractTaxon
org.biojava.bio.taxa.WeakTaxon
- All Implemented Interfaces:
- Annotatable, Changeable, Taxon
- public class WeakTaxon
- extends AbstractTaxon
An implementation of Taxon that keeps only weak references to
children, but full references to parents.
This may be suitable for deriving memory-savy implementations
of TaxonFactory.
To manipulate the children set, use the getChildrenRaw and
setChildrenRaw methods. These 'box' the actual weak reference, but
recognize null to mean that there are no children currently
known. A code-fragment may wish to do something like this:
Set children = weakTaxon.getChildrenRaw();
if(children == null) {
children = new HashSet();
weakTaxon.setChildrenRaw(children);
}
// do stuff to update child set e.g. add children
- Author:
- Matthew Pocock
Constructor Summary |
WeakTaxon()
|
WeakTaxon(java.lang.String scientificName,
java.lang.String commonName)
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
parent
protected Taxon parent
WeakTaxon
public WeakTaxon()
WeakTaxon
public WeakTaxon(java.lang.String scientificName,
java.lang.String commonName)
getParent
public Taxon getParent()
- Description copied from interface:
Taxon
The parent of this Taxon.
Taxa live within a tree data-structure, so every taxon has a
single parent except for the root type. This has the null
parent.
- Returns:
- the parent Taxon, or null if this is the root type.
getChildren
public java.util.Set getChildren()
- Description copied from interface:
Taxon
The children of this Taxon.
Taxa live within a tree data-structure, so every taxon has
zero or more children. In the case of zero children, the empty
set is returned.
? read-only ? dynamicaly updated with taxon object ? copy of
data ?
- Returns:
- the Set (possibly empty) of all child Taxa
getChildrenRaw
public java.util.Set getChildrenRaw()
setChildrenRaw
public void setChildrenRaw(java.util.Set children)