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


Java OntResource.canAs方法代码示例

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


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

示例1: generatePropertyNeighborhood

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
public ResultSet generatePropertyNeighborhood(int size) throws ConfigurationException {
		OntProperty ontprop = mmgr.getOntResourceInExistingModel(anchor).as(OntProperty.class);
		List<GraphSegment> data = new ArrayList<GraphSegment>();
		ExtendedIterator<? extends OntResource> eitr = ontprop.listDomain();
		while (eitr.hasNext()) {
			OntResource dmn = eitr.next();
			if (dmn.canAs(OntClass.class)){
				data = generatePropertyRange(dmn.as(OntClass.class), ontprop, data);
			}
			data = generateClassPropertiesWithRange(dmn.as(OntClass.class), data);
		}
//		ExtendedIterator<? extends OntResource> eitr2 = ontprop.listRange();
//		while (eitr2.hasNext()) {
//			OntResource rng = eitr2.next();
//			if (ontprop.as(OntProperty.class).isObjectProperty()) {
//				data = generateClassPropertiesWithDomain(rng.as(OntClass.class), data);
//			}
//		}
		return convertDataToResultSet(data);
	}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:21,代码来源:GraphGenerator.java

示例2: generatePropertyNeighborhood

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
public ResultSet generatePropertyNeighborhood(int size) throws ConfigurationException, InvalidNameException {
		OntProperty ontprop = getTheJenaModelWithImports().getOntProperty(getAnchor().toFQString());

		List<GraphSegment> data = new ArrayList<GraphSegment>();
		ExtendedIterator<? extends OntResource> eitr = ontprop.listDomain();
		while (eitr.hasNext()) {
			isCanceled();
			OntResource dmn = eitr.next();
			if (dmn.canAs(OntClass.class)){
				data = generatePropertyRange(dmn.as(OntClass.class), -1, ontprop, size, true, data);
			}
			data = generateClassPropertiesWithRange(dmn.as(OntClass.class), size - 1, data);
		}
//		ExtendedIterator<? extends OntResource> eitr2 = ontprop.listRange();
//		while (eitr2.hasNext()) {
//			OntResource rng = eitr2.next();
//			if (ontprop.as(OntProperty.class).isObjectProperty()) {
//				data = generateClassPropertiesWithDomain(rng.as(OntClass.class), data);
//			}
//		}
		return convertDataToResultSet(data, uriStrategy, modelUri);
	}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:23,代码来源:GraphGenerator.java

