es.ucm.fdi.gaia.ontobridge
Class OntoBridge

java.lang.Object
  extended by es.ucm.fdi.gaia.ontobridge.OntoBridge

public class OntoBridge
extends java.lang.Object

Main OntoBridge Class
This class provides a simple wrapper for JENA.
It allows connecting to PELLET reasoner or any other that supports the DIG protocol. Instead of using JENA classes this class returns strings containing the URIs of the elements in the ontology. Input parameters of the methods use URIs (or the qualified short representation) for pointing to the ontology elements.
Conversion between URIs and JENA objects is managed automatically

Author:
Juan A. Recio García

Constructor Summary
OntoBridge()
          Creates an OntoBridge object.
 
Method Summary
 void createClass(java.lang.String className)
          Create a new class in the ontology.
 void createDataTypeProperty(java.lang.String sourceInstance, java.lang.String propertyName, java.lang.Object value)
          Creates an dataType property between two instances.
 void createDataTypeProperty(java.lang.String sourceInstance, java.lang.String propertyName, java.lang.String value, java.lang.String valueDataType)
          Creates an dataType property between two instances.
 void createInstance(java.lang.String className, java.lang.String instanceName)
          Creates a new instance of a class.
 void createOntProperty(java.lang.String sourceInstance, java.lang.String propertyName, java.lang.String destInstance)
          Creates an ontology property between two instances.
 boolean existsClass(java.lang.String name)
          Returns if a class exists
 boolean existsInstance(java.lang.String name)
          Returns if an instance exists
 boolean existsProperty(java.lang.String name)
          Returns if a property exists
 java.lang.String getShortName(java.lang.String URI)
          Returns the short form of an URI.
 java.lang.String getURI(java.lang.String shortName)
          Returns the long URI form of a short name
 void initWithDIGReasoner(java.lang.String reasonerHost, int reasonerPort)
          Inits the OntoBridge with a DIG reasoner.
 void initWithOutReasoner()
          Inits the OntoBridge without reasoner.
 void initWithPelletReasoner()
          Inits the OntoBridge with the PELLET Reasoner
 boolean isInstanceOf(java.lang.String instance, java.lang.String ontclass)
          Checks if an instance belongs to a class
 boolean isOntoProperty(java.lang.String property)
          Checks if a proporty is an OntologyProperty instead of a DataTypeProperty
 boolean isSubClassOf(java.lang.String subclass, java.lang.String superclass)
          Checks if a class is subclass of other
 java.util.Iterator<java.lang.String> listAllandAnonClasses()
          Lists all the classes of the ontology including anonymous classes
 java.util.Iterator<java.lang.String> listAllClasses()
          Lists all the no anonymous classes of the ontology
 java.util.Iterator<java.lang.String> listBelongingClasses(java.lang.String instance)
          Lists the classes that an instance belongs to
 java.util.Iterator<java.lang.String> listComplementClasses()
          Lists the complement classes of the ontology
 java.util.Iterator<java.lang.String> listDeclaredInstances(java.lang.String ontClass)
          List the declared (not inferred) instances of a class
 java.util.Iterator<java.lang.String> listEnumeratedClasses()
          Lists the enumerated classes of the ontology
 java.util.Iterator<java.lang.String> listInstanceProperties(java.lang.String instance)
          Lists the properties of an instance
 void listInstancePropertiesValues(java.lang.String instance, java.util.List<java.lang.String> properties, java.util.List<java.lang.String> values)
          Returns the properties with their corresponding values of an instance.
 java.util.Iterator<java.lang.String> listInstances(java.lang.String ontClass)
          List the instances of a class
 java.util.Iterator<java.lang.String> listIntersectionClasses()
          Lists the intersection classes of the ontology
 java.util.Iterator<java.lang.String> listProperties(java.lang.String ontClass)
          Lists the properties applicable to a class
 java.util.Iterator<java.lang.String> listPropertyRange(java.lang.String property)
          Lists the classes on the range of a property
 java.util.Iterator<java.lang.String> listPropertyValue(java.lang.String instance, java.lang.String property)
          Lists the instances that are the values of a property of an instance.
 java.util.Iterator<java.lang.String> listRestrictions()
          Lists the restrictions of the ontology
 java.util.Iterator<java.lang.String> listRootClasses()
          Lists the hierarchy root classes of the ontology
 java.util.Iterator<java.lang.String> listSpecificProperties(java.lang.String ontClass)
          Lists the specific properties of class.
 java.util.Iterator<java.lang.String> listSubClasses(java.lang.String ontClass, boolean direct)
          Lists the subclasses of a class.
 java.util.Iterator<java.lang.String> listSuperClasses(java.lang.String ontClass, boolean direct)
          Lists the superclasses (parents) of a class.
 java.util.Iterator<java.lang.String> listUnionClasses()
          Lists the union classes of the ontology
 void loadOntology(OntologyDocument mainOntology, java.util.Collection<OntologyDocument> subOntologies, boolean loadSubOntologies)
          Loads an ontology using the initialized reasoner
 void save(java.lang.String fileName)
          Saves the ontology (without imported ontologies data) into a file.
 void setSubClass(java.lang.String subClass, java.lang.String superClass)
          Sets a class as subclass of other.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OntoBridge

