本文整理汇总了Java中org.apache.jena.ontology.OntModel.listClasses方法的典型用法代码示例。如果您正苦于以下问题:Java OntModel.listClasses方法的具体用法?Java OntModel.listClasses怎么用?Java OntModel.listClasses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.ontology.OntModel
的用法示例。
在下文中一共展示了OntModel.listClasses方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processSingle
import org.apache.jena.ontology.OntModel; //导入方法依赖的package包/类
private void processSingle(OntModel m) {
for (Iterator<?> i = m.listClasses(); i.hasNext(); ) {
OntClass c = (OntClass) i.next();
try {
// too confusing to list all the restrictions as root classes
if (c.isAnon()) {
continue;
}
if (c.hasSuperClass(m.getProfile().THING(), true) || c.getCardinality(m.getProfile().SUB_CLASS_OF()) == 0) {
// this class is directly descended from Thing
roots.add(c);
}
} catch (Exception e) {
Log.error("Error during extraction or root Classes from Ontology Model: ", e);
}
}
}
示例2: rootClasses
import org.apache.jena.ontology.OntModel; //导入方法依赖的package包/类
/**
* Parses out all root classes of the given
* {@link org.apache.jena.ontology.OntModel}
* @param m the {@link org.apache.jena.ontology.OntModel} we wish to obtain
* all root classes for.
* @return an {@link java.util.Iterator} of {@link org.apache.jena.ontology.OntClass}
* elements representing all root classes.
*/
@Override
public Iterator<OntClass> rootClasses(OntModel m) {
Iterator<?> i = m.listClasses();
if (i.hasNext() && i.next() instanceof OntClass) {
//assume ontology has root classes
processSingle(m);
} else {
//check for presence of aggregate/collection ontologies such as sweetAll.owl
processCollection(m);
}
return roots.iterator();
}