GATE
Version 3.1-2270

com.ontotext.gate.ontology
Class OntologyImpl

java.lang.Object
  extended by gate.util.AbstractFeatureBearer
      extended by gate.creole.AbstractResource
          extended by gate.creole.AbstractLanguageResource
              extended by com.ontotext.gate.ontology.TaxonomyImpl
                  extended by com.ontotext.gate.ontology.OntologyImpl
All Implemented Interfaces:
Ontology, Taxonomy, LanguageResource, Resource, FeatureBearer, NameBearer, Serializable
Direct Known Subclasses:
JenaOntologyImpl

public class OntologyImpl
extends TaxonomyImpl
implements Ontology

An Ontology Implementation Class

Author:
borislav popov, Kalina Bontcheva, Valentin Tablan
See Also:
Serialized Form

Field Summary
protected  Set instances
           
protected  Map instancesByName
           
protected  Set propertyDefinitionSet
           
 
Fields inherited from class com.ontotext.gate.ontology.TaxonomyImpl
DIRECT_CLOSURE, lastGeneratedId, modified, nullBuffers, TRANSITIVE_CLOSURE
 
Fields inherited from class gate.creole.AbstractLanguageResource
dataStore, lrPersistentId
 
Fields inherited from class gate.util.AbstractFeatureBearer
features
 
Constructor Summary
OntologyImpl()
           
 
Method Summary
 DatatypeProperty addDatatypeProperty(String name, String comment, OClass domain, Class range)
          Creates a new Datatype property in this ontology where the domain consists of a single OClass.
 DatatypeProperty addDatatypeProperty(String name, String comment, Set domain, Class range)
          Create a DatatypeProperty with the given domain and range.
 void addInstance(OInstance theInstance)
          Adds a preconstructed instance to the ontology.
 OInstance addInstance(String name, OClass theClass)
          Adds an instance to the ontology.
 ObjectProperty addObjectProperty(String name, String comment, OClass domain, OClass range)
          Creates a new object property (a property that takes instances as values).
 ObjectProperty addObjectProperty(String name, String comment, Set domain, Set range)
          Creates a new object property (a property that takes instances as values).
 Property addProperty(String name, String comment, OClass domain, Class range)
          Creates a new generic property that is neither datatype or object property.
 Property addProperty(String name, String comment, Set domain, Set range)
          Creates a new generic property that is neither datatype or object property.
protected  void addPropertyDefinition(Property theProperty)
           
 SymmetricProperty addSymmetricProperty(String name, String comment, OClass domain, OClass range)
          Creates a new symmetric property.
 SymmetricProperty addSymmetricProperty(String name, String comment, Set domain, Set range)
          Creates a new symmetric property (an object property that is symmetric).
 TransitiveProperty addTransitiveProperty(String name, String comment, OClass domain, OClass range)
          Creates a new transitive property.
 TransitiveProperty addTransitiveProperty(String name, String comment, Set domain, Set range)
          Creates a new transitive property (an object property that is transitive).
 TClass createClass(String aName, String aComment)
          Creates a new OClass and returns it.
 Set getDirectInstances(OClass aClass)
          Gets all instances in the ontology, which belong to the given class only.
 OInstance getInstanceByName(String aName)
          Gets the instance with the given name.
 Set getInstances()
          Gets all instances in the ontology.
 Set getInstances(OClass aClass)
          Gets all instances in the ontology, which belong to this class, including instances of sub-classes.
 Property getPropertyDefinitionByName(String name)
          Returns the property definition for a given property.
 Set getPropertyDefinitions()
          Gets the set of all known property definitions in this ontology.
static void reduceToMostSpecificClasses(Set classSet)
          Eliminates the more general classes from a set, keeping only the most specific ones.
 void removeInstance(OInstance theInstance)
          Removes the instance from the ontology.
 
Methods inherited from class com.ontotext.gate.ontology.TaxonomyImpl
addClass, addObjectModificationListener, containsClassByName, equals, fireObjectModificationEvent, getClassByName, getClasses, getClasses, getComment, getDefaultNameSpace, getId, getLabel, getOntology, getTaxonomicDistance, getTopClasses, getURL, getVersion, init, isDirectSubClassOf, isModified, isSubClassOf, load, reinfer, removeClass, setComment, setDefaultNameSpace, setId, setLabel, setModified, setURL, setVersion, store, toString
 
Methods inherited from class gate.creole.AbstractLanguageResource
cleanup, getDataStore, getLRPersistenceId, getParent, setDataStore, setLRPersistenceId, setParent, sync
 
Methods inherited from class gate.creole.AbstractResource
checkParameterValues, getBeanInfo, getName, getParameterValue, getParameterValue, removeResourceListeners, setName, setParameterValue, setParameterValue, setParameterValues, setParameterValues, setResourceListeners
 
