|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.biojava.utils.AbstractChangeable
org.biojavax.ontology.SimpleComparableOntology
public class SimpleComparableOntology
Represents an ontology that can be compared to other ontologies.
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)
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. 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 |
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. 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)
set the 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. 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 |
---|
public SimpleComparableOntology(String name)
name
- the name of the ontology.protected SimpleComparableOntology()
Method Detail |
---|
public int compareTo(Object o)
compareTo
in interface Comparable
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
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 term
name
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_a
public 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 exists
ChangeVetoException
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 null
ChangeVetoException
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 null
AlreadyExistsException
- if a triple already exists with the same
subject, object and predicate, regardless of the name and description
ChangeVetoException
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 exists
ChangeVetoException
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 exists
ChangeVetoException
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 exists
ChangeVetoException
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 String getName()
getName
in interface Ontology
public void setName(String name)
Ontology
setName
in interface Ontology
name
- - the namepublic OntologyOps getOps()
getOps
in interface Ontology
public Integer getId()
public void setId(Integer id)
id
- the Hibernate ID, if using Hibernate.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |