org.openanzo.owl.utils
Class OntologyDatasetUtils

java.lang.Object
  extended by org.openanzo.owl.utils.OntologyDatasetUtils

public class OntologyDatasetUtils
extends java.lang.Object

Utilities for operating on ontology data within a Dataset. Contains a cache of the classes Hierarchy.

Author:
Matthew Roy ( mroy@cambridgesemantics.com )

Constructor Summary
OntologyDatasetUtils()
          Create a new OntologyDataUtils
 
Method Summary
 java.util.List<_Property> findDeclaredProperties(Class clazz)
          Get the set of properties whose domain matches the class
 java.util.List<_Property> findDeclaredProperties(Class clazz, java.lang.String label)
          Get the set of properties whose domain matches the class and has an rdf:label that matches the provided label
 java.util.Set<Class> getAllClasses(IDataset dataset)
          Get all classes from a dataset
 java.util.Map<org.openrdf.model.Resource,org.openrdf.model.Resource> getAllClasses(IDataset dataset, org.openrdf.model.Resource clazzUri, boolean directlyAssertedOnly)
          Get all classes from the dataset with the given type
 java.util.Map<org.openrdf.model.Resource,org.openrdf.model.Resource> getAllClasses(IDataset dataset, java.lang.String label, boolean directlyAssertedOnly)
          Get all classes within a dataset whose label matches the provided label
 java.util.Map<org.openrdf.model.Resource,org.openrdf.model.Resource> getAllImplementors(IDataset dataset, Class clazz, boolean directlyAssertedOnly)
          Within an IDataset, retrieve all the individuals of the given class type
 java.util.Map<org.openrdf.model.Resource,org.openrdf.model.Resource> getAllImplementors(IDataset dataset, Class clazz, java.lang.String label, boolean directlyAssertedOnly)
          Get all things within a dataset that are of a given type and whose label matches the provided label
 java.util.Map<org.openrdf.model.Resource,org.openrdf.model.Resource> getAllImplementors(org.openrdf.model.URI namedGraphUri, IDataset dataset, java.lang.String label, boolean directlyAssertedOnly)
          Get all things within a dataset whose label matches the provided label
 java.util.Map<org.openrdf.model.Resource,org.openrdf.model.Resource> getAllImplementors2(IDataset dataset, Class clazz, boolean directlyAssertedOnly)
          Within an IDataset, retrieve all the individuals of the given class type.
 java.util.Collection<Individual> getAllIndividuals(IDataset dataset, Class clazz, boolean directlyAssertedOnly)
          Get all individuals that are of a given type
 java.util.Collection<Individual> getAllIndividuals(IDataset dataset, Class clazz, java.lang.String label, boolean directlyAssertedOnly)
          Get all individuals that are of a given type
 java.util.Collection<Individual> getAllIndividuals(IDataset dataset, org.openrdf.model.URI namedGraphUri, java.lang.String label, boolean directlyAssertedOnly)
          Get all individuals that are of a given type
 java.util.Map<org.openrdf.model.Resource,org.openrdf.model.Resource> getAllThings(IDataset dataset)
          Get all things within dataset, where a thing is something other than an ontology definition object.
 java.util.List<Class> getDomain(_Property property)
          Get the set of Classes that make up the Domain of a property
 java.util.List<Class> getRange(_Property property)
          Get the set of Classes that make up the Range of a property
 java.util.List<Class> getSubClasses(Class clazz, boolean adjacent, boolean directlyAssertedOnly)
          Get subclasses for a given Class.
 java.util.List<org.openrdf.model.Resource> getSubClasses(IDataset dataset, org.openrdf.model.Resource clazz, boolean directlyAssertedOnly)
          Get subclasses for a given Class
 java.util.List<org.openrdf.model.Resource> getSubClasses(IDataset dataset, org.openrdf.model.URI namedGraphUri, org.openrdf.model.Resource clazz, boolean directlyAssertedOnly)
          Get subclasses for a given Class
 java.util.List<_Property> getSubProperties(_Property property, boolean directlyAssertedOnly)
          Get all sub properties of the given property.
 java.util.List<Class> getSuperClasses(Class clazz, boolean directlyAssertedOnly)
          Get superclasses for a given Class
 java.util.List<Class> getSuperClasses(Class clazz, boolean adjacent, boolean directlyAssertedOnly)
          Get superclasses for a given Class.
 void registerDatasetListener(IDataset dataset)
          Register this OntologyDatasetUtils instance as a listener to a dataset's events.
 void registerOntologyChangeListener(IOntologyChangeListener listener)
          Register an ontology change listener
 void unregisterOntologyChangeListener(IOntologyChangeListener listener)
          Unregister an ontology change listener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OntologyDatasetUtils

public OntologyDatasetUtils()
Create a new OntologyDataUtils

Method Detail

registerOntologyChangeListener

public void registerOntologyChangeListener(IOntologyChangeListener listener)
Register an ontology change listener