示例3: dtPropertyToSadl

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private String dtPropertyToSadl(ModelConcepts concepts, OntResource prop) {
	StringBuilder sb = new StringBuilder();
	sb.append(uriToSadlString(concepts, prop));
	addNotesAndAliases(sb, prop);
	if (prop.canAs(DatatypeProperty.class)) {
		propertyToSadl(sb, concepts, prop);
	}
	else {
		sb.append(" is a property");
	}
	if (!sb.toString().contains("with values")) {
		sb.append(" with values of type data");
	}
	addEndOfStatement(sb, 1);
	return sb.toString();
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:17,代码来源:OwlToSadl.java

示例4: rangeToString

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private String rangeToString(OntProperty prop) {
	ExtendedIterator<? extends OntResource> ritr = prop.listRange();
	String rng = "";
	int cnt = 0;
	while (ritr.hasNext()) {
		OntResource rngNode = ritr.next();
		if (!rngNode.isAnon() && rngNode.getNameSpace().equals(XSD.getURI())) {
			rng += rngNode.getLocalName();
		}
		else if (rngNode.canAs(OntClass.class)) {
			rng += ontClassToString((OntClass)rngNode.as(OntClass.class), null);
		}
		else {
			rng += rngNode.toString();
		}
		cnt++;
	}
	if (cnt > 1) {
		rng = "{" + rng + "}";
	}
	return rng;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:23,代码来源:OwlToSadl.java

示例5: checkResourceOutputComplete

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private void checkResourceOutputComplete(OntResource r) {
	if (r.canAs(Individual.class)) {
		Individual inst = r.asIndividual();
		StmtIterator sitr = inst.listProperties();
		while (sitr.hasNext()) {
			Statement s = sitr.next();
			if (!s.getPredicate().equals(RDF.type)) {
				System.out.println(s);
				sitr.close();
				return;
			}
		}
		resourcesOutput.add(r);
		sitr.close();
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:17,代码来源:OwlToSadl.java

示例6: addUnittedQuantityAsInstancePropertyValue

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private void addUnittedQuantityAsInstancePropertyValue(Individual inst, OntProperty oprop, OntResource rng,
		String literalNumber, String unit) {
	Individual unittedVal;
	if (rng != null && rng.canAs(OntClass.class)) {
		unittedVal = getTheJenaModel().createIndividual(rng.as(OntClass.class));
	} else {
		unittedVal = getTheJenaModel().createIndividual(
				getTheJenaModel().getOntClass(SadlConstants.SADL_IMPLICIT_MODEL_UNITTEDQUANTITY_URI));
	}
	// TODO this may need to check for property restrictions on a subclass of
	// UnittedQuantity
	unittedVal.addProperty(getTheJenaModel().getProperty(SadlConstants.SADL_IMPLICIT_MODEL_VALUE_URI),
			getTheJenaModel().createTypedLiteral(literalNumber));
	unittedVal.addProperty(getTheJenaModel().getProperty(SadlConstants.SADL_IMPLICIT_MODEL_UNIT_URI),
			getTheJenaModel().createTypedLiteral(unit));
	inst.addProperty(oprop, unittedVal);
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:18,代码来源:JenaBasedSadlModelProcessor.java

示例7: getListType

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private ConceptName getListType(TypeCheckInfo tci) throws TranslationException, InvalidTypeException {
		Node tct = tci.getTypeCheckType();
		if (tct != null) {
			if (tct instanceof NamedNode) {
				try {
					OntResource cls = theJenaModel.getOntResource(((NamedNode)tct).toFullyQualifiedString());
					if (tci.getTypeToExprRelationship().equals(RANGE) || tci.getTypeToExprRelationship().equals(RESTRICTED_TO)) {
						if (cls.isURIResource()) {
//							return new ConceptName(cls.getURI());
							return getModelProcessor().namedNodeToConceptName((NamedNode) tct);
						}
					}
					if (cls != null && cls.canAs(OntClass.class)){
						ConceptName listcn = getListClassType(cls);
						if (listcn != null) {
							return listcn;
						}
					}
				} catch (InvalidNameException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		return null;
	}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:27,代码来源:JenaBasedSadlModelValidator.java

示例8: addClassToUnionClass

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private OntResource addClassToUnionClass(OntModel model, OntResource existingCls, OntResource cls) {
	if (existingCls != null && !existingCls.equals(cls)) {
		RDFList classes = null;
		if (existingCls.canAs(UnionClass.class)) {
			try {
				classes = ((UnionClass) existingCls.as(UnionClass.class))
						.getOperands();
				if (classes.contains(cls)) {
					return existingCls;
				}
				classes = classes.with(cls);
			} catch (Exception e) {
				// don't know why this is happening
				logger.error("Union class error that hasn't been resolved or understood.");
				return cls;
			}
		} else {
			if (cls.equals(existingCls)) {
				return existingCls;
			}
			classes = model.createList();
			classes = classes.with(existingCls);
			classes = classes.with(cls);
		}
		OntResource unionClass = model.createUnionClass(null,
				classes);
		return unionClass;
	} else {
		return cls;
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:32,代码来源:SadlServerPEImpl.java

示例9: ontClassInThisModel

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private OntClass ontClassInThisModel(OntClass cls) {
	// make sure we have the class in this model
	if (cls != null) {
		if (!cls.isAnon()) {
			cls = getJenaModel().createClass(cls.getURI());
		}
		else {
			OntResource newor = getJenaModel().getOntResource(cls);
			if (newor.canAs(OntClass.class)) {
				cls = newor.as(OntClass.class);
			}
		}
	}
	return cls;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:16,代码来源:ModelManager.java

示例10: addClassToUnionClass

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private OntResource addClassToUnionClass(OntResource existingCls,
		OntResource cls) {
	if (existingCls != null && !existingCls.equals(cls)) {
		if (existingCls.canAs(OntClass.class) && classIsSubclassOf(existingCls.as(OntClass.class), cls, true)) {
			return cls;
		}
		else if (cls.canAs(OntClass.class) && classIsSubclassOf(cls.as(OntClass.class), existingCls, true)) {
			return existingCls;
		}
		else {
			RDFList classes = null;
			if (existingCls.canAs(UnionClass.class)) {
				try {
					 UnionClass ucls = existingCls.as(UnionClass.class);
					 ucls.addOperand(cls);
					 return ucls;
				} catch (Exception e) {
					// don't know why this is happening
					logger.error("Union class error that hasn't been resolved or understood.");
					return cls;
				}
			} else {
				if (cls.equals(existingCls)) {
					return existingCls;
				}
				classes = getJenaModel().createList();
				classes = classes.with(existingCls);
				classes = classes.with(cls);
			}
			OntResource unionClass = getJenaModel().createUnionClass(null,
					classes);
			return unionClass;
		}
	} else {
		return cls;
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:38,代码来源:ModelManager.java

示例11: classInstances

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private List<GraphSegment> classInstances(OntClass cls, List<GraphSegment> instData) {
	ExtendedIterator<? extends OntResource> itr = cls.listInstances(true);
	while (itr.hasNext()) {
		OntResource or = itr.next();
		if (or.canAs(Individual.class)){
			GraphSegment gs = new GraphSegment(getModelUri(), or.as(Individual.class), "is a", cls, configMgr);
			if (!instData.contains(gs)) {
				annotateHeadAsIndividual(gs);
				annotateTailAsClass(gs);
				instData.add(gs);
			}
		}
	}
	return instData;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:16,代码来源:GraphGenerator.java

示例12: objPropertyToSadl

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private String objPropertyToSadl(ModelConcepts concepts, OntResource prop) {
	StringBuilder sb = new StringBuilder();
	sb.append(uriToSadlString(concepts, prop));
	addNotesAndAliases(sb, prop);
	if (prop.canAs(ObjectProperty.class)) {
		propertyToSadl(sb, concepts, prop);
	}
	else {
		sb.append(" is a property");
	}
	addEndOfStatement(sb, 1);
	return sb.toString();
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:14,代码来源:OwlToSadl.java

示例13: domainToString

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private String domainToString(OntProperty prop) throws IOException {
	ExtendedIterator<? extends OntResource> ditr = prop.listDomain();
	while (ditr.hasNext()) {
		OntResource dmnNode = ditr.next();
		if (dmnNode.canAs(OntClass.class)) {
			return ontClassToString(dmnNode.as(OntClass.class), null);
		}
		else {
			throw new IOException("Domain of property '" + prop.toString() + "' is not an OntClass!");
		}
	}
	return null;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:14,代码来源:OwlToSadl.java

示例14: isNamedNodeSubclassOfNamedNode

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private boolean isNamedNodeSubclassOfNamedNode(NamedNode cls, NamedNode subcls) {
	OntResource curCls = getTheJenaModel().getOntResource(((NamedNode) cls).toFullyQualifiedString());
	OntResource newCls = getTheJenaModel().getOntResource(((NamedNode) subcls).toFullyQualifiedString());
	if (curCls.canAs(OntClass.class) && newCls.canAs(OntClass.class)) {
		try {
			if (SadlUtils.classIsSubclassOf(newCls.as(OntClass.class), curCls.as(OntClass.class), true, null)) {
				return true; // OK if subclass
			}
		} catch (CircularDependencyException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	return false;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:16,代码来源:JenaBasedSadlModelProcessor.java

示例15: checkRangeForMatch

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private boolean checkRangeForMatch(OntModel theJenaModel2, OntProperty pred, OntResource obj, boolean isList) throws CircularDependencyException {
		StmtIterator rngitr = theJenaModel2.listStatements(pred, RDFS.range, (RDFNode)null);
		while (rngitr.hasNext()) {
			RDFNode rng = rngitr.nextStatement().getObject();
			if (isTypedListSubclass(rng)) {
				if (!isList) {
					rngitr.close();
					return false;
				}
				if (rng.canAs(OntClass.class )) {
					rng = getSadlTypedListType(rng.as(OntClass.class));
				}
				else {
// TODO this is an unhandled case					
				}
			}
			if (obj instanceof Individual) {
				ExtendedIterator<Resource> institr = obj.asIndividual().listRDFTypes(true);
				while (institr.hasNext()) {
					Resource typ = institr.next();
					if (rng.canAs(OntClass.class)) {
						if (SadlUtils.classIsSubclassOf(typ.as(OntClass.class), rng.asResource().as(OntClass.class), true, null)) {
							institr.close();
							rngitr.close();
							return true;
						}
					}
				}
			}
			else if (obj.canAs(OntClass.class) && rng.isResource() && rng.asResource().canAs(OntClass.class)) {
				if (SadlUtils.classIsSubclassOf(obj.as(OntClass.class), rng.asResource().as(OntClass.class), true, null)) {
					rngitr.close();
					return true;
				}
			}
		}
		return false;
	}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:39,代码来源:JenaBasedSadlModelValidator.java


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