org.biojava.ontology
Class Ontology.Impl

java.lang.Object
  extended by org.biojava.utils.AbstractChangeable
      extended by org.biojava.ontology.Ontology.Impl
All Implemented Interfaces:
java.io.Serializable, Ontology, Changeable
Enclosing interface:
Ontology

public static final class Ontology.Impl
extends AbstractChangeable
implements Ontology, java.io.Serializable

A basic in-memory implementation of an ontology

Since:
1.3
Author:
Thomas Down, Matthew Pocock
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.biojava.ontology.Ontology
Ontology.Impl
 
Field Summary
 
Fields inherited from interface org.biojava.ontology.Ontology
TERM, TRIPLE
 
Constructor Summary
Ontology.Impl(java.lang.String name, java.lang.String description)
           
 
Method Summary
 boolean containsTerm(java.lang.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
 OntologyTerm createOntologyTerm(Ontology o)
           
 Term createTerm(java.lang.String name, java.lang.String description)
          Create a new term in this ontology.
 Term createTerm(java.lang.String name, java.lang.String description, java.lang.Object[] synonyms)
          Create a new term in this ontology.
 Triple createTriple(Term subject, Term object, Term predicate, java.lang.String name, java.lang.String description)
          Creates a new Triple.
 Variable createVariable(java.lang.String name, java.lang.String description)
          Create a new term in this ontology that is used as a variable.
 void deleteTerm(Term t)
          Remove a term from an ontology, together with all triples which refer to it.
 java.lang.String getDescription()
          Return a human-readable description of this ontology, or the empty string if none is available
 java.lang.String getName()
          Return the name of this ontology
 OntologyOps getOps()
          Return the associated OntologyOps.
 Term getTerm(java.lang.String name)
          Fetch the term with the specified name.
 java.util.Set getTerms()
          Return all the terms in this ontology
 java.util.Set getTriples(Term subject, Term object, Term predicate)
          Return all triples from this ontology which match the supplied pattern.
 Term importTerm(Term t, java.lang.String name)
          Create a view of a term from another ontology.
 java.lang.String toString()
           
 
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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
 

Constructor Detail

Ontology.Impl

public Ontology.Impl(java.lang.String name,
                     java.lang.String description)
Method Detail

getName

public java.lang.String getName()
Description copied from interface: Ontology
Return the name of this ontology

Specified by:
getName in interface Ontology

getDescription

public java.lang.String getDescription()
Description copied from interface: Ontology
Return a human-readable description of this ontology, or the empty string if none is available

Specified by:
getDescription in interface Ontology

getTerms

public java.util.Set getTerms()
Description copied from interface: Ontology
Return all the terms in this ontology

Specified by:
getTerms in interface Ontology

getTerm

public Term getTerm(java.lang.String name)
             throws java.util.NoSuchElementException
Description copied from interface: Ontology
Fetch the term with the specified name.

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

getTriples

public java.util.Set getTriples(Term subject,
                                Term object,
                                Term predicate)
Description copied from interface: Ontology
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.

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.

createTerm

public Term createTerm(java.lang.String name,
                       java.lang.String description)
                throws AlreadyExistsException,
                       java.lang.IllegalArgumentException,
                       ChangeVetoException
Description copied from interface: Ontology
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
java.lang.IllegalArgumentException - if either name or description is null, or violates some other constraint of this implementation.
ChangeVetoException

createTerm

public Term createTerm(java.lang.String name,
                       java.lang.String description,
                       java.lang.Object[] synonyms)
                throws AlreadyExistsException,
                       java.lang.IllegalArgumentException,
                       ChangeVetoException
Description copied from interface: Ontology
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
java.lang.IllegalArgumentException - if either name or description is null, or violates some other constraint of this implementation.
ChangeVetoException

createVariable

public Variable createVariable(java.lang.String name,
                               java.lang.String description)
                        throws AlreadyExistsException,
                               ChangeVetoException,
                               java.lang.IllegalArgumentException
Description copied from interface: Ontology
Create a new term in this ontology that is used as a variable.

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
java.lang.IllegalArgumentException - if either name or description is null, or violates some other constraint of this implementation.
ChangeVetoException

createOntologyTerm

public OntologyTerm createOntologyTerm(Ontology o)
                                throws AlreadyExistsException,
                                       ChangeVetoException
Throws:
AlreadyExistsException
ChangeVetoException

importTerm

public Term importTerm(Term t,
                       java.lang.String name)
                throws java.lang.IllegalArgumentException,
                       ChangeVetoException
Description copied from interface: Ontology
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.

Specified by:
importTerm in interface Ontology
Parameters:
t - the Term to import
name - the local name to import it under, optionally null
Throws:
java.lang.IllegalArgumentException
ChangeVetoException

deleteTerm

public void deleteTerm(Term t)
                throws ChangeVetoException
Description copied from interface: Ontology
Remove a term from an ontology, together with all triples which refer to it.

Specified by:
deleteTerm in interface Ontology
Throws:
ChangeVetoException

containsTerm

public boolean containsTerm(java.lang.String name)
Description copied from interface: Ontology
Determines if this ontology currently contains a term named name

Specified by:
containsTerm in interface Ontology

containsTriple

public boolean containsTriple(Term subject,
                              Term object,
                              Term predicate)
Description copied from interface: Ontology
See if a triple exists in this ontology

Specified by:
containsTriple in interface Ontology

createTriple

public Triple createTriple(Term subject,
                           Term object,
                           Term predicate,
                           java.lang.String name,
                           java.lang.String description)
                    throws AlreadyExistsException,
                           java.lang.IllegalArgumentException,
                           ChangeVetoException,
                           java.lang.NullPointerException,
                           java.lang.IllegalArgumentException
Description copied from interface: Ontology
Creates a new Triple.

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
java.lang.IllegalArgumentException - if subject, object or predicate are not all from the same ontology
ChangeVetoException
java.lang.NullPointerException - if subject, object or predicate are null

getOps

public OntologyOps getOps()
Description copied from interface: Ontology
Return the associated OntologyOps.

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object