Methods inherited from class gate.util.AbstractFeatureBearer
getFeatures, setFeatures
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gate.creole.ontology.Taxonomy
addClass, containsClassByName, equals, getClassByName, getClasses, getClasses, getComment, getDefaultNameSpace, getId, getLabel, getTaxonomicDistance, getTopClasses, getURL, getVersion, isDirectSubClassOf, isModified, isSubClassOf, load, removeClass, setComment, setDefaultNameSpace, setId, setLabel, setModified, setURL, setVersion, store
 
Methods inherited from interface gate.LanguageResource
getDataStore, getLRPersistenceId, getParent, setDataStore, setLRPersistenceId, setParent, sync
 
Methods inherited from interface gate.Resource
cleanup, getParameterValue, init, setParameterValue, setParameterValues
 
Methods inherited from interface gate.util.FeatureBearer
getFeatures, setFeatures
 
Methods inherited from interface gate.util.NameBearer
getName, setName
 

Field Detail

instancesByName

protected Map instancesByName

instances

protected Set instances

propertyDefinitionSet

protected Set propertyDefinitionSet
Constructor Detail

OntologyImpl

public OntologyImpl()
Method Detail

addInstance

public OInstance addInstance(String name,
                             OClass theClass)
Description copied from interface: Ontology
Adds an instance to the ontology.

Specified by:
addInstance in interface Ontology
Parameters:
name - the name for the new instance
theClass - the class to which the instance belongs
Returns:
the OInstance that has been added to the ontology

addInstance

public void addInstance(OInstance theInstance)
Description copied from interface: Ontology
Adds a preconstructed instance to the ontology.

Specified by:
addInstance in interface Ontology

removeInstance

public void removeInstance(OInstance theInstance)
Description copied from interface: Ontology
Removes the instance from the ontology.

Specified by:
removeInstance in interface Ontology
Parameters:
theInstance - to be removed

getInstances

public Set getInstances()
Description copied from interface: Ontology
Gets all instances in the ontology.

Specified by:
getInstances in interface Ontology
Returns:
a Set of OInstance objects

getInstances

public Set getInstances(OClass aClass)
Description copied from interface: Ontology
Gets all instances in the ontology, which belong to this class, including instances of sub-classes. If only the instances of the given class are needed, then use getDirectInstances.

Specified by:
getInstances in interface Ontology
Parameters:
aClass - the class of the instances
Returns:
Set of OInstance objects

getDirectInstances

public Set getDirectInstances(OClass aClass)
Description copied from interface: Ontology
Gets all instances in the ontology, which belong to the given class only.

Specified by:
getDirectInstances in interface Ontology
Parameters:
aClass - the class of the instances
Returns:
Set of OInstance objects

getInstanceByName

public OInstance getInstanceByName(String aName)
Description copied from interface: Ontology
Gets the instance with the given name.

Specified by:
getInstanceByName in interface Ontology
Parameters:
aName - the instance name
Returns:
the OInstance object with this name

createClass

public TClass createClass(String aName,
                          String aComment)
Description copied from interface: Taxonomy
Creates a new OClass and returns it.

Specified by:
createClass in interface Taxonomy
Overrides:
createClass in class TaxonomyImpl
Parameters:
aName - the name of this class
aComment - the comment of this class
Returns:
the newly created class

addDatatypeProperty

public DatatypeProperty addDatatypeProperty(String name,
                                            String comment,
                                            Set domain,
                                            Class range)
Description copied from interface: Ontology
Create a DatatypeProperty with the given domain and range.

Specified by:
addDatatypeProperty in interface Ontology
Parameters:
name - the name for the new property.
comment - the comment for the new property.
domain - the set of ontology classes (i.e. OClass objects} that constitutes the range for the new property. The property only applies to instances that belong to all classes included in its domain. An empty set means that the property applies to instances of any class.
range - the Class specifying the types of Java objects that this property has as values.
Returns:
the newly created property.

addDatatypeProperty

public DatatypeProperty addDatatypeProperty(String name,
                                            String comment,
                                            OClass domain,
                                            Class range)
Description copied from interface: Ontology
Creates a new Datatype property in this ontology where the domain consists of a single OClass.

Specified by:
addDatatypeProperty in interface Ontology
Parameters:
name - the name for the new property.
comment - the comment for the new property.
domain - the OClass to which this property applies.
range - the Class specifying the types of Java objects that this property has as values.
Returns:
the newly created property.

addProperty

public Property addProperty(String name,
                            String comment,
                            Set domain,
                            Set range)
Description copied from interface: Ontology
Creates a new generic property that is neither datatype or object property. This can be for instance a RDF property.

Specified by:
addProperty in interface Ontology
Parameters:
name - the name for the new property.
comment - the comment for the new property.
domain - the set of ontology classes (i.e. OClass objects} that constitutes the range for the new property. The property only applies to instances that belong to all classes included in its domain. An empty set means that the property applies to instances of any class.
range - the set of ontology classes (i.e. OClass objects} that constitutes the range for the new property.
Returns:
the newly created property.

