SimpleComparableOntology (BioJava-1.5-beta API)
Keywords: org.biojavax.ontology.SimpleComparableOntology class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.biojavax.ontology
Class SimpleComparableOntology

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

All Implemented Interfaces:
  Comparable, Ontology, Changeable, ComparableOntology

    public class SimpleComparableOntology

extends AbstractChangeable
implements ComparableOntology

Represents an ontology that can be compared to other ontologies.

Since:
  1.5
Author:
  Richard Holland, Mark Schreiber

Nested Class Summary

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

Field Summary

Fields inherited from interface org.biojavax.ontology.ComparableOntology
`DESCRIPTION, TERM, TRIPLE`

Constructor Summary
`protected` | `SimpleComparableOntology()`
`` | `SimpleComparableOntology(String name)` Creates a new instance of SimpleComparableOntology with the given, immutable, non-nullable name.

Method Summary
`int` | `compareTo(Object o)` Ontologies are compared only by name.
`boolean` | `containsTerm(String name)` Determines if this ontology currently contains a term named `name`
`boolean` | `containsTriple(Term subject, Term object, Term predicate)` See if a triple exists in this ontology If you call this method with plain Terms instead of ComparableTerms, it may not match any of the triples in the ontology as they are all stored as ComparableTerms.
`Term` | `createTerm(String name, String description)` Create a new term in this ontology.
`Term` | `createTerm(String name, String description, Object[] synonyms)` Create a new term in this ontology.
`Triple` | `createTriple(Term subject, Term object, Term predicate, String name, String description)` Creates a new Triple. If you call this method with plain Terms instead of ComparableTerms, it will import them into the local ontology first.
`Variable` | `createVariable(String name, String description)` Create a new term in this ontology that is used as a variable. NOT IMPLEMENTED
`void` | `deleteTerm(Term t)` Remove a term from an ontology, together with all triples which refer to it. If you call this method with a plain Term instead of a ComparableTerm, it may not match any of the terms in the ontology as they are all stored as ComparableTerms.
`boolean` | `equals(Object obj)` Ontologies are equal if their names are equal.
`String` | `getDescription()` Return a human-readable description of this ontology, or the empty string if none is available
`String` | `getName()` Return the name of this ontology
`OntologyOps` | `getOps()` Return the associated OntologyOps.
`ComparableTerm` | `getOrCreateTerm(String name)` Looks for a term with the given name and returns it. If the term has to be created, it is added with the description "auto-generated by biojavax".
`ComparableTriple` | `getOrCreateTriple(Term subject, Term object, Term predicate)` Looks for a triple with the given subject object and predicate and returns it.
`ComparableTerm` | `getOrImportTerm(Term term)` Looks for a term with the same name as the given term and returns it.
`Term` | `getTerm(String s)` Fetch the term with the specified name.
`Set` | `getTerms()` Return all the terms in this ontology This will always return a set of ComparableTerm objects.
`Set` | `getTermSet()` Returns the set of terms in this ontology. Warning this method gives access to the original Collection not a copy.
`Set` | `getTriples(Term subject, Term object, Term predicate)` Return all triples from this ontology which match the supplied pattern. If you call this method with plain Terms instead of ComparableTerms, it may not match any of the triples in the ontology as they are all stored as ComparableTerms.
`Set` | `getTripleSet()` Returns the set of triples in this ontology. Warning this method gives access to the original Collection not a copy.
`int` | `hashCode()`
`Term` | `importTerm(Term t, String localName)` Create a view of a term from another ontology. This particular implementation merely copies the term into this ontology, and returns a pointer to the copied term.
`void` | `setDescription(String description)` Sets a human-readable description of this ontology.
`void` | `setTermSet(Set terms)` Clears out all the terms and populates the ontology with the contents of the set passed. Warning this method gives access to the original Collection not a copy.
`void` | `setTripleSet(Set triples)` Clears out all the triples and populates the ontology with the contents of the set passed. Warning this method gives access to the original Collection not a copy.
`String` | `toString()` Form: "name"

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

### SimpleComparableOntology

    public SimpleComparableOntology(String name)

  Creates a new instance of SimpleComparableOntology with the given, immutable, non-nullable name.

  Parameters:
    `name` - the name of the ontology.

### SimpleComparableOntology

    protected SimpleComparableOntology()

Method Detail

### compareTo

    public int compareTo(Object o)

  Ontologies are compared only by name.

  Specified by:
    `compareTo` in interface `Comparable`

### equals

    public boolean equals(Object obj)

  Ontologies are equal if their names are equal.

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### toString

    public String toString()

  Form: "name"

  Overrides:
    `toString` in class `Object`

### containsTerm

    public boolean containsTerm(String name)

  Determines if this ontology currently contains a term named `name`

  Specified by:
    `containsTerm` in interface `Ontology`

