## org.biojavax.ontology
Class SimpleComparableTerm

    java.lang.Object
      org.biojava.utils.AbstractChangeable
          org.biojavax.ontology.SimpleComparableTerm

All Implemented Interfaces:
  Comparable, Annotatable, Term, Changeable, ComparableTerm, RankedCrossRefable

    public class SimpleComparableTerm

extends AbstractChangeable
implements ComparableTerm

A Term object that can be compared and thus sorted.

Since:
  1.5
Author:
  Richard Holland

Nested Class Summary

Nested classes/interfaces inherited from interface org.biojava.ontology.Term
`Term.Impl`

Nested classes/interfaces inherited from interface org.biojava.bio.Annotatable
`Annotatable.AnnotationForwarder`

Field Summary

Fields inherited from interface org.biojavax.ontology.ComparableTerm
`DESCRIPTION, IDENTIFIER, OBSOLETE, RANKEDCROSSREF`

Fields inherited from interface org.biojava.ontology.Term
`ONTOLOGY`

Fields inherited from interface org.biojava.bio.Annotatable
`ANNOTATION`

Constructor Summary
`protected` `SimpleComparableTerm()`

Method Summary
`void` `addRankedCrossRef(RankedCrossRef crossref)` Adds a ranked cross reference to the existing set.
`void` `addSynonym(Object synonym)` Add a synonym for this term. Synonyms are stored in the database as the results of a toString() operation on each synonym object.
`int` `compareTo(Object o)` Terms are sorted by ontology first, then name.
`boolean` `equals(Object obj)` Two terms are equal if they are in the same ontology and share the same name.
`Annotation` `getAnnotation()` Should return the associated annotation object. ALWAYS RETURNS AN EMPTY ANNOTATION OBJECT
`String` `getDescription()` Return a human-readable description of this term, or the empty string if none is available.
`Integer` `getId()` Gets the Hibernate ID.
`String` `getIdentifier()` Returns the (optional) identifier associated with this term.
`String` `getName()` Return the name of this term.
`Boolean` `getObsolete()` Checks to see if this term is obsolete.
`Ontology` `getOntology()` Return the ontology in which this term exists.
`Set` `getRankedCrossRefs()` Returns the set of all ranked cross references associated with an object. Warning this method gives access to the original Collection not a copy.
`Object[]` `getSynonyms()` Return the synonyms for this term.
`int` `hashCode()`
`void` `removeRankedCrossRef(RankedCrossRef crossref)` Removes a ranked cross reference from the existing set.
`void` `removeSynonym(Object synonym)` Remove a synonym for this term.
`void` `setDescription(String description)` set the description of the term;
`void` `setId(Integer id)` Sets the Hibernate ID.
`void` `setIdentifier(String identifier)` Sets the (optional) identifier associated with this term.
`void` `setObsolete(Boolean obsolete)` Sets the obsolescence flag associated with this term.
`void` `setRankedCrossRefs(Set rankedcrossrefs)` Sets the ranked cross references associated with an object. Warning this method gives access to the original Collection not a copy.
`String` `toString()` Form: "ontology:name [obsolete]" where [obsolete] is optional

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, finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.biojava.utils.Changeable
`addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener`

Constructor Detail

### SimpleComparableTerm

    protected SimpleComparableTerm()

Method Detail

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### equals

    public boolean equals(Object obj)

  Two terms are equal if they are in the same ontology and share the same name.

  Overrides:
    `equals` in class `Object`

### compareTo

    public int compareTo(Object o)

  Terms are sorted by ontology first, then name.

  Specified by:
    `compareTo` in interface `Comparable`

### addSynonym

    public void addSynonym(Object synonym)

  Add a synonym for this term. Synonyms are stored in the database as the results of a toString() operation on each synonym object. This doesn't happen until it reaches the database though, so if you are not using a database, don't worry about it.

  Specified by:
    `addSynonym` in interface `Term`
  Parameters:
    `synonym` - the synonym

### removeSynonym

    public void removeSynonym(Object synonym)

  Remove a synonym for this term.

  Specified by:
    `removeSynonym` in interface `Term`

### getSynonyms

    public Object[] getSynonyms()

  Return the synonyms for this term.

  Specified by:
    `getSynonyms` in interface `Term`
  Returns:
    the synonyms

### getRankedCrossRefs

    public Set getRankedCrossRefs()

  Returns the set of all ranked cross references associated with an object. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.

  Specified by:
    `getRankedCrossRefs` in interface `RankedCrossRefable`
  Returns:
    a set of RankedCrossRef objects.

### setRankedCrossRefs

    public void setRankedCrossRefs(Set rankedcrossrefs)
                            throws ChangeVetoException

  Sets the ranked cross references associated with an object. Null will throw an exception but the empty set is fine. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.

  Specified by:
    `setRankedCrossRefs` in interface `RankedCrossRefable`
  Parameters:
    `rankedcrossrefs` - a set of RankedCrossRef objects.
  Throws:
    `ChangeVetoException` - if the set was null or any of its contents were not RankedCrossRef objects.

### addRankedCrossRef

    public void addRankedCrossRef(RankedCrossRef crossref)
                           throws ChangeVetoException

  Adds a ranked cross reference to the existing set. If already present, this call is ignored. Null values are not acceptable.

  Specified by:
    `addRankedCrossRef` in interface `RankedCrossRefable`
  Parameters:
    `crossref` - the ranked cross reference to add.
  Throws:
    `ChangeVetoException` - if the parameter is null.

### removeRankedCrossRef

    public void removeRankedCrossRef(RankedCrossRef crossref)
                              throws ChangeVetoException

  Removes a ranked cross reference from the existing set. If not present, this call is ignored. Null values are not acceptable.

  Specified by:
    `removeRankedCrossRef` in interface `RankedCrossRefable`
  Parameters:
    `crossref` - the ranked cross reference to remove.
  Throws:
    `ChangeVetoException` - if the parameter is null.

### getName

    public String getName()

  Return the name of this term.

  Specified by:
    `getName` in interface `Term`
  Returns:
    the name of the term

### getDescription

    public String getDescription()

  Return a human-readable description of this term, or the empty string if none is available.

  Specified by:
    `getDescription` in interface `Term`
  Returns:
    the description of the term

### setDescription

    public void setDescription(String description)
                        throws ChangeVetoException

  set the description of the term;

  Specified by:
    `setDescription` in interface `Term`
  Specified by:
    `setDescription` in interface `ComparableTerm`
  Parameters:
    `description` - the description to give the term. Nullable.
  Throws:
    `ChangeVetoException` - if the description is unacceptable.

### getOntology

    public Ontology getOntology()

  Return the ontology in which this term exists.

  Specified by:
    `getOntology` in interface `Term`
  Returns:
    the ontology

### toString

    public String toString()

  Form: "ontology:name [obsolete]" where [obsolete] is optional

  Overrides:
    `toString` in class `Object`

### getAnnotation

    public Annotation getAnnotation()

  Should return the associated annotation object. ALWAYS RETURNS AN EMPTY ANNOTATION OBJECT

  Specified by:
    `getAnnotation` in interface `Annotatable`
  Returns:
    an Annotation object, never null

### getIdentifier

    public String getIdentifier()

  Returns the (optional) identifier associated with this term.

  Specified by:
    `getIdentifier` in interface `ComparableTerm`
  Returns:
    the string identifier.

### setIdentifier

    public void setIdentifier(String identifier)
                       throws ChangeVetoException

  Sets the (optional) identifier associated with this term.

  Specified by:
    `setIdentifier` in interface `ComparableTerm`
  Parameters:
    `identifier` - the identifier to give the term. Null will unset it.
  Throws:
    `ChangeVetoException` - if the identifier is unacceptable.

### getObsolete

    public Boolean getObsolete()

  Checks to see if this term is obsolete. As the column in the database is nullable, this value is a Boolean object instead of a boolean simple type. Hence it may also be null.

  Specified by:
    `getObsolete` in interface `ComparableTerm`
  Returns:
    true if it is, false if not.

### setObsolete

    public void setObsolete(Boolean obsolete)
                     throws ChangeVetoException

  Sets the obsolescence flag associated with this term.

  Specified by:
    `setObsolete` in interface `ComparableTerm`
  Parameters:
    `obsolete` - true if it is obsolete, false if not. Nullable.
  Throws:
    `ChangeVetoException` - if the change is unacceptable.

### getId

    public Integer getId()

  Gets the Hibernate ID. Should be used with caution.

  Returns:
    the Hibernate ID, if using Hibernate.

### setId

    public void setId(Integer id)

  Sets the Hibernate ID. Should be used with caution.

  Parameters:
    `id` - the Hibernate ID, if using Hibernate.