Parameters:
listener - IOntologyChangeListener listener to register

unregisterOntologyChangeListener

public void unregisterOntologyChangeListener(IOntologyChangeListener listener)
Unregister an ontology change listener

Parameters:
listener - IOntologyChangeListener listener to unregister

registerDatasetListener

public void registerDatasetListener(IDataset dataset)
Register this OntologyDatasetUtils instance as a listener to a dataset's events. These events cause the class hierarchy cache to be updated, as well as notify listeners of ontology changes

Parameters:
dataset - dataset to which this class will register for events

getAllImplementors

public java.util.Map<org.openrdf.model.Resource,org.openrdf.model.Resource> getAllImplementors(IDataset dataset,
                                                                                               Class clazz,
                                                                                               boolean directlyAssertedOnly)
Within an IDataset, retrieve all the individuals of the given class type

Parameters:
dataset - dataset containing data
clazz - class for which whose type must match
directlyAssertedOnly - only include individuals that directly assert the class's type
Returns:
map of Resources for the individuals that match and the resource's NamedGraph

getAllImplementors2

public java.util.Map<org.openrdf.model.Resource,org.openrdf.model.Resource> getAllImplementors2(IDataset dataset,
                                                                                                Class clazz,
                                                                                                boolean directlyAssertedOnly)
Within an IDataset, retrieve all the individuals of the given class type. Uses Sparql queries to find results.

Parameters:
dataset - dataset containing data
clazz - class for which whose type must match
directlyAssertedOnly - only include individuals that directly assert the class's type
Returns:
map of Resources for the individuals that match and the resource's NamedGraph

getAllThings

public java.util.Map<org.openrdf.model.Resource,org.openrdf.model.Resource> getAllThings(IDataset dataset)
Get all things within dataset, where a thing is something other than an ontology definition object.

Parameters:
dataset - dataset containing data
Returns:
map of a Thing's Resource to its containing NamedGraph's URI

getAllImplementors

public java.util.Map<org.openrdf.model.Resource,org.openrdf.model.Resource> getAllImplementors(IDataset dataset,
                                                                                               Class clazz,
                                                                                               java.lang.String label,
                                                                                               boolean directlyAssertedOnly)
Get all things within a dataset that are of a given type and whose label matches the provided label

Parameters:
dataset - dataset containing data
clazz - type of things to look for
label - only return things that have an RDFS:Label with the given value
directlyAssertedOnly - only return things that directly assert the given class type
Returns:
map of a Thing's Resource to its containing NamedGraph's URI

getAllImplementors

public java.util.Map<org.openrdf.model.Resource,org.openrdf.model.Resource> getAllImplementors(org.openrdf.model.URI namedGraphUri,
                                                                                               IDataset dataset,
                                                                                               java.lang.String label,
                                                                                               boolean directlyAssertedOnly)
Get all things within a dataset whose label matches the provided label

Parameters:
namedGraphUri - URI of namedGraph where thing must reside
dataset - dataset containing data
label - only return things that have an RDFS:Label with the given value
directlyAssertedOnly - only return things that directly assert the given class type
Returns:
map of a Thing's Resource to its containing NamedGraph's URI

getAllClasses

public java.util.Map<org.openrdf.model.Resource,org.openrdf.model.Resource> getAllClasses(IDataset dataset,
                                                                                          java.lang.String label,
                                                                                          boolean directlyAssertedOnly)
Get all classes within a dataset whose label matches the provided label

Parameters:
dataset - dataset containing data
label - only return things that have an RDFS:Label with the given value
directlyAssertedOnly - only return things that directly assert the given class type
Returns:
map of a class's Resource to its containing NamedGraph's URI

getAllClasses

public java.util.Map<org.openrdf.model.Resource,org.openrdf.model.Resource> getAllClasses(IDataset dataset,
                                                                                          org.openrdf.model.Resource clazzUri,
                                                                                          boolean directlyAssertedOnly)
Get all classes from the dataset with the given type

Parameters:
dataset - dataset containing data
clazzUri - URI of classes to get
directlyAssertedOnly - only include classes that directly assert that they are of type Class
Returns:
map of a class's Resource to its containing NamedGraph's URI

getAllClasses

public java.util.Set<Class> getAllClasses(IDataset dataset)
Get all classes from a dataset

Parameters:
dataset - dataset containing data
Returns:
set of Classes from a dataset

getSubProperties

public java.util.List<_Property> getSubProperties(_Property property,
                                                  boolean directlyAssertedOnly)
Get all sub properties of the given property. Uses the property's dataset.

Parameters:
property - property for which to find sub properties
directlyAssertedOnly - only include properties that are directly asserted sub properties
Returns:
all sub properties of the given property

getAllIndividuals

public java.util.Collection<Individual> getAllIndividuals(IDataset dataset,
                                                          Class clazz,
                                                          boolean directlyAssertedOnly)
Get all individuals that are of a given type