### getTerm

    public Term getTerm(String s)
                 throws NoSuchElementException

  Fetch the term with the specified name.

  Specified by:
    `getTerm` in interface `Ontology`
  Returns:
    The term named `name`
  Throws:
    `NoSuchElementException` - if no term exists with that name

### getOrCreateTerm

    public ComparableTerm getOrCreateTerm(String name)

  Looks for a term with the given name and returns it. If it couldn't be found, then it creates it, adds it to the ontology, then returns it. If the term has to be created, it is added with the description "auto-generated by biojavax".

  Specified by:
    `getOrCreateTerm` in interface `ComparableOntology`
  Parameters:
    `name` - the name of the term to look for.
  Returns:
    the ComparableTerm representing that name.

### getOrCreateTriple

    public ComparableTriple getOrCreateTriple(Term subject,
                                              Term object,
                                              Term predicate)

  Looks for a triple with the given subject object and predicate and returns it. If it couldn't be found, then it creates it, adds it to the ontology, then returns it.

  Specified by:
    `getOrCreateTriple` in interface `ComparableOntology`
  Parameters:
    `subject` - the subject of the triple eg apple
    `object` - the object of the triple eg fruit
    `predicate` - the relationship of the triple eg is_a
  Returns:
    the ComparableTriple representing the object subject and predicate.

### getOrImportTerm

    public ComparableTerm getOrImportTerm(Term term)

  Looks for a term with the same name as the given term and returns it. If it couldn't be found, then it creates it, adds it to the ontology, then returns it.

  Specified by:
    `getOrImportTerm` in interface `ComparableOntology`
  Parameters:
    `term` - the term to look for.
  Returns:
    the ComparableTerm representing that term in this ontology.

### createTerm

    public Term createTerm(String name,
                           String description,
                           Object[] synonyms)
                    throws AlreadyExistsException,
                           ChangeVetoException,
                           IllegalArgumentException

  Create a new term in this ontology.

  Specified by:
    `createTerm` in interface `Ontology`
  Parameters:
    `name` - The name of the term (must be unique)
    `description` - A human-readable description (may be empty)
    `synonyms` - Some synonyms for this term.
  Returns:
    The newly created term.
  Throws:
    `AlreadyExistsException` - if a term of this name already exists
    `IllegalArgumentException` - if either `name` or `description` is `null`, or violates some other constraint of this implementation.
    `ChangeVetoException`

### importTerm

    public Term importTerm(Term t,
                           String localName)
                    throws ChangeVetoException,
                           IllegalArgumentException

  Create a view of a term from another ontology. If the requested term has already been imported under that name, this method returns the existing RemoteTerm object. If the term that is being imported is itself a RemoteTerm instance then first unwrap the term back to the orriginal term it represents and then produce a RemoteTerm from that. If the term being imported orriginated from this ontology, then return that term unaltered. This particular implementation merely copies the term into this ontology, and returns a pointer to the copied term. Thus the term becomes a part of this ontology instead of a pointer to another ontology.

  Specified by:
    `importTerm` in interface `Ontology`
  Parameters:
    `t` - the Term to import
    `localName` - the local name to import it under, optionally null
  Throws:
    `ChangeVetoException`
    `IllegalArgumentException`
  See Also:
    `ComparableTerm`

### createTriple

    public Triple createTriple(Term subject,
                               Term object,
                               Term predicate,
                               String name,
                               String description)
                        throws AlreadyExistsException,
                               ChangeVetoException

  Creates a new Triple. If you call this method with plain Terms instead of ComparableTerms, it will import them into the local ontology first. This is done BEFORE the check to see if the triple already exists, as obviously it can't check until it has the right terms to check with. So you may find the terms get imported but the triple does not. Moral of the story: use ComparableTerm objects!

  Specified by:
    `createTriple` in interface `Ontology`
  Parameters:
    `subject` - the subject Term
    `object` - the object Term
    `predicate` - the predicate Term
    `name` - the name of the triple, or null
    `description` - the description of the triple, or null
  Returns:
    a new Triple over these three terms
  Throws:
    `AlreadyExistsException` - if a triple already exists with the same subject, object and predicate, regardless of the name and description
    `ChangeVetoException`
  See Also:
    `ComparableTerm`

### deleteTerm

    public void deleteTerm(Term t)
                    throws ChangeVetoException

  Remove a term from an ontology, together with all triples which refer to it. If you call this method with a plain Term instead of a ComparableTerm, it may not match any of the terms in the ontology as they are all stored as ComparableTerms. So, use ComparableTerm objects! This method also removes all triples that the term is involved in.

  Specified by:
    `deleteTerm` in interface `Ontology`
  Throws:
    `ChangeVetoException`
  See Also:
    `ComparableTerm`

