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


Java OntResource.equals方法代码示例

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


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

示例1: addRestrictionsToOutput

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private void addRestrictionsToOutput(OntResource cls, boolean indent) {
	if (restrictions != null && restrictions.containsValue(cls)) {
		Iterator<String>  itr = restrictions.keySet().iterator();
		while (itr.hasNext()) {
			String key = itr.next();
			OntResource r = restrictions.get(key);
			if (r != null && r.equals(cls)) {
				if (indent) {
					sadlModel.append("\t");
				}
				sadlModel.append(key);
				restrictions.put(key, null);	// clear
			}
		}
	}
	
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:18,代码来源:OwlToSadl.java

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

示例3: updatePropertyDomain

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private boolean updatePropertyDomain(int argIdx, OntProperty prop,
		ConceptIdentifier domain) {
	boolean retval = false;
	OntResource domainCls = conceptIdentifierToOntClass(argIdx, 0, domain);
	OntResource existingDomain = prop.getDomain();
	if (domainCls != null) {
		domainCls = addClassToUnionClass(existingDomain,
				(OntClass) domainCls);
		if (existingDomain != null) {
			if (!existingDomain.equals(domainCls)) {
				if (prop.getNameSpace().equals(getModelNamespace())) {
					prop.removeDomain(existingDomain);
					prop.addDomain(domainCls);
				}
				else {
					// this is changing the domain of a property defined in a different model
					getJenaModel().add(prop, RDFS.domain, domainCls);
				}
			}
			retval = true; // return true if it was already the domain
		} else {
			if (prop.getNameSpace().equals(getModelNamespace())) {
				prop.addDomain(domainCls);
			}
			else {
				getJenaModel().add(prop, RDFS.domain, domainCls);
			}
			retval = true;
		}
	} else {
		addError(argIdx, ExistingNamePart.NOTAPPLICABLE,
				"Unable to convert domain identifier (" + domain
						+ ") to a class.");
	}
	return retval;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:37,代码来源:ModelManager.java

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

示例5: checkForExistingCompatibleDatatypeProperty

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private boolean checkForExistingCompatibleDatatypeProperty(String propUri, RDFNode rngNode) {
	DatatypeProperty prop = getTheJenaModel().getDatatypeProperty(propUri);
	if (prop != null) {
		OntResource rng = prop.getRange();
		if (rng != null && rng.equals(rngNode)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:11,代码来源:JenaBasedSadlModelProcessor.java

示例6: compareObjects

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private boolean compareObjects(Object lval, Object objVal,
		OntResource rngrsrc) {
	if ((lval instanceof KnownNode && objVal != null)
			|| (objVal instanceof KnownNode && lval != null)) {
		return true;
	}
	if (lval instanceof String && objVal instanceof String
			&& lval.equals(objVal)) {
		return true;
	} else if (lval instanceof Boolean && objVal instanceof Boolean) {
		if (lval.equals(objVal)) {
			return true;
		} else {
			return false;
		}
	} else if (lval instanceof Number && objVal instanceof Number) {
		if (lval.equals(objVal)) {
			return true;
		} else {
			double d1 = ((Number) lval).doubleValue();
			double d2 = ((Number) objVal).doubleValue();
			// double diff = d1 - d2;
			// if (Math.abs((double)diff / Math.max(Math.max(d1, d2),
			// .0000001)) < .0000001) {
			return ResultSet.areDoublesEqual(d1, d2); // true;
			// }
		}
	} else if (lval != null && objVal != null && lval.equals(objVal)) {
		return true;
	} else if (rngrsrc != null) {
		// we know the range so let's try to convert each value to the
		// desired value type and compare
		Literal v1 = getJenaModel().createTypedLiteral(lval,
				rngrsrc.getURI());
		Literal v2 = getJenaModel().createTypedLiteral(objVal,
				rngrsrc.getURI());
		if (v1 != null && v2 != null && v1.equals(v2)) {
			return true;
		}
		if (rngrsrc.equals(XSD.date)
				&& v1.getDatatypeURI().equals(XSD.date.getURI())
				&& v2.getDatatypeURI().equals(XSD.date.getURI())) {
			Object v1obj = v1.getValue();
			Object v2obj = v2.getValue();
			if (v1obj instanceof XSDDateTime
					&& v2obj instanceof XSDDateTime
					&& ((XSDDateTime) v1obj).getYears() == ((XSDDateTime) v2obj)
							.getYears()
					&& ((XSDDateTime) v1obj).getMonths() == ((XSDDateTime) v2obj)
							.getMonths()
					&& ((XSDDateTime) v1obj).getDays() == ((XSDDateTime) v2obj)
							.getDays()) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:59,代码来源:ModelManager.java

示例7: propertyToSadl

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private void propertyToSadl(StringBuilder sb, ModelConcepts concepts,
		OntResource prop) {
	OntProperty ontprop = prop.asProperty();
	ExtendedIterator<? extends OntResource> deitr = ontprop.listDomain();
	OntProperty sprprop = null;
	try {
		sprprop = ontprop.getSuperProperty();
	}
	catch(Exception e) {
		concepts.addErrorMessage(e.getMessage());
	}
	if (sprprop != null) {
		sb.append(" is a type of ");
		sb.append(uriToSadlString(concepts, sprprop));
	}
	if (deitr.hasNext()) {
		sb.append(" describes ");
		boolean unionDomain = false;
		int domainctr = 0;
		while (deitr.hasNext()) {
			OntResource dr = deitr.next();
			if (deitr.hasNext() && domainctr == 0) {
				unionDomain = true;
				sb.append("{");
			}
			if (domainctr++ > 0) {
				sb.append(" or ");
			}
			sb.append(uriToSadlString(concepts, dr));
		}
		if (unionDomain) {
			sb.append("}");
		}
	}
	else if (sprprop == null) {
		sb.append(" is a property");				
	}
	ExtendedIterator<? extends OntResource> reitr = ontprop.listRange();
	List<OntResource> rngList = new ArrayList<OntResource>();
	while (reitr.hasNext()) {
		OntResource rr = reitr.next();
		if (!rr.equals(RDFS.Resource)) {
			rngList.add(rr);
		}
	}
	int rngcnt = rngList.size();
	if (rngcnt > 0) {
		sb.append(" with values of type ");
		if (rngcnt == 1) {
			sb.append(uriToSadlString(concepts, rngList.get(0)));
		}
		else {
			sb.append("{");
			for (int i = 0; i < rngcnt; i++) {
				if (i > 0) {
					sb.append(" or ");
				}
				sb.append(uriToSadlString(concepts, rngList.get(i)));
			}
			sb.append("}");
		}
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:64,代码来源:OwlToSadl.java

示例8: createUnionOfClasses

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private OntResource createUnionOfClasses(OntResource cls, ExtendedIterator<? extends OntResource> ditr)
		throws JenaProcessorException {
	OntResource unionClass = null;
	RDFList classes = null;
	boolean allEqual = true;
	while (ditr.hasNext()) {
		OntResource existingCls = ditr.next();
		if (!existingCls.canAs(OntResource.class)) {
			throw new JenaProcessorException(
					"Unable to '" + existingCls.toString() + "' to OntResource to put into union of classes");
		}
		if (existingCls.equals(cls)) {
			continue;
		} else {
			allEqual = false;
		}
		if (existingCls.as(OntResource.class).canAs(UnionClass.class)) {
			if (classes != null) {
				classes.append(existingCls.as(UnionClass.class).getOperands());
			} else {
				try {
					existingCls.as(UnionClass.class).addOperand(cls);
					unionClass = existingCls.as(UnionClass.class);
				} 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 (classes == null) {
				classes = getTheJenaModel().createList();
			}
			classes = classes.with(existingCls.as(OntResource.class));
			classes = classes.with(cls);
		}
	}
	if (allEqual) {
		return cls;
	}
	if (classes != null) {
		unionClass = getTheJenaModel().createUnionClass(null, classes);
	}
	return unionClass;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:46,代码来源:JenaBasedSadlModelProcessor.java

示例9: compareObjects

import com.hp.hpl.jena.ontology.OntResource; //导入方法依赖的package包/类
private boolean compareObjects(Object lval, Object objVal,
		OntResource rngrsrc) {
	if ((lval instanceof KnownNode && objVal != null)
			|| (objVal instanceof KnownNode && lval != null)) {
		return true;
	}
	if (lval instanceof String && objVal instanceof String
			&& lval.equals(objVal)) {
		return true;
	} else if (lval instanceof Boolean && objVal instanceof Boolean) {
		if (lval.equals(objVal)) {
			return true;
		} else {
			return false;
		}
	} else if (lval instanceof Number && objVal instanceof Number) {
		if (lval.equals(objVal)) {
			return true;
		} else {
			double d1 = ((Number) lval).doubleValue();
			double d2 = ((Number) objVal).doubleValue();
			// double diff = d1 - d2;
			// if (Math.abs((double)diff / Math.max(Math.max(d1, d2),
			// .0000001)) < .0000001) {
			return ResultSet.areDoublesEqual(d1, d2); // true;
			// }
		}
	} else if (lval != null && objVal != null && lval.equals(objVal)) {
		return true;
	} else if (rngrsrc != null) {
		// we know the range so let's try to convert each value to the
		// desired value type and compare
		com.hp.hpl.jena.rdf.model.Literal v1 = getTheJenaModel().createTypedLiteral(lval,
				rngrsrc.getURI());
		com.hp.hpl.jena.rdf.model.Literal v2 = getTheJenaModel().createTypedLiteral(objVal,
				rngrsrc.getURI());
		if (v1 != null && v2 != null && v1.equals(v2)) {
			return true;
		}
		if (rngrsrc.equals(XSD.date)
				&& v1.getDatatypeURI().equals(XSD.date.getURI())
				&& v2.getDatatypeURI().equals(XSD.date.getURI())) {
			Object v1obj = v1.getValue();
			Object v2obj = v2.getValue();
			if (v1obj instanceof XSDDateTime
					&& v2obj instanceof XSDDateTime
					&& ((XSDDateTime) v1obj).getYears() == ((XSDDateTime) v2obj)
							.getYears()
					&& ((XSDDateTime) v1obj).getMonths() == ((XSDDateTime) v2obj)
							.getMonths()
					&& ((XSDDateTime) v1obj).getDays() == ((XSDDateTime) v2obj)
							.getDays()) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:59,代码来源:JenaBasedSadlInferenceProcessor.java


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