public OntoBridge()
Creates an OntoBridge object. Currentlly it does nothing.

Method Detail

initWithPelletReasoner

public void initWithPelletReasoner()
Inits the OntoBridge with the PELLET Reasoner


initWithDIGReasoner

public void initWithDIGReasoner(java.lang.String reasonerHost,
                                int reasonerPort)
Inits the OntoBridge with a DIG reasoner. Dig is a protocol (working over http) that allows conecting with any reasoner.

Parameters:
reasonerHost - Host where the reasoner is running.
reasonerPort - Port that the reasoner listens to.

initWithOutReasoner

public void initWithOutReasoner()
Inits the OntoBridge without reasoner. That way, this class doesn't use any inferred knowledge of the ontology


loadOntology

public void loadOntology(OntologyDocument mainOntology,
                         java.util.Collection<OntologyDocument> subOntologies,
                         boolean loadSubOntologies)
Loads an ontology using the initialized reasoner

Parameters:
mainOntology - Main ontology document
subOntologies - Collection of ontology documents used by the main ontology
loadSubOntologies - Indicates if the reasoner must load the subOntologies. If loaded, their content is included in the reasoning graph of the main ontology graph.

listAllClasses

public java.util.Iterator<java.lang.String> listAllClasses()
Lists all the no anonymous classes of the ontology


listAllandAnonClasses

public java.util.Iterator<java.lang.String> listAllandAnonClasses()
Lists all the classes of the ontology including anonymous classes


listEnumeratedClasses

public java.util.Iterator<java.lang.String> listEnumeratedClasses()
Lists the enumerated classes of the ontology


listUnionClasses

public java.util.Iterator<java.lang.String> listUnionClasses()
Lists the union classes of the ontology


listComplementClasses

public java.util.Iterator<java.lang.String> listComplementClasses()
Lists the complement classes of the ontology


listIntersectionClasses

public java.util.Iterator<java.lang.String> listIntersectionClasses()
Lists the intersection classes of the ontology


listRestrictions

public java.util.Iterator<java.lang.String> listRestrictions()
Lists the restrictions of the ontology


listRootClasses

public java.util.Iterator<java.lang.String> listRootClasses()
Lists the hierarchy root classes of the ontology


listSubClasses

public java.util.Iterator<java.lang.String> listSubClasses(java.lang.String ontClass,
                                                           boolean direct)
Lists the subclasses of a class.

Parameters:
ontClass - class parent of the classes user is asking for
direct - return only direct subclasses

listSuperClasses

public java.util.Iterator<java.lang.String> listSuperClasses(java.lang.String ontClass,
                                                             boolean direct)
Lists the superclasses (parents) of a class.

Parameters:
ontClass - subclass of the classes user is asking for
direct - return only direct subclasses

listInstances

public java.util.Iterator<java.lang.String> listInstances(java.lang.String ontClass)
List the instances of a class

Parameters:
ontClass - class that instances belong to

listDeclaredInstances

public java.util.Iterator<java.lang.String> listDeclaredInstances(java.lang.String ontClass)
List the declared (not inferred) instances of a class

Parameters:
ontClass - class that instances belong to

listBelongingClasses

public java.util.Iterator<java.lang.String> listBelongingClasses(java.lang.String instance)
Lists the classes that an instance belongs to

Parameters:
instance - instance asked for belonging classes

