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


Java OntProperty类代码示例

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


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

示例1: handleAttributes

import com.hp.hpl.jena.ontology.OntProperty; //导入依赖的package包/类
private void handleAttributes(HashMap<String, Object> tboxMap, Individual ind, NamedNodeMap mapAttr) {
	for (int i = 0; i < mapAttr.getLength(); i++) {
		Node nodeattr = mapAttr.item(i);
		String attrname = nodeattr.getNodeName();
		String attrns = nodeattr.getNamespaceURI();
		String attrvalue = nodeattr.getNodeValue();

		if (StringUtils.isBlank(attrvalue)) {
			continue;
		}

		if (attrns == null) {
			attrns = nstBox;
		} else if (!(attrns.endsWith("/") || attrns.endsWith("#"))) {
			attrns += "#";
		}

		OntProperty ontProp = getDatatypeOntProperty(tboxMap, attrns + attrname);

		// Add literal
		ind.addLiteral(ontProp, attrvalue.trim());
	}
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:24,代码来源:XMLToRDFConverter.java

示例2: addSinglePropertyFromTypeRemembrance

import com.hp.hpl.jena.ontology.OntProperty; //导入依赖的package包/类
private void addSinglePropertyFromTypeRemembrance(Resource r, OntProperty p, String literalString, TypeVO typeremembrance,IFCVO ivo) throws IOException, IfcDataFormatException {
      OntResource range = ontModel.getOntResource(getOntNS() + typeremembrance.getName());

      if (range.isClass()) {
          if (range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "ENUMERATION"))) {
              // Check for ENUM
              addEnumProperty(r, p, range, literalString,ivo);
          } else if (range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "SELECT"))) {
              // Check for SELECT
 //             if (logToFile)
//                  bw.write("*OK 24*: found subClass of SELECT Class, now doing nothing with it: " + p + " - " + range.getLocalName() + " - " + literalString + "\r\n");
              createLiteralProperty(r, p, range, literalString,ivo);
          } else if (range.asClass().hasSuperClass(listModel.getOntClass(getListns() + "OWLList"))) {
              // Check for LIST
          	throw IfcDataFormatException.valueOutOfRange("#"+ivo.getLineNum(),literalString,range.getLocalName());
          } else {
              createLiteralProperty(r, p, range, literalString,ivo);
          }
      } else {

              LOGGER.log(Level.WARNING ,"found other kind of property: " + p + " - " + range.getLocalName() + "\r\n");
      }
  }
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:24,代码来源:RDFWriter.java

示例3: fillClassInstanceList

import com.hp.hpl.jena.ontology.OntProperty; //导入依赖的package包/类
private void fillClassInstanceList(LinkedList<Object> tmpList, OntResource typerange, OntProperty p, Resource r) throws IOException, IfcDataFormatException {
    List<Resource> reslist = new ArrayList<Resource>();
    List<IFCVO> entlist = new ArrayList<IFCVO>();

    // createrequirednumberofresources
    for (int i = 0; i < tmpList.size(); i++) {
        if (IFCVO.class.isInstance(tmpList.get(i))) {
        	Resource r1 = getResource(getBaseURI() + createLocalName(typerange.getLocalName() + "_" + IDcounter), typerange);
            reslist.add(r1);
            IDcounter++;
            entlist.add((IFCVO) tmpList.get(i));
            if (i == 0) {
                getRdfWriter().triple(new Triple(r.asNode(), p.asNode(), r1.asNode()));
            }
        }
    }

    // bindtheproperties
    String listvaluepropURI = getOntNS() + typerange.getLocalName().substring(0, typerange.getLocalName().length() - 5);
    OntResource listrange = ontModel.getOntResource(listvaluepropURI);

    addClassInstanceListProperties(reslist, entlist, listrange);
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:24,代码来源:RDFWriter.java

示例4: getName

import com.hp.hpl.jena.ontology.OntProperty; //导入依赖的package包/类
@Override
public String getName() {
  NodeIterator ni;
  try {
    ni = KBObjectImpl.getBaseContextModel().listObjectsOfProperty(
            ((Individual)((VariableImpl)this).getCore()),
            (OntProperty)((KBPredicateImpl)Constants.getInstance().RIF_VARNAME_PRED).getCore());
    if (ni.hasNext()) {
    return ni.next().asLiteral().getString();
  }
  } catch (Exception ex) {
    Logger.getLogger(VariableImpl.class.getName()).log(Level.SEVERE, null, ex);
  }
  return "";
  
}
 
开发者ID:vijayrajak,项目名称:JenaKBClient,代码行数:17,代码来源:VariableImpl.java

示例5: testStatements

import com.hp.hpl.jena.ontology.OntProperty; //导入依赖的package包/类
@Test
public void testStatements() throws Exception {
  String bio_ns = "http://example.com/biology#";
  KBCollection human = new KBCollectionImpl(bio_ns + "human");
  Variable v = new VariableImpl ("person");
  
  KBObjectImpl.getBaseContextModel().createList(new RDFNode[] {((Resource)human.getCore()), ((Resource)v.getCore())});
  FileWriter fw = new FileWriter("/scratch/WORK2/jena/testModels/test5.xml");
  
  
  KBPredicate father = new KBPredicateImpl(Constants.CYC_TBOX_NS.concat("father"));
  
  Statement s;
  s = KBObjectImpl.getBaseContextModel().createStatement(((KBCollectionImpl)Constants.owlThing()).getCore(), (OntProperty)((KBPredicateImpl)father).getCore(), ((VariableImpl)v).getCore());
  KBObjectImpl.getBaseContextModel().add(s);
  
  KBObjectImpl.getBaseContextModel().createReifiedStatement(s);
  
  RDFDataMgr.write(fw, KBObjectImpl.getDataset(), RDFFormat.NQUADS);
}
 
开发者ID:vijayrajak,项目名称:JenaKBClient,代码行数:21,代码来源:KBIndividualImplTest.java

示例6: getInverseProperty

import com.hp.hpl.jena.ontology.OntProperty; //导入依赖的package包/类
/**
 * Returns the inverse property of the property with given URI
 * @param uri
 * @return
 */
public Label getInverseProperty(String uri) {
	ObjectProperty op = ontModel.getObjectProperty(uri);
	if (op == null)
		return null;
	OntProperty inverseProp = null; 
	try {
		inverseProp = op.getInverse();
	} catch (ConversionException e) {
		logger.error(e.getMessage());
	}
	if (inverseProp != null) {
		return getUriLabel(inverseProp.getURI());
	}
	else
		return null;
}
 
开发者ID:therelaxist,项目名称:spring-usc,代码行数:22,代码来源:OntologyHandler.java

示例7: getInverseOfProperty

import com.hp.hpl.jena.ontology.OntProperty; //导入依赖的package包/类
/**
 * Returns the inverseOf property of the property with given URI
 * @param uri
 * @return
 */
public Label getInverseOfProperty(String uri) {
	ObjectProperty op = ontModel.getObjectProperty(uri);
	if (op == null)
		return null;
	OntProperty inverseOfProp = null;
	try {
		inverseOfProp = op.getInverse();
	} catch (ConversionException e) {
		logger.error(e.getMessage());
	}
	if (inverseOfProp != null) {
		return getUriLabel(inverseOfProp.getURI());
	}
	else
		return null;
}
 
开发者ID:therelaxist,项目名称:spring-usc,代码行数:22,代码来源:OntologyHandler.java

示例8: tripleHasDecimalObject

import com.hp.hpl.jena.ontology.OntProperty; //导入依赖的package包/类
private boolean tripleHasDecimalObject(TripleElement gpe) {
	Node pred = gpe.getPredicate();
	Node obj = gpe.getObject();
	if (!(obj instanceof NamedNode) && pred instanceof NamedNode && ((NamedNode)pred).getNamespace() != null) {
		OntProperty prop = getTheModel().getOntProperty(((NamedNode)pred).toFullyQualifiedString());
		if (prop != null && prop.isDatatypeProperty()) {
			Resource rng = prop.getRange();
			if (rng.toString().contains("double") || rng.toString().contains("float")) {
				return true;
			}
		}
	}
	if (obj instanceof Literal) {
		Object objval = ((Literal)obj).getValue();
		if (objval instanceof Double || objval instanceof Float) {
			return true;
		}
	}
	return false;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:21,代码来源:JenaTranslatorPlugin.java

示例9: getOntProperty

import com.hp.hpl.jena.ontology.OntProperty; //导入依赖的package包/类
private OntProperty getOntProperty(ConceptName propName) {
	Resource ir;
	try {
		ir = getOntResourceInExistingModel(propName);
		if (ir != null) {
			if (logger.isDebugEnabled()) {
				exploreProperty(ir.as(OntProperty.class));
			}

			ConceptType it = getOntResourceConceptType(ir);
			if (it.equals(ConceptType.ANNOTATIONPROPERTY)) {
				return ir.as(AnnotationProperty.class);
			}
			else if (it.equals(ConceptType.OBJECTPROPERTY)) {
				return ir.as(ObjectProperty.class);
			}
			else if (it.equals(ConceptType.DATATYPEPROPERTY)) {
				return ir.as(DatatypeProperty.class);
			}
		}
	} catch (ConfigurationException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:27,代码来源:ModelManager.java

示例10: getDomain

import com.hp.hpl.jena.ontology.OntProperty; //导入依赖的package包/类
public Object getDomain(ConceptName prop) {
	OntProperty pr = getOntProperty(prop);
	OntResource rr = getDomain(pr);
	if (rr != null) {
		if (rr.isURIResource()) {
			return rr.getURI();
		}
		else if (rr.isAnon()) {
			List<ConceptName> rngClasses = findAllUriResourcesInAnon(rr);
			return rngClasses;
		}
		else {
			addError(new ModelError("Unexpected range class: " + rr.toString(), ErrorType.ERROR));
		}
	}
	return null;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:18,代码来源:ModelManager.java

示例11: getRange

import com.hp.hpl.jena.ontology.OntProperty; //导入依赖的package包/类
public Object getRange(ConceptName prop) {
	OntProperty pr = getOntProperty(prop);
	OntResource rr = getRange(pr);
	if (rr != null) {
		if (rr.isURIResource()) {
			return rr.getURI();
		}
		else if (rr.isAnon()) {
			List<ConceptName> rngClasses = findAllUriResourcesInAnon(rr);
			return rngClasses;
		}
		else {
			addError(new ModelError("Unexpected range class: " + rr.toString(), ErrorType.ERROR));
		}
	}
	return null;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:18,代码来源:ModelManager.java

示例12: addFunctionalProperty

import com.hp.hpl.jena.ontology.OntProperty; //导入依赖的package包/类
/**
 * Call this method to make a functional property
 * 
 * @param prop
 * @return
 */
public List<ModelError> addFunctionalProperty(ConceptName prop) {
	OntProperty p = getOntProperty(prop);
	if (p == null) {
		addError(0, "Property '" + prop.toString()
				+ "' must exist before being declared functional.");
	} else {
		makePropertyFunctional(p);
		if (p.isObjectProperty()) {
			getJenaModel().createObjectProperty(p.getURI(), true);
		} else {
			getJenaModel().createDatatypeProperty(p.getURI(), true);
		}
	}
	return getErrorsFinal();
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:22,代码来源:ModelManager.java

示例13: createCardinalityRestriction

import com.hp.hpl.jena.ontology.OntProperty; //导入依赖的package包/类
private CardinalityRestriction createCardinalityRestriction(
		ConceptName prop, OntProperty p, int i,
		ClassRestrictionCondition rCond, int j) {
	if (p == null) {
		addError(2,
				"Cardinality restriction can't tell if property '" + prop + "' is object or data property.");
		return null;
	} else {
		int card = rCond.getRestrictedToCardinality();
		CardinalityRestriction cr = getJenaModel()
				.createCardinalityRestriction(null, p, card);
		if (cr != null && rCond.getRestrictedToObject() != null) {
			cr.removeAll(OWL.cardinality);
			cr.addLiteral(OWL2.qualifiedCardinality, new Integer(rCond.getRestrictedToCardinality()));
			OntClass qualifiedCls = conceptIdentifierToOntClass(i, j, (ConceptIdentifier) rCond.getRestrictedToObject());
			cr.addProperty(OWL2.onClass, qualifiedCls);
		}
		return cr;
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:21,代码来源:ModelManager.java

示例14: createMaxCardinalityRestriction

import com.hp.hpl.jena.ontology.OntProperty; //导入依赖的package包/类
private MaxCardinalityRestriction createMaxCardinalityRestriction(
		ConceptName prop, OntProperty p, int i,
		ClassRestrictionCondition rCond, int j) {
	if (p == null) {
		addError(2,
				"Max cardinality restriction can't tell if property '" + prop + "' is object or data property.");
		return null;
	} else {
		int card = rCond.getRestrictedToCardinality();
		MaxCardinalityRestriction cr = getJenaModel()
				.createMaxCardinalityRestriction(null, p, card);
		if (cr != null && rCond.getRestrictedToObject() != null) {
			cr.removeAll(OWL.maxCardinality);
			cr.addLiteral(OWL2.maxQualifiedCardinality, new Integer(rCond.getRestrictedToCardinality()));
			OntClass qualifiedCls = conceptIdentifierToOntClass(i, j, (ConceptIdentifier) rCond.getRestrictedToObject());
			cr.addProperty(OWL2.onClass, qualifiedCls);
		}
		return cr;
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:21,代码来源:ModelManager.java

示例15: createMinCardinalityRestriction

import com.hp.hpl.jena.ontology.OntProperty; //导入依赖的package包/类
private MinCardinalityRestriction createMinCardinalityRestriction(
		ConceptName prop, OntProperty p, int i,
		ClassRestrictionCondition rCond, int j) {
	if (p == null) {
		addError(2,
				"Min cardinality restriction can't tell if property '" + prop + "' is object or data property.");
		return null;
	} else {
		int card = rCond.getRestrictedToCardinality();
		MinCardinalityRestriction cr = getJenaModel()
				.createMinCardinalityRestriction(null, p, card);
		if (cr != null && rCond.getRestrictedToObject() != null) {
			cr.removeAll(OWL.minCardinality);
			cr.addLiteral(OWL2.minQualifiedCardinality, new Integer(rCond.getRestrictedToCardinality()));
			OntClass qualifiedCls = conceptIdentifierToOntClass(i, j, (ConceptIdentifier) rCond.getRestrictedToObject());
			cr.addProperty(OWL2.onClass, qualifiedCls);
		}
		return cr;
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:21,代码来源:ModelManager.java


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