Package org.biojavax.ontology
Class SimpleComparableTriple
java.lang.Object
org.biojava.utils.AbstractChangeable
org.biojavax.ontology.SimpleComparableTriple
- All Implemented Interfaces:
Comparable,Annotatable,Term,Triple,Changeable,ComparableTriple
Basic comparable triple, BioSQL style.
- Since:
- 1.5
- Author:
- Richard Holland
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.biojava.bio.Annotatable
Annotatable.AnnotationForwarderNested classes/interfaces inherited from interface org.biojava.ontology.Triple
Triple.Impl -
Field Summary
Fields inherited from interface org.biojava.bio.Annotatable
ANNOTATIONFields inherited from interface org.biojavax.ontology.ComparableTriple
DESCRIPTOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDescriptor(ComparableTerm desc) Adds a descriptor.voidaddSynonym(Object synonym) Add a synonym for this term.intTriples are sorted in order of ontology, subject, object, and finally predicate.booleanCheck to see if an object is an equivalent Triple.Should return the associated annotation object.Return a human-readable description of this term, or the empty string if none is available.Returns all descriptors.getId()Gets the Hibernate ID.getName()Return the name of this term.Return the object term of this triple.Return the ontology in which this term exists.Return a Term which defines the type of relationship between the subject and object terms.Return the subject term of this tripleObject[]Return the synonyms for this term.inthashCode()The hashcode for a Triple.booleanRemoves a descriptor.voidremoveSynonym(Object synonym) Remove a synonym for this term.voidsetDescription(String desc) set the description of the term;voidsetDescriptors(Set descriptors) Clears the current set of descriptors and replaces it with the content of the set passed.voidSets the Hibernate ID.toString()Form: "ontology:predicate(subject,object)"Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListenerMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
-
Constructor Details
-
SimpleComparableTriple
protected SimpleComparableTriple()
-
-
Method Details
-
compareTo
Triples are sorted in order of ontology, subject, object, and finally predicate.- Specified by:
compareToin interfaceComparable
-
equals
Check to see if an object is an equivalent Triple.Two triples are equivalent if they have the same subject, object and predicate fields.
if (! (o instanceof Triple)) { return false; } Triple to = (Triple) o; return to.getSubject() == getSubject() && to.getObject() == getObject() && to.getPredicate() == getPredicate();If you do not implement equals 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. Triples are equal only if they are from the same ontology and share the same subject, object and predicate. -
hashCode
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. -
getName
Return the name of this term. Returns the output of toSring() -
getSubject
Return the subject term of this triple- Specified by:
getSubjectin interfaceTriple- Returns:
- the subject term
-
getObject
Return the object term of this triple. -
getPredicate
Return a Term which defines the type of relationship between the subject and object terms.- Specified by:
getPredicatein interfaceTriple- Returns:
- the predicate
-
addDescriptor
Adds a descriptor. Must not be null.- Specified by:
addDescriptorin interfaceComparableTriple- Parameters:
desc- the descriptor to add.- Throws:
IllegalArgumentException- if the descriptor is missing.ChangeVetoException- in case of objections.
-
removeDescriptor
public boolean removeDescriptor(ComparableTerm desc) throws IllegalArgumentException, ChangeVetoException Removes a descriptor. Must not be null.- Specified by:
removeDescriptorin interfaceComparableTriple- Parameters:
desc- the descriptor to remove.- Returns:
- True if it did it, false if the descriptor did not exist.
- Throws:
IllegalArgumentException- if the descriptor is missing.ChangeVetoException- in case of objections.
-
getDescriptors
Returns all descriptors. 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:
getDescriptorsin interfaceComparableTriple- Returns:
- a set of all ComparableTerm descriptors, possibly empty.
- See Also:
-
setDescriptors
Clears the current set of descriptors and replaces it with the content of the set passed. 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:
setDescriptorsin interfaceComparableTriple- Parameters:
descriptors- the set of ComparableTerm descriptors to add.- Throws:
ChangeVetoException- in case of objections.- See Also:
-
removeSynonym
Remove a synonym for this term. NOT IMPLEMENTED- Specified by:
removeSynonymin interfaceTerm
-
addSynonym
Add a synonym for this term. NOT IMPLEMENTED- Specified by:
addSynonymin interfaceTerm- Parameters:
synonym- the synonym
-
getSynonyms
Return the synonyms for this term. ALWAYS RETURNS AN EMPTY LIST- Specified by:
getSynonymsin interfaceTerm- Returns:
- the synonyms
-
getOntology
Return the ontology in which this term exists.- Specified by:
getOntologyin interfaceTerm- Returns:
- the ontology
-
getDescription
Return a human-readable description of this term, or the empty string if none is available. ALWAYS RETURNS THE EMPTY STRING- Specified by:
getDescriptionin interfaceTerm- Returns:
- the description of the term
-
setDescription
set the description of the term; does not do anything- Specified by:
setDescriptionin interfaceTerm
-
getAnnotation
Should return the associated annotation object. ALWAYS RETURNS THE EMPTY ANNOTATION- Specified by:
getAnnotationin interfaceAnnotatable- Returns:
- an Annotation object, never null
-
toString
Form: "ontology:predicate(subject,object)" -
getId
Gets the Hibernate ID. Should be used with caution.- Returns:
- the Hibernate ID, if using Hibernate.
-
setId
Sets the Hibernate ID. Should be used with caution.- Parameters:
id- the Hibernate ID, if using Hibernate.
-