### getTriples

    public Set getTriples(Term subject,
                          Term object,
                          Term predicate)

  Return all triples from this ontology which match the supplied pattern. If any of the parameters of this method are `null`, they are treated as wildcards. If you call this method with plain Terms instead of ComparableTerms, it may not match any of the triples in the ontology as they are all stored as ComparableTerms. So, use ComparableTerm objects! The set returned is a set of ComparableTriple objects.

  Specified by:
    `getTriples` in interface `Ontology`
  Parameters:
    `subject` - The subject to search for, or `null`
    `object` - The object to search for, or `null`
    `predicate` - The relationship to search for, or `null`.
  See Also:
    `ComparableTerm`, `ComparableTriple`

### setTripleSet

    public void setTripleSet(Set triples)
                      throws ChangeVetoException

  Clears out all the triples and populates the ontology with the contents 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:
    `setTripleSet` in interface `ComparableOntology`
  Parameters:
    `triples` - the set of ComparableTriple objects this ontology should have.
  Throws:
    `ChangeVetoException` - if any of them are unacceptable.
  See Also:
    `ComparableTriple`

### getTripleSet

    public Set getTripleSet()

  Returns the set of triples in this ontology. 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:
    `getTripleSet` in interface `ComparableOntology`
  Returns:
    the set of ComparableTriple objects.

### getTerms

    public Set getTerms()

  Return all the terms in this ontology This will always return a set of ComparableTerm objects. It is not the original set so you are safe to modify it.

  Specified by:
    `getTerms` in interface `Ontology`
  See Also:
    `ComparableTerm`

### setTermSet

    public void setTermSet(Set terms)
                    throws ChangeVetoException

  Clears out all the terms and populates the ontology with the contents of the set passed. The terms should be ComparableTerms. 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:
    `setTermSet` in interface `ComparableOntology`
  Parameters:
    `terms` - a set of Term objects this ontology should have.
  Throws:
    `ChangeVetoException` - if any of them are unacceptable.
  See Also:
    `ComparableTerm`

### getTermSet

    public Set getTermSet()

  Returns the set of terms in this ontology. 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:
    `getTermSet` in interface `ComparableOntology`
  Returns:
    a set of ComparableTerm objects.
  See Also:
    `ComparableTerm`

### containsTriple

    public boolean containsTriple(Term subject,
                                  Term object,
                                  Term predicate)

  See if a triple exists in this ontology If you call this method with plain Terms instead of ComparableTerms, it may not match any of the triples in the ontology as they are all stored as ComparableTerms. So, use ComparableTerm objects! The set returned is a set of ComparableTriple objects.

  Specified by:
    `containsTriple` in interface `Ontology`
  See Also:
    `ComparableTerm`, `ComparableTriple`

### createTerm

    public Term createTerm(String name,
                           String description)
                    throws AlreadyExistsException,
                           ChangeVetoException,
                           IllegalArgumentException

  Create a new term in this ontology.

  Specified by:
    `createTerm` in interface `Ontology`
  Parameters:
    `name` - The name of the term (must be unique)
    `description` - A human-readable description (may be empty)
  Returns:
    The newly created term.
  Throws:
    `AlreadyExistsException` - if a term of this name already exists
    `IllegalArgumentException` - if either `name` or `description` is `null`, or violates some other constraint of this implementation.
    `ChangeVetoException`

### createVariable

    public Variable createVariable(String name,
                                   String description)
                            throws AlreadyExistsException,
                                   ChangeVetoException,
                                   IllegalArgumentException

  Create a new term in this ontology that is used as a variable. NOT IMPLEMENTED

  Specified by:
    `createVariable` in interface `Ontology`
  Parameters:
    `name` - The name of the term (must be unique)
    `description` - A human-readable description (may be empty)
  Returns:
    The newly created term.
  Throws:
    `AlreadyExistsException` - if a term of this name already exists
    `IllegalArgumentException` - if either `name` or `description` is `null`, or violates some other constraint of this implementation.
    `ChangeVetoException`

### getDescription

    public String getDescription()

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

  Specified by:
    `getDescription` in interface `Ontology`
  Specified by:
    `getDescription` in interface `ComparableOntology`
  Returns:
    the description.

### setDescription

    public void setDescription(String description)
                        throws ChangeVetoException

  Sets a human-readable description of this ontology.

  Specified by:
    `setDescription` in interface `ComparableOntology`
  Parameters:
    `description` - the description.
  Throws:
    `ChangeVetoException` - in case of problems.

### getName

    public String getName()

  Return the name of this ontology

  Specified by:
    `getName` in interface `Ontology`

### getOps

    public OntologyOps getOps()

  Return the associated OntologyOps.

  Specified by:
    `getOps` in interface `Ontology`
  Returns:
    the OntologyOps instance associated with this instance.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD