Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.hp.hpl.jena.ontology
Class OntTools

    java.lang.Object
      com.hp.hpl.jena.ontology.OntTools

    public class OntTools

extends java.lang.Object

Some general utilities and algorithms to support developers working with the general classes in the Jena ontology API. Warning these utilities are experimental. Extensive testing has not yet occurred (see `TestOntTools` for basic unit tests), and in particular performance testing has not been carried out yet. Users are advised to exercise caution before relying on these utilities in production code. Please send any comments or suggestions to the Jena support email list.

Author:
  Ian Dickinson, HP Labs (email)

Nested Class Summary
`static class` | `OntTools.DisjointSet` A simple representation of disjoint sets
`static class` | `OntTools.LCAIndex` Simple data structure mapping RDF nodes to disjoint sets, and pairs of resources to their LCA.
`static class` | `OntTools.Path` A path is an application of `List` containing only `Statement` objects, and in which for all adjacent elements `Si-1` and `Si`, where `i > 0`, it is true that: `Si-1.getObject().equals( Si.getSubject() )`
`static class` | `OntTools.PredicatesFilter` A filter which accepts statements whose predicate matches one of a collection of predicates held by the filter object.

Constructor Summary
`OntTools()`

Method Summary
`static OntTools.Path` | `findShortestPath(Model m, Resource start, RDFNode end, Filter onPath)` Answer the shortest path from the `start` resource to the `end` RDF node, such that every step on the path is accepted by the given filter.
`static OntClass` | `getLCA(OntModel m, OntClass u, OntClass v)` Answer the lowest common ancestor of two classes in a given ontology.
`static OntClass` | `getLCA(OntModel m, OntClass root, OntClass u, OntClass v)` Answer the lowest common ancestor of two classes, assuming that the given class is the root concept to start searching from.
`static java.util.List` | `namedHierarchyRoots(OntModel m)` Answer a list of the named hierarchy roots of a given `OntModel`.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### OntTools

    public OntTools()

Method Detail

### getLCA

    public static OntClass getLCA(OntModel m,
                                  OntClass u,
                                  OntClass v)

  Answer the lowest common ancestor of two classes in a given ontology. This is the class that is farthest from the root concept (defaulting to `owl:Thing` which is a super-class of both `u` and `v`. The algorithm is based on Tarjan's off-line LCA. The current implementation expects that the given model:

  - is transitively closed over the `subClassOf` relation
  - can cheaply determine direct sub-class relations

  Both of these conditions are true of the built-in Jena OWL reasoners, such as `OntModelSpec.OWL_MEM_MICRO_RULE_INF`, and external DL reasoners such as Pellet.

  Parameters:
    `m` - The ontology model being queried to find the LCA, which should conform to the reasoner capabilities described above
    `u` - An ontology class
    `v` - An ontology class
  Returns:
    The LCA of `u` and `v`
  Throws:
    `JenaException` - if the language profile of the given model does not define a top concept (e.g. `owl:Thing`)

### getLCA

    public static OntClass getLCA(OntModel m,
                                  OntClass root,
                                  OntClass u,
                                  OntClass v)

  Answer the lowest common ancestor of two classes, assuming that the given class is the root concept to start searching from. See `getLCA(OntModel, OntClass, OntClass)` for details.

  Parameters:
    `m` - The ontology model being queried to find the LCA, which should conform to the reasoner capabilities described above
    `root` - The root concept, which will be the starting point for the algorithm
    `u` - An ontology class
    `v` - An ontology class
  Returns:
    The LCA of `u` and `v`
  Throws:
    `JenaException` - if the language profile of the given model does not define a top concept (e.g. `owl:Thing`)

### findShortestPath

    public static OntTools.Path findShortestPath(Model m,
                                                 Resource start,
                                                 RDFNode end,
                                                 Filter onPath)

  Answer the shortest path from the `start` resource to the `end` RDF node, such that every step on the path is accepted by the given filter. A path is a `List` of RDF `Statement`s. The subject of the first statement in the list is `start`, and the object of the last statement in the list is `end`.

  The `onPath` argument is a `Filter`, which accepts a statement and returns true if the statement should be considered to be on the path. To search for an unconstrained path, pass `Filter.any` as an argument. To search for a path whose predicates match a fixed restricted set of property names, pass an instance of `OntTools.PredicatesFilter`.

  If there is more than one path of minimal length from `start` to `end`, this method returns an arbitrary one. The algorithm is blind breadth-first search, with loop detection.

  Parameters:
    `m` - The model in which we are seeking a path
    `start` - The starting resource
    `end` - The end, or goal, node
    `onPath` - A filter which determines whether a given statement can be considered part of the path
  Returns:
    A path, consisting of a list of statements whose first subject is `start`, and whose last object is `end`, or null if no such path exists.

### namedHierarchyRoots

    public static java.util.List namedHierarchyRoots(OntModel m)

  Answer a list of the named hierarchy roots of a given `OntModel`. This will be similar to the results of `OntModel.listHierarchyRootClasses()`, with the added constraint that every member of the returned iterator will be a named class, not an anonymous class expression. The named root classes are calculated from the root classes, by recursively replacing every anonymous class with its direct sub-classes. Thus it can be seen that the values in the list consists of the shallowest fringe of named classes in the hierarchy.

  Parameters:
    `m` - An ontology model
  Returns:
    A list of classes whose members are the named root classes of the class hierarchy in `m`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP