Package org.biojava.ontology
Class Ontology.Impl
- java.lang.Object
-
- org.biojava.utils.AbstractChangeable
-
- org.biojava.ontology.Ontology.Impl
-
- All Implemented Interfaces:
Serializable
,Ontology
,Changeable
- Enclosing interface:
- Ontology
public static final class Ontology.Impl extends AbstractChangeable implements Ontology, 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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsTerm(String name)
Determines if this ontology currently contains a term namedname
boolean
containsTriple(Term subject, Term object, Term predicate)
See if a triple exists in this ontologyOntologyTerm
createOntologyTerm(Ontology o)
Term
createTerm(String name)
Create a new term in this ontology.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.Variable
createVariable(String name, 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.String
getDescription()
Return a human-readable description of this ontology, or the empty string if none is availableString
getName()
Return the name of this ontologyOntologyOps
getOps()
Return the associated OntologyOps.Term
getTerm(String name)
Fetch the term with the specified name.Set<Term>
getTerms()
Return all the terms in this ontologySet<Triple>
getTriples(Term subject, Term object, Term predicate)
Return all triples from this ontology which match the supplied pattern.Term
importTerm(Term t, String name)
Create a view of a term from another ontology.void
setDescription(String description)
set the description of this ontologyvoid
setName(String name)
Set the name for this ontologyString
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
-
-
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:Ontology
Return the name of this ontology
-
getDescription
public 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 interfaceOntology
- Returns:
- the description of the term
-
setDescription
public void setDescription(String description)
Description copied from interface:Ontology
set the description of this ontology- Specified by:
setDescription
in interfaceOntology
-
getTerms
public Set<Term> getTerms()
Description copied from interface:Ontology
Return all the terms in this ontology
-
getTerm
public Term getTerm(String name) throws NoSuchElementException
Description copied from interface:Ontology
Fetch the term with the specified name.- Specified by:
getTerm
in interfaceOntology
- Parameters:
name
- the name of the term- Returns:
- The term named
name
- Throws:
NoSuchElementException
- if no term exists with that name
-
getTriples
public Set<Triple> 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 arenull
, they are treated as wildcards.- Specified by:
getTriples
in interfaceOntology
- Parameters:
subject
- The subject to search for, ornull
object
- The object to search for, ornull
predicate
- The relationship to search for, ornull
.- Returns:
- a Set of triples
-
createTerm
public Term createTerm(String name) throws AlreadyExistsException, IllegalArgumentException, ChangeVetoException
Description copied from interface:Ontology
Create a new term in this ontology.- Specified by:
createTerm
in interfaceOntology
- Parameters:
name
- The name of the term (must be unique))- Returns:
- The newly created term.
- Throws:
AlreadyExistsException
- if a term of this name already existsIllegalArgumentException
- if eithername
ordescription
isnull
, or violates some other constraint of this implementation.ChangeVetoException
-
createTerm
public Term createTerm(String name, String description) throws AlreadyExistsException, IllegalArgumentException, ChangeVetoException
Description copied from interface:Ontology
Create a new term in this ontology.- Specified by:
createTerm
in interfaceOntology
- 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 existsIllegalArgumentException
- if eithername
ordescription
isnull
, or violates some other constraint of this implementation.ChangeVetoException
-
createTerm
public Term createTerm(String name, String description, Object[] synonyms) throws AlreadyExistsException, IllegalArgumentException, ChangeVetoException
Description copied from interface:Ontology
Create a new term in this ontology.- Specified by:
createTerm
in interfaceOntology
- 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 existsIllegalArgumentException
- if eithername
ordescription
isnull
, or violates some other constraint of this implementation.ChangeVetoException
-
createVariable
public Variable createVariable(String name, String description) throws AlreadyExistsException, ChangeVetoException, IllegalArgumentException
Description copied from interface:Ontology
Create a new term in this ontology that is used as a variable.- Specified by:
createVariable
in interfaceOntology
- 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 existsChangeVetoException
IllegalArgumentException
- if eithername
ordescription
isnull
, or violates some other constraint of this implementation.
-
createOntologyTerm
public OntologyTerm createOntologyTerm(Ontology o) throws AlreadyExistsException, ChangeVetoException
-
importTerm
public Term importTerm(Term t, String name) throws 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 interfaceOntology
- Parameters:
t
- the Term to importname
- the local name to import it under, optionally null- Returns:
- a Term
- Throws:
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 interfaceOntology
- Throws:
ChangeVetoException
-
containsTerm
public boolean containsTerm(String name)
Description copied from interface:Ontology
Determines if this ontology currently contains a term namedname
- Specified by:
containsTerm
in interfaceOntology
- Returns:
- true is contained
-
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 interfaceOntology
- Returns:
- true if contained
-
createTriple
public Triple createTriple(Term subject, Term object, Term predicate, String name, String description) throws AlreadyExistsException, IllegalArgumentException, ChangeVetoException, NullPointerException, IllegalArgumentException
Description copied from interface:Ontology
Creates a new Triple.- Specified by:
createTriple
in interfaceOntology
- Parameters:
subject
- the subject Termobject
- the object Termpredicate
- the predicate Termname
- the name of the triple, or nulldescription
- 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 descriptionIllegalArgumentException
- if subject, object or predicate are not all from the same ontologyChangeVetoException
NullPointerException
- if subject, object or predicate are null
-
getOps
public OntologyOps getOps()
Description copied from interface:Ontology
Return the associated OntologyOps. This method should be implemented by ontology implementors to allow OntoTools to get optimized access to some usefull ontology operations. It is not intended that users will ever invoke this. A sensible dumb implementation of this would return a per-ontology instance of DefaultOps.
-
-