isSubClassOf

public boolean isSubClassOf(java.lang.String subclass,
                            java.lang.String superclass)
Checks if a class is subclass of other

Parameters:
subclass - subclasss
superclass - superclass

isInstanceOf

public boolean isInstanceOf(java.lang.String instance,
                            java.lang.String ontclass)
Checks if an instance belongs to a class

Parameters:
instance - instance
ontclass - class

isOntoProperty

public boolean isOntoProperty(java.lang.String property)
Checks if a proporty is an OntologyProperty instead of a DataTypeProperty

Parameters:
property -
Returns:

listProperties

public java.util.Iterator<java.lang.String> listProperties(java.lang.String ontClass)
Lists the properties applicable to a class

Parameters:
ontClass - class in the domain of the listed properties

listSpecificProperties

public java.util.Iterator<java.lang.String> listSpecificProperties(java.lang.String ontClass)
Lists the specific properties of class. This method only returns the properties that has the specified class in the domain

Parameters:
ontClass - class in the domain of the listed properties

listPropertyRange

public java.util.Iterator<java.lang.String> listPropertyRange(java.lang.String property)
Lists the classes on the range of a property

Parameters:
property - property user is asking for its range

listPropertyValue

public java.util.Iterator<java.lang.String> listPropertyValue(java.lang.String instance,
                                                              java.lang.String property)
Lists the instances that are the values of a property of an instance.

Parameters:
instance - instance origin of the property
property - property

listInstanceProperties

public java.util.Iterator<java.lang.String> listInstanceProperties(java.lang.String instance)
Lists the properties of an instance

Parameters:
instance - source of the properties

listInstancePropertiesValues

public void listInstancePropertiesValues(java.lang.String instance,
                                         java.util.List<java.lang.String> properties,
                                         java.util.List<java.lang.String> values)
Returns the properties with their corresponding values of an instance. The properties and values parameter are cleared. They are used to return the properties and values. property[i] has value values[i].

Parameters:
instance - source of the properties
properties - Array containing the name of the properties
values - Array containing the value of the property

getShortName

public java.lang.String getShortName(java.lang.String URI)
Returns the short form of an URI.


getURI

public java.lang.String getURI(java.lang.String shortName)
Returns the long URI form of a short name


existsClass

public boolean existsClass(java.lang.String name)
Returns if a class exists


existsProperty

public boolean existsProperty(java.lang.String name)
Returns if a property exists


existsInstance

public boolean existsInstance(java.lang.String name)
Returns if an instance exists


createClass

public void createClass(java.lang.String className)
Create a new class in the ontology. The className must not exist.

Parameters:
className - Class to create

setSubClass

public void setSubClass(java.lang.String subClass,
                        java.lang.String superClass)
Sets a class as subclass of other.

Parameters:
subClass -
superClass -

createInstance

public void createInstance(java.lang.String className,
                           java.lang.String instanceName)
Creates a new instance of a class. The class must exist but the instance must not.

Parameters:
className -
instanceName -

createOntProperty

public void createOntProperty(java.lang.String sourceInstance,
                              java.lang.String propertyName,
                              java.lang.String destInstance)
Creates an ontology property between two instances. An ontology property ranges over instances.

Parameters:
sourceInstance -
propertyName -
destInstance -

createDataTypeProperty

public void createDataTypeProperty(java.lang.String sourceInstance,
                                   java.lang.String propertyName,
                                   java.lang.Object value)
Creates an dataType property between two instances. An ontology property ranges over XML-Schema datatypes. The method tries to find the proper datatype for the value object. (If this fails use the explicit datatyped method).

Parameters:
sourceInstance -
propertyName -
value - The value of the property. The method tries to find the proper datatype for this object.

createDataTypeProperty

public void createDataTypeProperty(java.lang.String sourceInstance,
                                   java.lang.String propertyName,
                                   java.lang.String value,
                                   java.lang.String valueDataType)
Creates an dataType property between two instances. An ontology property ranges over XML-Schema datatypes. The datatype of the value is explicitely defined.

Parameters:
sourceInstance -
propertyName -
value - The value of the property.
valueDataType - DataType of the value

save

public void save(java.lang.String fileName)
Saves the ontology (without imported ontologies data) into a file.

Parameters:
fileName - file path for saving the ontology