public class SimpleComparableOntology extends AbstractChangeable implements ComparableOntology
Ontology.Impl
DESCRIPTION, TERM, TRIPLE
Modifier | Constructor and Description |
---|---|
protected |
SimpleComparableOntology() |
|
SimpleComparableOntology(String name)
Creates a new instance of SimpleComparableOntology with the given,
immutable, non-nullable name.
|
Modifier and Type | Method and Description |
---|---|
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
|
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.
|
boolean |
equals(Object obj)
Ontologies are equal if their names are equal.
|
String |
getDescription()
Return a human-readable description of this ontology.
|
Integer |
getId()
Gets the Hibernate ID.
|
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.
|
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
|
Set |
getTermSet()
Returns the set of terms in this ontology.
|
Set |
getTriples(Term subject,
Term object,
Term predicate)
Return all triples from this ontology which match the supplied
pattern.
|
Set |
getTripleSet()
Returns the set of triples in this ontology.
|
int |
hashCode() |
Term |
importTerm(Term t,
String localName)
Create a view of a term from another ontology.
|
void |
setDescription(String description)
Sets a human-readable description of this ontology.
|
void |
setId(Integer id)
Sets the Hibernate ID.
|
void |
setName(String name)
Set the name for this ontology
|
void |
setTermSet(Set terms)
Clears out all the terms and populates the ontology with the contents
of the set passed.
|
void |
setTripleSet(Set triples)
Clears out all the triples and populates the ontology with the contents
of the set passed.
|
String |
toString()
Form: "name"
|
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
public SimpleComparableOntology(String name)
name
- the name of the ontology.protected SimpleComparableOntology()
public int compareTo(Object o)
compareTo
in interface Comparable
public boolean containsTerm(String name)
name
containsTerm
in interface Ontology
public Term getTerm(String s) throws NoSuchElementException
getTerm
in interface Ontology
s
- the name of the termname
NoSuchElementException
- if no term exists with that namepublic ComparableTerm getOrCreateTerm(String name)
getOrCreateTerm
in interface ComparableOntology
name
- the name of the term to look for.public ComparableTriple getOrCreateTriple(Term subject, Term object, Term predicate)
getOrCreateTriple
in interface ComparableOntology
subject
- the subject of the triple eg appleobject
- the object of the triple eg fruitpredicate
- the relationship of the triple eg is_apublic ComparableTerm getOrImportTerm(Term term)
getOrImportTerm
in interface ComparableOntology
term
- the term to look for.public Term createTerm(String name, String description, Object[] synonyms) throws AlreadyExistsException, ChangeVetoException, IllegalArgumentException
createTerm
in interface Ontology
name
- The name of the term (must be unique)description
- A human-readable description (may be empty)synonyms
- Some synonyms for this term.AlreadyExistsException
- if a term of this name already existsChangeVetoException
IllegalArgumentException
- if either name
or
description
is null
, or violates
some other constraint of this implementation.public Term importTerm(Term t, String localName) throws ChangeVetoException, IllegalArgumentException
importTerm
in interface Ontology
t
- the Term to importlocalName
- the local name to import it under, optionally nullChangeVetoException
IllegalArgumentException
ComparableTerm
public Triple createTriple(Term subject, Term object, Term predicate, String name, String description) throws AlreadyExistsException, ChangeVetoException
createTriple
in interface Ontology
subject
- the subject Termobject
- the object Termpredicate
- the predicate Termname
- the name of the triple, or nulldescription
- the description of the triple, or nullAlreadyExistsException
- if a triple already exists with the same
subject, object and predicate, regardless of the name and descriptionChangeVetoException
ComparableTerm
public void deleteTerm(Term t) throws ChangeVetoException
deleteTerm
in interface Ontology
ChangeVetoException
ComparableTerm
public Set getTriples(Term subject, Term object, Term predicate)
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.getTriples
in interface Ontology
subject
- The subject to search for, or null
object
- The object to search for, or null
predicate
- The relationship to search for, or null
.ComparableTerm
,
ComparableTriple
public void setTripleSet(Set triples) throws ChangeVetoException
setTripleSet
in interface ComparableOntology
triples
- the set of ComparableTriple objects this ontology should have.ChangeVetoException
- if any of them are unacceptable.ComparableTriple
public Set getTripleSet()
getTripleSet
in interface ComparableOntology
public Set getTerms()
getTerms
in interface Ontology
ComparableTerm
public void setTermSet(Set terms) throws ChangeVetoException
setTermSet
in interface ComparableOntology
terms
- a set of Term objects this ontology should have.ChangeVetoException
- if any of them are unacceptable.ComparableTerm
public Set getTermSet()
getTermSet
in interface ComparableOntology
ComparableTerm
public boolean containsTriple(Term subject, Term object, Term predicate)
containsTriple
in interface Ontology
ComparableTerm
,
ComparableTriple
public Term createTerm(String name) throws AlreadyExistsException, ChangeVetoException, IllegalArgumentException
createTerm
in interface Ontology
name
- The name of the term (must be unique))AlreadyExistsException
- if a term of this name already existsChangeVetoException
IllegalArgumentException
- if either name
or
description
is null
, or violates
some other constraint of this implementation.public Term createTerm(String name, String description) throws AlreadyExistsException, ChangeVetoException, IllegalArgumentException
createTerm
in interface Ontology
name
- The name of the term (must be unique)description
- A human-readable description (may be empty)AlreadyExistsException
- if a term of this name already existsChangeVetoException
IllegalArgumentException
- if either name
or
description
is null
, or violates
some other constraint of this implementation.public Variable createVariable(String name, String description) throws AlreadyExistsException, ChangeVetoException, IllegalArgumentException
createVariable
in interface Ontology
name
- The name of the term (must be unique)description
- A human-readable description (may be empty)AlreadyExistsException
- if a term of this name already existsChangeVetoException
IllegalArgumentException
- if either name
or
description
is null
, or violates
some other constraint of this implementation.public String getDescription()
getDescription
in interface Ontology
getDescription
in interface ComparableOntology
public void setDescription(String description) throws ChangeVetoException
setDescription
in interface Ontology
setDescription
in interface ComparableOntology
description
- the description.ChangeVetoException
- in case of problems.public void setName(String name)
Ontology
public OntologyOps getOps()
public Integer getId()
Copyright © 2014 BioJava. All rights reserved.