Parameters:
dataset - dataset of data
clazz - class for which to find individuals
directlyAssertedOnly - only include individuals that directly asserted a type
Returns:
collection of individuals

getAllIndividuals

public java.util.Collection<Individual> getAllIndividuals(IDataset dataset,
                                                          org.openrdf.model.URI namedGraphUri,
                                                          java.lang.String label,
                                                          boolean directlyAssertedOnly)
Get all individuals that are of a given type

Parameters:
dataset - dataset of data
namedGraphUri - uri of graph where individuals reside
directlyAssertedOnly - only include individuals that directly asserted a type
label - value of rdf:label that must match
Returns:
collection of individuals

getAllIndividuals

public java.util.Collection<Individual> getAllIndividuals(IDataset dataset,
                                                          Class clazz,
                                                          java.lang.String label,
                                                          boolean directlyAssertedOnly)
Get all individuals that are of a given type

Parameters:
dataset - dataset of data
clazz - class for which to find individuals
label - value of rdf:label that must match
directlyAssertedOnly - only include individuals that directly asserted a type
Returns:
collection of individuals

getDomain

public java.util.List<Class> getDomain(_Property property)
Get the set of Classes that make up the Domain of a property

Parameters:
property - property of which to find the Domain classes
Returns:
set of Classes that make up the Domain of a property

findDeclaredProperties

public java.util.List<_Property> findDeclaredProperties(Class clazz)
                                                 throws JastorException
Get the set of properties whose domain matches the class

Parameters:
clazz - class for which to find properties
Returns:
the set of properties whose domain matches the class
Throws:
JastorException

findDeclaredProperties

public java.util.List<_Property> findDeclaredProperties(Class clazz,
                                                        java.lang.String label)
                                                 throws JastorException
Get the set of properties whose domain matches the class and has an rdf:label that matches the provided label

Parameters:
clazz - class for which to find properties
label - value of label to match
Returns:
the set of properties whose domain matches the class
Throws:
JastorException

getRange

public java.util.List<Class> getRange(_Property property)
Get the set of Classes that make up the Range of a property

Parameters:
property - property of which to find the Range classes
Returns:
set of Classes that make up the Range of a property

getSubClasses

public java.util.List<org.openrdf.model.Resource> getSubClasses(IDataset dataset,
                                                                org.openrdf.model.Resource clazz,
                                                                boolean directlyAssertedOnly)
Get subclasses for a given Class

Parameters:
dataset - dataset containing data
clazz - class of which to find subclasses
directlyAssertedOnly - only include classes that directly asserted subclasses
Returns:
set of subclasses for the Class

getSubClasses

public java.util.List<org.openrdf.model.Resource> getSubClasses(IDataset dataset,
                                                                org.openrdf.model.URI namedGraphUri,
                                                                org.openrdf.model.Resource clazz,
                                                                boolean directlyAssertedOnly)
Get subclasses for a given Class

Parameters:
dataset - dataset containing data
namedGraphUri - the URI of the namedgraph where to look first for sub classes
clazz - class of which to find subclasses
directlyAssertedOnly - only include classes that directly asserted subclasses
Returns:
set of subclasses for the Class

getSubClasses

public java.util.List<Class> getSubClasses(Class clazz,
                                           boolean adjacent,
                                           boolean directlyAssertedOnly)
Get subclasses for a given Class.
                        
                        Example:  (A->B denotes A is a superClass of B)
                                          ClassA -> ClassB 
                                          ClassB -> ClassC
                                          ClassA -> ClassC
                        if adjacent is true, subclasses of ClassA would be ClassB, but if false, it would be both ClassB and ClassC
                        
 
                        

Parameters:
clazz - class of which to find subclasses
adjacent - only include classes that are directly adjacent to their parent class. Filter out subclasses that have more than one path to the parent.
directlyAssertedOnly - only include classes that directly asserted subclasses
Returns:
set of subclasses for the Class

getSuperClasses

public java.util.List<Class> getSuperClasses(Class clazz,
                                             boolean directlyAssertedOnly)
Get superclasses for a given Class

Parameters:
clazz - class of which to find superclasses
directlyAssertedOnly - only include classes that directly asserted superclasses
Returns:
set of superclasses for the Class

getSuperClasses

public java.util.List<Class> getSuperClasses(Class clazz,
                                             boolean adjacent,
                                             boolean directlyAssertedOnly)
Get superclasses for a given Class.
                        
                        Example:  (A->B denotes A is a superClass of B)
                                          ClassA -> ClassB 
                                          ClassB -> ClassC
                                          ClassA -> ClassC
                        if adjacent is true, superclasses of ClassC would be ClassB, but if false, it would be both ClassA and ClassB
                        
 
                        

Parameters:
clazz - class of which to find superclasses
adjacent - only include classes that are directly adjacent to their child class. Filter out superclasses that have more than one path to the child.
directlyAssertedOnly - only include classes that directly asserted superclasses
Returns:
set of superclasses for the Class


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.