org.biojava.ontology
Class Triple.Impl

java.lang.Object
  extended by org.biojava.utils.Unchangeable
      extended by org.biojava.ontology.Triple.Impl
All Implemented Interfaces:
Serializable, Annotatable, Term, Triple, Changeable
Enclosing interface:
Triple

public static final class Triple.Impl
extends Unchangeable
implements Triple, Serializable

Basic in-memory implementation of a Triple in an ontology This can be used to implement Ontology.createTriple

See Also:
SimpleComparableTriple, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.biojava.ontology.Triple
Triple.Impl
 
Nested classes/interfaces inherited from interface org.biojava.bio.Annotatable
Annotatable.AnnotationForwarder
 
Field Summary
 
Fields inherited from interface org.biojava.ontology.Term
ONTOLOGY
 
Fields inherited from interface org.biojava.bio.Annotatable
ANNOTATION
 
Constructor Summary
Triple.Impl(Term subject, Term object, Term predicate)
           
Triple.Impl(Term subject, Term object, Term predicate, Object[] synonyms)
           
Triple.Impl(Term subject, Term object, Term predicate, String name, String description)
           
Triple.Impl(Term subject, Term object, Term predicate, String name, String description, Object[] synonyms)
           
 
Method Summary
 void addSynonym(Object synonym)
          Add a synonym for this term.
 boolean equals(Object o)
          Two triples are equal if all their fields are identical.
 Annotation getAnnotation()
          Should return the associated annotation object.
 String getDescription()
          Return a human-readable description of this term, or the empty string if none is available.
 String getName()
          Return the name of this term.
 Term getObject()
          Return the object term of this triple.
 Ontology getOntology()
          Return the ontology in which this term exists.
 Term getPredicate()
          Return a Term which defines the type of relationship between the subject and object terms.
 Term getSubject()
          Return the subject term of this triple
 Object[] getSynonyms()
          Return the synonyms for this term.
 int hashCode()
          The hashcode for a Triple.
 void removeSynonym(Object synonym)
          Remove a synonym for this term.
 void setDescription(String desc)
          set the description of the term;
 String toString()
           
 
Methods inherited from class org.biojava.utils.Unchangeable
addChangeListener, addChangeListener, addForwarder, getForwarders, getListeners, isUnchanging, removeChangeListener, removeChangeListener, removeForwarder
 
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

Triple.Impl

public Triple.Impl(Term subject,
                   Term object,
                   Term predicate)

Triple.Impl

public Triple.Impl(Term subject,
                   Term object,
                   Term predicate,
                   Object[] synonyms)

Triple.Impl

public Triple.Impl(Term subject,
                   Term object,
                   Term predicate,
                   String name,
                   String description)

Triple.Impl

public Triple.Impl(Term subject,
                   Term object,
                   Term predicate,
                   String name,
                   String description,
                   Object[] synonyms)
Method Detail

addSynonym

public void addSynonym(Object synonym)
Description copied from interface: Term
Add a synonym for this term.

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

removeSynonym

public void removeSynonym(Object synonym)
Description copied from interface: Term
Remove a synonym for this term.

Specified by:
removeSynonym in interface Term

getSynonyms

public Object[] getSynonyms()
Description copied from interface: Term
Return the synonyms for this term.

Specified by:
getSynonyms in interface Term
Returns:
the synonyms

getName

public String getName()
Description copied from interface: Term
Return the name of this term.

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

getDescription

public String getDescription()
Description copied from interface: Term
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 desc)
Description copied from interface: Term
set the description of the term;

Specified by:
setDescription in interface Term

getOntology

public Ontology getOntology()
Description copied from interface: Term
Return the ontology in which this term exists.

Specified by:
getOntology in interface Term
Returns:
the ontology

getSubject

public Term getSubject()
Description copied from interface: Triple
Return the subject term of this triple

Specified by:
getSubject in interface Triple
Returns:
the subject term

getObject

public Term getObject()
Description copied from interface: Triple
Return the object term of this triple.

Specified by:
getObject in interface Triple
Returns:
the object term

getPredicate

public Term getPredicate()
Description copied from interface: Triple
Return a Term which defines the type of relationship between the subject and object terms.

Specified by:
getPredicate in interface Triple
Returns:
the predicate

getAnnotation

public Annotation getAnnotation()
Description copied from interface: Annotatable
Should return the associated annotation object.

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

equals

public boolean equals(Object o)
Two triples are equal if all their fields are identical.

Specified by:
equals in interface Triple
Overrides:
equals in class Object

hashCode

public int hashCode()
Description copied from interface: Triple
The hashcode for a Triple.

This must be implemented as:

 return getSubject().hashCode() +
   31 * getObject().hashCode() +
   31 * 31 * getPredicate().hashCode();
 
If you do not implement hashcode in this way then you have no guarantee that your Triple objects will be found in an ontology and that they will not be duplicated.

Specified by:
hashCode in interface Triple
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object