com.ge.grc.acuity
Class ClassHierarchy

java.lang.Object
  extended bycom.ge.grc.acuity.ClassHierarchy

public class ClassHierarchy
extends java.lang.Object

This is a modification of the ClassHierarchy created by Ian Dickson, HP Labs Bristol, with the optional display of Individuals of the Class type added. Simple demonstration program to show how to list a hierarchy of classes. This is not a complete solution to the problem (sub-classes of restrictions, for example, are not shown). It is inteded only to be illustrative of the general approach.

Version:
$Revision: 1.2 $ Last modified on $Date: 2006/09/08 22:38:35 $
Author:
crapo

Constructor Summary
ClassHierarchy()
           
 
Method Summary
protected  void indent(java.io.PrintStream out, int depth)
          Generate the indentation
protected  void renderAnonymous(java.io.PrintStream out, com.hp.hpl.jena.rdf.model.Resource anon, java.lang.String name)
          Render an anonymous class or restriction
 void renderClassDescription(java.io.PrintStream out, com.hp.hpl.jena.ontology.OntClass c, int depth, boolean bShowIndividuals)
          Render a description of the given class to the given output stream.
protected  void renderRestriction(java.io.PrintStream out, com.hp.hpl.jena.ontology.Restriction r)
          Handle the case of rendering a restriction.
protected  void renderURI(java.io.PrintStream out, com.hp.hpl.jena.shared.PrefixMapping prefixes, java.lang.String uri)
          Render a URI
protected  java.util.Iterator rootClasses(com.hp.hpl.jena.ontology.OntModel m)
          Answer an iterator over the classes we will use as the roots of the depicted hierarchy.
protected  void showClass(java.io.PrintStream out, com.hp.hpl.jena.ontology.OntClass cls, java.util.List occurs, int depth, boolean bShowIndividuals)
          Present a class, then recurse down to the sub-classes.
 void showHierarchy(java.io.PrintStream out, com.hp.hpl.jena.ontology.OntModel m, boolean bShowIndividuals)
          Show the sub-class hierarchy encoded by the given model
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassHierarchy

public ClassHierarchy()
Method Detail

showHierarchy

public void showHierarchy(java.io.PrintStream out,
                          com.hp.hpl.jena.ontology.OntModel m,
                          boolean bShowIndividuals)
Show the sub-class hierarchy encoded by the given model


showClass

protected void showClass(java.io.PrintStream out,
                         com.hp.hpl.jena.ontology.OntClass cls,
                         java.util.List occurs,
                         int depth,
                         boolean bShowIndividuals)
Present a class, then recurse down to the sub-classes. Use occurs check to prevent getting stuck in a loop


renderClassDescription

public void renderClassDescription(java.io.PrintStream out,
                                   com.hp.hpl.jena.ontology.OntClass c,
                                   int depth,
                                   boolean bShowIndividuals)

Render a description of the given class to the given output stream.

Parameters:
out - A print stream to write to
c - The class to render

renderRestriction

protected void renderRestriction(java.io.PrintStream out,
                                 com.hp.hpl.jena.ontology.Restriction r)

Handle the case of rendering a restriction.

Parameters:
out - The print stream to write to
r - The restriction to render

renderURI

protected void renderURI(java.io.PrintStream out,
                         com.hp.hpl.jena.shared.PrefixMapping prefixes,
                         java.lang.String uri)
Render a URI


renderAnonymous

protected void renderAnonymous(java.io.PrintStream out,
                               com.hp.hpl.jena.rdf.model.Resource anon,
                               java.lang.String name)
Render an anonymous class or restriction


indent

protected void indent(java.io.PrintStream out,
                      int depth)
Generate the indentation


rootClasses

protected java.util.Iterator rootClasses(com.hp.hpl.jena.ontology.OntModel m)
Answer an iterator over the classes we will use as the roots of the depicted hierarchy. We use named classes that either have Thing as a direct super-class, or which have no declared super-classes. The first condition is helpful if using a reasoner, the second otherwise.

Parameters:
m - A model
Returns:
An iterator over the named class hierarchy roots in m