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


Java OntResource.listPropertyValues方法代码示例

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


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

示例1: addSuperPropertiesWithoutRange

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private void addSuperPropertiesWithoutRange(ModelConcepts concepts,
		StringBuilder sb, OntResource prop) {
	if (!hasRange(prop)) {
		String thisPropString;
		if (prop.isObjectProperty() || concepts.getPseudoObjProperties().contains(prop)) {
			thisPropString = objPropertyToSadl(concepts, prop);
		}
		else {
			thisPropString = dtPropertyToSadl(concepts, prop);
		}
		if (concepts.getPseudoObjProperties().contains(prop)) {
			sb.append("// ");
			sb.append(prop.getLocalName());
			sb.append(" is not typed in the input but SADL requires typed properties\n//    --typed as object property to match subproperties\n");
		}
		else if (concepts.getPseudoDtProperties().contains(prop)) {
			sb.append("// ");
			sb.append(prop.getLocalName());
			sb.append(" is not typed in the input but SADL requires typed properties\n//    --typed as datatype property to match subproperties\n");
		}
		concepts.addCompleted(prop);
		NodeIterator nitr2 = prop.listPropertyValues(RDFS.subPropertyOf);
		if (nitr2.hasNext()) {
			RDFNode superprop = nitr2.nextNode();
			if (superprop.canAs(OntProperty.class)){
				OntProperty supProp = superprop.as(OntProperty.class);
				addSuperPropertiesWithoutRange(concepts, sb, supProp);
			}
		}
		sb.append(thisPropString);
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:33,代码来源:OwlToSadl.java

示例2: hasRange

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private boolean hasRange(OntResource prop) {
	NodeIterator nitr = prop.listPropertyValues(RDFS.range);
	if (!nitr.hasNext()) {
		return false;
	}
	else {
		RDFNode rng = nitr.nextNode();
		if (rng.equals(RDFS.Resource)) {
			// rdfs:Resource is treated (for now?) as not a range as it adds no information and creates a SADL error.
			return false;
		}
	}
	return true;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:15,代码来源:OwlToSadl.java

示例3: ask

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
public List<Object> ask(ConceptName subject, ConceptName property)
		throws InvalidNameException {
	OntResource subj;
	Property prop;
	if (subject.getType() == null) {
		subject = validateConceptName(subject);
	}
	if (property.getType() == null) {
		property = validateConceptName(property);
	}
	if (subject.getType().equals(ConceptType.INDIVIDUAL)) {
		subj = getIndividual(subject);
		prop = getOntProperty(property);
	}
	else {
		subj = getJenaModel().getOntResource(subject.getUri());
		prop = getJenaModel().getOntProperty(property.getUri());
	}
	if (subj == null) {
		return null;
	}
	if (prop == null) {
		if (property.getNamespace().equals(RDFS.getURI())) {
			prop = getJenaModel().getProperty(RDFS.getURI() + property.getName());
		}
		else if (property.getNamespace().equals(RDF.getURI())) {
			prop = getJenaModel().getProperty(RDF.getURI() + property.getName());
		}
		else if (property.getNamespace().equals(OWL.getURI())) {
			prop = getJenaModel().getProperty(OWL.getURI() + property.getName());
		}
		else {
			return null;
		}
	}
	NodeIterator nitr = subj.listPropertyValues(prop);
	List<Object> results = null;
	while (nitr.hasNext()) {
		RDFNode objNode = nitr.next();
		if (results == null) {
			results = new ArrayList<Object>();
		}
		if (objNode.canAs(Individual.class)) {
			Individual inst = objNode.as(Individual.class);
			if (namespaceInBaseModel(inst.getNameSpace())) {
				results.add(new ConceptName(inst.getLocalName()));
			} else {
				String prefix = getJenaModel().getNsURIPrefix(
						inst.getNameSpace());
				results.add(new ConceptName(prefix, inst.getLocalName()));
			}
		} else if (objNode instanceof Literal) {
			results.add(((Literal) objNode).getValue());
		}
	}
	return results;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:58,代码来源:ModelManager.java


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