当前位置: 首页>>代码示例>>Java>>正文


Java OntClass.listSuperClasses方法代码示例

本文整理汇总了Java中com.hp.hpl.jena.ontology.OntClass.listSuperClasses方法的典型用法代码示例。如果您正苦于以下问题:Java OntClass.listSuperClasses方法的具体用法?Java OntClass.listSuperClasses怎么用?Java OntClass.listSuperClasses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hp.hpl.jena.ontology.OntClass的用法示例。


在下文中一共展示了OntClass.listSuperClasses方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: maxCardinalityRestrictionAlreadyExists

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
private boolean maxCardinalityRestrictionAlreadyExists(OntClass domainCls,
		OntProperty prop, int mxcard) {
	ExtendedIterator<OntClass> eitr = domainCls.listSuperClasses(true);
	while (eitr.hasNext()) {
		OntClass supercls = eitr.next();
		if (supercls.isRestriction()) {
			Restriction rstrctn = supercls.asRestriction();
			if (rstrctn.isMaxCardinalityRestriction()) {
				MaxCardinalityRestriction maxrest = rstrctn.asMaxCardinalityRestriction();
				if (maxrest.getOnProperty().equals(prop) && maxrest.getMaxCardinality() == mxcard) {
					eitr.close();
					return true;
				}
			}
		}
	}
	eitr.close();
	return false;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:20,代码来源:ModelManager.java

示例2: getSuperclasses

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
private List<OntClass> getSuperclasses(OntClass cls) {
	try {
		ExtendedIterator<OntClass> eitr = cls.listSuperClasses(true);
		if (eitr.hasNext()) {
			List<OntClass> lst = new ArrayList<OntClass>();
			while (eitr.hasNext()) {
				lst.add(eitr.next());
			}
			return lst;
		}
	}
	catch (Throwable t) {
		System.out.println("Unexpected erro getting super classes of '" + cls.toString() + "': " + t.getLocalizedMessage());
	}
	return null;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:17,代码来源:OwlToSadl.java

示例3: addListValues

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
private void addListValues(Individual inst, OntClass cls, SadlValueList listInitializer) {
	com.hp.hpl.jena.rdf.model.Resource to = null;
	ExtendedIterator<OntClass> scitr = cls.listSuperClasses(true);
	while (scitr.hasNext()) {
		OntClass sc = scitr.next();
		if (sc.isRestriction()
				&& ((sc.as(Restriction.class)).isAllValuesFromRestriction() && sc.as(AllValuesFromRestriction.class)
						.onProperty(getTheJenaModel().getProperty(SadlConstants.SADL_LIST_MODEL_FIRST_URI)))) {
			to = sc.as(AllValuesFromRestriction.class).getAllValuesFrom();
			break;
		}
	}
	if (to == null) {
		// addError("No 'to' resource found in restriction of List subclass",
		// listInitializer);
	}
	Iterator<SadlExplicitValue> values = listInitializer.getExplicitValues().iterator();
	addValueToList(null, inst, cls, to, values);
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:20,代码来源:JenaBasedSadlModelProcessor.java

示例4: findNrofSuperClasses

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
/** Find the number of subclasses for the indicated OntClass. 
 * Caches values to speed up determination.
 *  
 * @param oc
 * @return
 */
protected int findNrofSuperClasses (OntClass oc) {
	String classUri = oc.getURI();
	if (!numOfSuperClasses.containsKey(classUri)) {
		ExtendedIterator i = oc.listSuperClasses();
		numOfSuperClasses.put(classUri, new Integer(i.toList().size()));
	}
	return numOfSuperClasses.get(classUri).intValue();
}
 
开发者ID:brianthomas,项目名称:soml,代码行数:15,代码来源:SemanticObjectBuilder.java

示例5: getSuperClasses

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
/**
 * Returns an iterator over all super classes of the class specified by the
 * given uri or an empty iterator if no such class exists or if it has no
 * super classes.
 * 
 * @param uri
 * @return an iterator over all super classes of the class specified by the
 *         given uri or an empty iterator if no such class exists or if it
 *         has no super classes.
 */
@SuppressWarnings("unchecked")
public Iterator<OntClass> getSuperClasses(String uri) {
	OntModel model = OntologyIndex.get().getModel();
	OntClass clazz = model.getOntClass(uri);
	if (clazz != null) {
		return clazz.listSuperClasses(true);
	}
	
	return EmptyIterator.INSTANCE;
}
 
开发者ID:ag-csw,项目名称:ExpertFinder,代码行数:21,代码来源:ExpertFinder.java

示例6: classIsSuperClassOf

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
private static boolean classIsSuperClassOf(OntClass cls, OntClass subcls) {
	ExtendedIterator<OntClass> eitr = subcls.listSuperClasses();
	try {
		while (eitr.hasNext()) {
			OntClass sprcls = eitr.next();
			if (sprcls.equals(cls)) {
				return true;
			}
			if (classIsSuperClassOf(cls, sprcls)) {
				return true;
			}
		}
		eitr.close();
		
		eitr = cls.listSuperClasses();
		while (eitr.hasNext()) {
			OntClass equivCls = eitr.next();
			if (classIsSubclassOf(subcls, equivCls, false)) {
				eitr.close();
				return true;
			}
		}
	}
	catch (Throwable t) {
		logger.error("Error checking if class '" + cls.toString() + "' is a superclass of '" + subcls.toString() + 
				"' : " + t.getMessage());
	}
	finally {
		eitr.close();
	}
	return false;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:33,代码来源:ModelManager.java

示例7: classIsSuperClassOf

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
public static boolean classIsSuperClassOf(OntClass cls, OntClass subcls) {
	ExtendedIterator<OntClass> eitr = subcls.listSuperClasses();
	try {
		while (eitr.hasNext()) {
			OntClass sprcls = eitr.next();
			if (sprcls.equals(cls)) {
				return true;
			}
			if (classIsSuperClassOf(cls, sprcls)) {
				return true;
			}
		}
		eitr.close();
		
		eitr = cls.listSuperClasses();
		while (eitr.hasNext()) {
			OntClass equivCls = eitr.next();
			if (classIsSubclassOf(subcls, equivCls, false, null)) {
				eitr.close();
				return true;
			}
		}
	}
	catch (Throwable t) {
		logger.error("Error checking if class '" + cls.toString() + "' is a superclass of '" + subcls.toString() + 
				"' : " + t.getMessage());
	}
	finally {
		eitr.close();
	}
	return false;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:33,代码来源:SadlUtils.java

示例8: classIsSuperClassOf

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
private boolean classIsSuperClassOf(OntClass cls, OntClass subcls) {
	ExtendedIterator<OntClass> eitr = subcls.listSuperClasses();
	while (eitr.hasNext()) {
		OntClass sprcls = eitr.next();
		if (sprcls.equals(cls)) {
			return true;
		}
		if (classIsSuperClassOf(cls, sprcls)) {
			return true;
		}
	}
	eitr.close();
	return false;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:15,代码来源:SadlUtils.java

示例9: isSingleValued

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
public static boolean isSingleValued(OntClass cls, OntProperty prop, String rngString) {
		if (prop.isFunctionalProperty()) {
			return true;
		}
		if (cls != null) {
			ExtendedIterator<OntClass> eitr = cls.listSuperClasses(false);
			while (eitr.hasNext()) {
				OntClass supercls = eitr.next();
				if (supercls.isRestriction()) {
					Restriction rstrct = supercls.asRestriction();
					if (rstrct.isMaxCardinalityRestriction()) {
						MaxCardinalityRestriction mxcr = rstrct.asMaxCardinalityRestriction();
						if (mxcr.getOnProperty().equals(prop) && mxcr.getMaxCardinality() == 1) {
							return true;
						}
					}
					else if (rstrct.isCardinalityRestriction()) {
						if (rstrct.isCardinalityRestriction()) {
							CardinalityRestriction cr = rstrct.asCardinalityRestriction();
							if (cr.getOnProperty().equals(prop) && cr.getCardinality() == 1) {
								return true;
							}
						}
					}
					else {
						if (rstrct.hasProperty(OWL2.maxQualifiedCardinality)) {
							if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.maxQualifiedCardinality).getInt() == 1) {
								// check class
								if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
									return true;
								}
							}
						}
						else if (rstrct.hasProperty(OWL2.qualifiedCardinality)) {
							if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.qualifiedCardinality).getInt() == 1) {
								// check class
								if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
									return true;
								}
							}							
						}
//						StmtIterator siter = rstrct.listProperties();
//						while (siter.hasNext()) {
//							System.out.println(siter.nextStatement().toString());
//						}
					}
				}
			}
		}
		return false;
	}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:52,代码来源:OwlToSadl.java

