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


Java OntClass.isRestriction方法代码示例

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


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

示例3: getSadlTypedListType

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
public Resource getSadlTypedListType(OntClass lstcls) {
	ExtendedIterator<OntClass> eitr = ((OntClass)lstcls.as(OntClass.class)).listSuperClasses(true);
	while (eitr.hasNext()) {
		OntClass cls = eitr.next();
		if (cls.isRestriction()) {
			if (cls.canAs(AllValuesFromRestriction.class)) {
				if (((AllValuesFromRestriction)cls.as(AllValuesFromRestriction.class)).onProperty(theJenaModel.getProperty(SadlConstants.SADL_LIST_MODEL_FIRST_URI))) {
					Resource avf = ((AllValuesFromRestriction)cls.as(AllValuesFromRestriction.class)).getAllValuesFrom();
					eitr.close();
					return avf;
				}
			}
		}
	}
	return null;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:17,代码来源:JenaBasedSadlModelValidator.java

示例4: getListClassType

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
protected ConceptName getListClassType(OntResource cls) {
	ExtendedIterator<OntClass> eitr = cls.as(OntClass.class).listSuperClasses();
	while (eitr.hasNext()) {
		OntClass supercls = eitr.next();
		if (supercls.isRestriction() && supercls.hasProperty(OWL.onProperty, theJenaModel.getProperty(SadlConstants.SADL_LIST_MODEL_FIRST_URI))) {
			RDFNode avf = supercls.getPropertyValue(OWL.allValuesFrom);
			if (avf.canAs(Resource.class)) {
				Resource r = avf.as(Resource.class);
				if (r.isURIResource()) {
					eitr.close();
					return new ConceptName(r.getURI());
				}
			}
		}
	}
	return null;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:18,代码来源:JenaBasedSadlModelValidator.java

示例5: addIsATypeOfToGraph

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
private void addIsATypeOfToGraph(String publicUri, OntClass classInst, OntClass supercls, List<GraphSegment> data)
		throws ConfigurationException, IOException, URISyntaxException, Exception {
	GraphSegment sg;
	if (supercls.isRestriction()) {
		StmtIterator stir = getTheJenaModel().listStatements(supercls.asResource(), OWL.onProperty, (RDFNode)null);
		if (stir.hasNext()) {
			RDFNode pn = stir.next().getObject();
			if (pn.canAs(Property.class)){ 
				Property onprop = pn.as(Property.class);
				if (!onprop.equals(getListFirstProp()) && !onprop.equals(getListRestProp())) {
					RDFNode subjlisttype = getListType(supercls);
					RDFNode objlisttype = getListType(classInst);
					if (subjlisttype != null || objlisttype != null) {
						sg = new GraphSegment(publicUri, supercls, "restricts", classInst, subjlisttype, objlisttype, configMgr);
					}
					else {
						sg = new GraphSegment(publicUri, supercls, "restricts", classInst, configMgr);
					}
					if (!data.contains(sg)) {
						data.add(sg);
						sg.addHeadAttribute(COLOR, RED);
						sg.addEdgeAttribute(COLOR, RED);
						annotateTailAsClass(sg);
					}
				}
			}
			else {
				throw new InvalidNameException("Unable to convert restriction's property to a property");
			}
		}
		else {
			throw new InvalidNameException("Unable to get restriction's property");
		}
	}
	else {
		sg = new GraphSegment(publicUri, supercls, "subClass", classInst, getConfigMgr());
		sg.addEdgeAttribute(COLOR, BLUE);
		sg.addEdgeAttribute(STYLE, DASHED);
		if (!data.contains(sg)) {
			data.add(sg);
			annotateHeadAsClass(sg);
			if(isInImports(supercls, publicUri)){
				if(getImportUrl(supercls) != null) sg.addHeadAttribute(LINK_URL, getImportUrl(supercls));
				sg.addHeadAttribute(IS_IMPORT, "true");
			}
			annotateTailAsClass(sg);
			if(isInImports(classInst, publicUri)){
				if(getImportUrl(classInst) != null) sg.addTailAttribute(LINK_URL, getImportUrl(classInst));
				sg.addTailAttribute(IS_IMPORT, "true");
			}
		}
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:54,代码来源:OntologyGraphGenerator.java

示例6: ontClassToString

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
private String ontClassToString(OntClass cls, OntClass subclass) {
		if (cls.isUnionClass()) {
			return getUnionClassRangeString(cls.asUnionClass());
		}
		else if (cls.isIntersectionClass()) {
			return getIntersectionClassRangeString(cls.asIntersectionClass());
		}
		else if (cls.isRestriction()) {
			if (!shouldResourceBeOutput(cls, true, false, false)) {
				Restriction rest = cls.asRestriction();
				Property onProp = rest.getOnProperty();
				if (rest.isAllValuesFromRestriction()) {
					Resource avfr = rest.asAllValuesFromRestriction().getAllValuesFrom();
					addRestriction(subclass, resourceToString(onProp, false) + " of " + resourceToString(subclass, false) + " only has values of type " + 
							resourceToString(avfr, false) + ".\n");
				}
				else if (rest.isSomeValuesFromRestriction()) {
					Resource svfr = rest.asSomeValuesFromRestriction().getSomeValuesFrom();
					addRestriction(subclass, resourceToString(onProp, false) + " of " + resourceToString(subclass, false) + " has at least one value of type " + 
							resourceToString(svfr, false) + ".\n");				
				}
				else if (rest.isMaxCardinalityRestriction()) {
					int maxCard = rest.asMaxCardinalityRestriction().getMaxCardinality();
					addRestriction(subclass, resourceToString(onProp, false) + " of " + resourceToString(subclass, false) + " has at most " + 
							maxCard + (maxCard > 1 ? " values.\n" : " value.\n"));
				}
				else if (rest.isMinCardinalityRestriction()) {
					int minCard = rest.asMinCardinalityRestriction().getMinCardinality();
					addRestriction(subclass, resourceToString(onProp, false) + " of " + resourceToString(subclass, false) + " has at least " + 
							minCard + (minCard > 1 ? " values.\n" : " value.\n"));
				}
				else if (rest.isCardinalityRestriction()) {
					int card = rest.asCardinalityRestriction().getCardinality();
					addRestriction(subclass, resourceToString(onProp, false) + " of " + resourceToString(subclass, false) + " has exactly " + 
							card + (card > 1 ? " values.\n" : " value.\n"));
				}
				else if (rest.isHasValueRestriction()) {
					RDFNode hvr = rest.asHasValueRestriction().getHasValue();
					addRestriction(subclass, resourceToString(onProp, false) + " of " + resourceToString(subclass, false) + " always has value " + 
							rdfNodeToString(hvr, 0) + " .\n");				
				}
				else {
					System.out.println("Unhandled restriction: " + rest.getClass());
				}
				resourcesOutput.add(cls);
			}
			if (cls.isAnon()) {
//				System.out.println("returning null on anon restriction--should this happen??");
				return null;
			}
			else {
				return cls.toString();
			}
			
		}
		else if (cls.isEnumeratedClass()) {
			EnumeratedClass enumcls = cls.asEnumeratedClass();
			return enumeratedClassToString(enumcls);
		}
		else if (cls.isComplementClass()) {
			ComplementClass ccls = cls.asComplementClass();
			OntClass thecls = ccls.getDisjointWith();
			if (thecls != null) {
				return resourceToString(thecls, false);
			}
			else {
				return null;
			}
		}
		else if (!cls.isAnon()) {
			return resourceToString(cls, false);
		}
		else {
			System.out.println("Anon class; returning string equivalent--this shouldn't happen.");
			return cls.toString();
		}
	}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:78,代码来源:OwlToSadl.java

示例7: 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

示例8: 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

示例9: 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.isRestriction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。