Search in sources :

Example 26 with OntClass

use of org.apache.jena.ontology.OntClass in project jena by apache.

the class ClassHierarchy method showClass.

// Internal implementation methods
// ////////////////////////////////
/**
 * Present a class, then recurse down to the sub-classes.
 *  Use occurs check to prevent getting stuck in a loop
 */
protected void showClass(PrintStream out, OntClass cls, List<OntClass> occurs, int depth) {
    renderClassDescription(out, cls, depth);
    out.println();
    // recurse to the next level down
    if (cls.canAs(OntClass.class) && !occurs.contains(cls)) {
        for (Iterator<OntClass> i = cls.listSubClasses(true); i.hasNext(); ) {
            OntClass sub = i.next();
            // we push this expression on the occurs list before we recurse
            occurs.add(cls);
            showClass(out, sub, occurs, depth + 1);
            occurs.remove(cls);
        }
    }
}
Also used : OntClass(org.apache.jena.ontology.OntClass)

Aggregations

OntClass (org.apache.jena.ontology.OntClass)26 Individual (org.apache.jena.ontology.Individual)16 ArrayList (java.util.ArrayList)5 Literal (org.apache.jena.rdf.model.Literal)4 OntResource (org.apache.jena.ontology.OntResource)3 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 ThreadInfo (java.lang.management.ThreadInfo)1 ThreadMXBean (java.lang.management.ThreadMXBean)1 ExecutorService (java.util.concurrent.ExecutorService)1 OntModel (org.apache.jena.ontology.OntModel)1 InfModel (org.apache.jena.rdf.model.InfModel)1 Model (org.apache.jena.rdf.model.Model)1 Resource (org.apache.jena.rdf.model.Resource)1 StmtIterator (org.apache.jena.rdf.model.StmtIterator)1 JenaException (org.apache.jena.shared.JenaException)1 ExtendedIterator (org.apache.jena.util.iterator.ExtendedIterator)1