示例10: isSingleValued

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
public static synchronized boolean isSingleValued(OntClass cls, OntProperty prop, String rngString) {
	if (prop.isFunctionalProperty()) {
		return true;
	}
	if (cls != null) {
		ExtendedIterator<OntClass> eitr = cls.listSuperClasses(false);
		while (eitr.hasNext()) {
			OntClass supercls = eitr.next();
			if (supercls.isRestriction()) {
				Restriction rstrct = supercls.asRestriction();
				if (rstrct.isMaxCardinalityRestriction()) {
					MaxCardinalityRestriction mxcr = rstrct.asMaxCardinalityRestriction();
					if (mxcr.getOnProperty().equals(prop) && mxcr.getMaxCardinality() == 1) {
						return true;
					}
				}
				else if (rstrct.isCardinalityRestriction()) {
					if (rstrct.isCardinalityRestriction()) {
						CardinalityRestriction cr = rstrct.asCardinalityRestriction();
						if (cr.getOnProperty().equals(prop) && cr.getCardinality() == 1) {
							return true;
						}
					}
				}
				else {
					if (rstrct.hasProperty(OWL2.maxQualifiedCardinality)) {
						if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.maxQualifiedCardinality).getInt() == 1) {
							// check class
							if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
								return true;
							}
						}
					}
					else if (rstrct.hasProperty(OWL2.qualifiedCardinality)) {
						if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.qualifiedCardinality).getInt() == 1) {
							// check class
							if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
								return true;
							}
						}							
					}
				}
			}
		}
	}
	return false;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:48,代码来源:UtilsForJena.java