addProperty

public Property addProperty(String name,
                            String comment,
                            OClass domain,
                            Class range)
Description copied from interface: Ontology
Creates a new generic property that is neither datatype or object property. This can be for instance a RDF property.

Specified by:
addProperty in interface Ontology
Parameters:
name - the name for the new property.
comment - the comment for the new property.
domain - the OClass defining the type of instances this property can apply to.
range - Java Class defining the type of values this proeprty can take.
Returns:
the newly created property.

addObjectProperty

public ObjectProperty addObjectProperty(String name,
                                        String comment,
                                        Set domain,
                                        Set range)
Description copied from interface: Ontology
Creates a new object property (a property that takes instances as values).

Specified by:
addObjectProperty in interface Ontology
Parameters:
name - the name for the new property.
comment - the comment for the new property.
domain - the set of ontology classes (i.e. OClass objects} that constitutes the range for the new property. The property only applies to instances that belong to all classes included in its domain. An empty set means that the property applies to instances of any class.
range - the set of ontology classes (i.e. OClass objects} that constitutes the range for the new property.
Returns:
the newly created property.

addObjectProperty

public ObjectProperty addObjectProperty(String name,
                                        String comment,
                                        OClass domain,
                                        OClass range)
Description copied from interface: Ontology
Creates a new object property (a property that takes instances as values).

Specified by:
addObjectProperty in interface Ontology
Parameters:
name - the name for the new property.
comment - the comment for the new property.
domain - the OClass to which this property applies.
range - the OClass specifying the types of instances that this property can take as values.
Returns:
the newly created property.

addSymmetricProperty

public SymmetricProperty addSymmetricProperty(String name,
                                              String comment,
                                              Set domain,
                                              Set range)
Description copied from interface: Ontology
Creates a new symmetric property (an object property that is symmetric).

Specified by:
addSymmetricProperty in interface Ontology
Parameters:
name - the name for the new property.
comment - the comment for the new property.
domain - the set of ontology classes (i.e. OClass objects} that constitutes the range for the new property. The property only applies to instances that belong to all classes included in its domain. An empty set means that the property applies to instances of any class.
range - the set of ontology classes (i.e. OClass objects} that constitutes the range for the new property.
Returns:
the newly created property.

addSymmetricProperty

public SymmetricProperty addSymmetricProperty(String name,
                                              String comment,
                                              OClass domain,
                                              OClass range)
Description copied from interface: Ontology
Creates a new symmetric property.

Specified by:
addSymmetricProperty in interface Ontology
Parameters:
name - the name for the new property.
comment - the comment for the new property.
domain - the OClass to which this property applies.
range - the OClass specifying the types of instances that this property can take as values.
Returns:
the newly created property.

addTransitiveProperty

public TransitiveProperty addTransitiveProperty(String name,
                                                String comment,
                                                Set domain,
                                                Set range)
Description copied from interface: Ontology
Creates a new transitive property (an object property that is transitive).

Specified by:
addTransitiveProperty in interface Ontology
Parameters:
name - the name for the new property.
comment - the comment for the new property.
domain - the set of ontology classes (i.e. OClass objects} that constitutes the range for the new property. The property only applies to instances that belong to all classes included in its domain. An empty set means that the property applies to instances of any class.
range - the set of ontology classes (i.e. OClass objects} that constitutes the range for the new property.
Returns:
the newly created property.

addTransitiveProperty

public TransitiveProperty addTransitiveProperty(String name,
                                                String comment,
                                                OClass domain,
                                                OClass range)
Description copied from interface: Ontology
Creates a new transitive property.

Specified by:
addTransitiveProperty in interface Ontology
Parameters:
name - the name for the new property.
comment - the comment for the new property.
domain - the OClass to which this property applies.
range - the OClass specifying the types of instances that this property can take as values.
Returns:
the newly created property.

addPropertyDefinition

protected void addPropertyDefinition(Property theProperty)

getPropertyDefinitions

public Set getPropertyDefinitions()
Description copied from interface: Ontology
Gets the set of all known property definitions in this ontology.

Specified by:
getPropertyDefinitions in interface Ontology
Returns:
a Set of Property objects.

getPropertyDefinitionByName

public Property getPropertyDefinitionByName(String name)
Description copied from interface: Ontology
Returns the property definition for a given property.

Specified by:
getPropertyDefinitionByName in interface Ontology
Parameters:
name - the name for which the definition is sought.
Returns:
aProperty object.

reduceToMostSpecificClasses

public static void reduceToMostSpecificClasses(Set classSet)
Eliminates the more general classes from a set, keeping only the most specific ones. The changes are made to the set provided as a parameter. This is a utility method for ontologies.

Parameters:
classSet - a set of OClass objects.

GATE
Version 3.1-2270