示例11: isSingleValued

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
public static synchronized boolean isSingleValued(OntClass cls, OntProperty prop, String rngString) {
		if (prop.isFunctionalProperty()) {
			return true;
		}
		if (cls != null) {
			ExtendedIterator<OntClass> eitr = cls.listSuperClasses(false);
			while (eitr.hasNext()) {
				OntClass supercls = eitr.next();
				if (supercls.isRestriction()) {
					Restriction rstrct = supercls.asRestriction();
					if (rstrct.isMaxCardinalityRestriction()) {
						MaxCardinalityRestriction mxcr = rstrct.asMaxCardinalityRestriction();
						if (mxcr.getOnProperty().equals(prop) && mxcr.getMaxCardinality() == 1) {
							return true;
						}
					}
					else if (rstrct.isCardinalityRestriction()) {
						if (rstrct.isCardinalityRestriction()) {
							CardinalityRestriction cr = rstrct.asCardinalityRestriction();
							if (cr.getOnProperty().equals(prop) && cr.getCardinality() == 1) {
								return true;
							}
						}
					}
					else {
						if (rstrct.hasProperty(OWL2.maxQualifiedCardinality)) {
							if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.maxQualifiedCardinality).getInt() == 1) {
								// check class
								if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
									return true;
								}
							}
						}
						else if (rstrct.hasProperty(OWL2.qualifiedCardinality)) {
							if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.qualifiedCardinality).getInt() == 1) {
								// check class
								if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
									return true;
								}
							}							
						}
//						StmtIterator siter = rstrct.listProperties();
//						while (siter.hasNext()) {
//							System.out.println(siter.nextStatement().toString());
//						}
					}
				}
			}
		}
		return false;
	}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:52,代码来源:UtilsForJena.java


注:本文中的com.hp.hpl.jena.ontology.OntClass.listSuperClasses方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。