當前位置: 首頁>>代碼示例>>Java>>正文


Java Resource.getProperty方法代碼示例

本文整理匯總了Java中com.hp.hpl.jena.rdf.model.Resource.getProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java Resource.getProperty方法的具體用法?Java Resource.getProperty怎麽用?Java Resource.getProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hp.hpl.jena.rdf.model.Resource的用法示例。


在下文中一共展示了Resource.getProperty方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: open

import com.hp.hpl.jena.rdf.model.Resource; //導入方法依賴的package包/類
public Object open(Assembler ignore, Resource description, Mode ignore2) {
	if (!description.hasProperty(D2RQ.mappingFile)) {
		throw new D2RQException("Error in assembler specification " + description + ": missing property d2rq:mappingFile");
	}
	if (!description.getProperty(D2RQ.mappingFile).getObject().isURIResource()) {
		throw new D2RQException("Error in assembler specification " + description + ": value of d2rq:mappingFile must be a URI");
	}
	String mappingFileURI = ((Resource) description.getProperty(D2RQ.mappingFile).getObject()).getURI();
	String resourceBaseURI = null;
	Statement stmt = description.getProperty(D2RQ.resourceBaseURI);
	if (stmt != null) {
		if (!stmt.getObject().isURIResource()) {
			throw new D2RQException("Error in assembler specification " + description + ": value of d2rq:resourceBaseURI must be a URI");
		}
		resourceBaseURI = ((Resource) stmt.getObject()).getURI();
	}
	return new ModelD2RQ(mappingFileURI, resourceBaseURI);
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:19,代碼來源:D2RQAssembler.java

示例2: open

import com.hp.hpl.jena.rdf.model.Resource; //導入方法依賴的package包/類
public Object open(Assembler ignore, Resource description, Mode ignore2) {
	if (!description.hasProperty(D2RQ.mappingFile)) {
		throw new D2RQException("Error in assembler specification " + description + ": missing property d2rq:mappingFile");
	}
	if (!description.getProperty(D2RQ.mappingFile).getObject().isURIResource()) {
		throw new D2RQException("Error in assembler specification " + description + ": value of d2rq:mappingFile must be a URI");
	}
	String mappingFileURI = ((Resource) description.getProperty(D2RQ.mappingFile).getObject()).getURI();
	String resourceBaseURI = null;
	Statement stmt = description.getProperty(D2RQ.resourceBaseURI);
	if (stmt != null) {
		if (!stmt.getObject().isURIResource()) {
			throw new D2RQException("Error in assembler specification " + description + ": value of d2rq:resourceBaseURI must be a URI");
		}
		resourceBaseURI = ((Resource) stmt.getObject()).getURI();
	}
	return new ModelD2RQ(mappingFileURI, null, resourceBaseURI);
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:19,代碼來源:D2RQAssembler.java

示例3: getBestLabel

import com.hp.hpl.jena.rdf.model.Resource; //導入方法依賴的package包/類
public static Statement getBestLabel(Resource resource) {
	Statement label = resource.getProperty(RDFS.label);
	if (label == null)
		label = resource.getProperty(SKOS.prefLabel);
	if (label == null)
		label = resource.getProperty(DC.title);
	if (label == null)
		label = resource.getProperty(DCTerms.title);
	if (label == null)
		label = resource.getProperty(FOAF.name);
	return label;
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:13,代碼來源:PageServlet.java

示例4: retrieveList2

import com.hp.hpl.jena.rdf.model.Resource; //導入方法依賴的package包/類
private List<Statement> retrieveList2(List<Statement> statements,Statement s){
	statements.add(s);
	Resource list=s.getSubject();
	Statement st = list.getProperty(RDF.rest);
	statements.add(st);
	if (st.getObject() instanceof Resource && ((Resource)st.getObject()).getProperty(RDF.first)!=null){
		statements=retrieveList2(statements,((Resource)st.getObject()).getProperty(RDF.first));
	}
	return statements;
}
 
開發者ID:BenzclyZhang,項目名稱:BimSPARQL,代碼行數:11,代碼來源:IfcSemanticExtractor.java

示例5: listRelatedStatements

import com.hp.hpl.jena.rdf.model.Resource; //導入方法依賴的package包/類
private HashSet<Statement> listRelatedStatements(Resource r) {
	HashSet<Statement> statements = new HashSet<Statement>();
	StmtIterator st1 = model.listStatements(r, null, (RDFNode) null);
	StmtIterator st3 = model.listStatements(null, null, r);
	StmtIterator stmt = model.listStatements(null, model.getProperty(Namespace.LIST+"hasContents"), r);
	while (stmt.hasNext()) {
		Statement s = stmt.next();
		Resource list = s.getSubject();
		if (list.getProperty(model.getProperty(Namespace.LIST+"hasNext"))!=null) {
			statements.add(list.getProperty(model.getProperty(Namespace.LIST+"hasNext")));
			statements.add(list.getProperty(RDF.type));
			StmtIterator st = model.listStatements(null, model.getProperty(Namespace.LIST+"hasNext"), list);
			while (st.hasNext()) {
				statements.addAll(retrieveList(new HashSet<Statement>(),
						st.next()));
			}
		}

	}

	while (st1.hasNext()) {
		Statement statement=st1.next();
		statements.add(statement);
           if(statement.getObject() instanceof Resource){ 
               statements=removePrimaryTypes(statements,statement);
           	if (((Resource)statement.getObject()).getProperty(HASCONTENTS)!=null){
           	statements.addAll(retrieveList2(new HashSet<Statement>(),((Resource)statement.getObject()).getProperty(HASCONTENTS)));
           	}
           }
	}
	while (st3.hasNext()) {
		statements.add(st3.next());
	}
	return statements;
}
 
開發者ID:BenzclyZhang,項目名稱:BimSPARQL,代碼行數:36,代碼來源:GeometryTripleExtractor.java

示例6: removePrimaryTypes

import com.hp.hpl.jena.rdf.model.Resource; //導入方法依賴的package包/類
private HashSet<Statement> removePrimaryTypes(HashSet<Statement> statements, Statement statement){
   	Resource object=(Resource)statement.getObject();
   	Statement s=object.getProperty(HASBOOLEAN);
   	if(s!=null){
   		statements.add(s);
   		statements.add(object.getProperty(RDF.type));
   	}
   	s=object.getProperty(HASSTRING);
   	if(s!=null){
   		statements.add(s);
   		statements.add(object.getProperty(RDF.type));
   	}
   	s=object.getProperty(HASDOUBLE);
   	if(s!=null){
   		statements.add(s);
   		statements.add(object.getProperty(RDF.type));
   	}
   	s=object.getProperty(HASLOGICAL);
   	if(s!=null){
   		statements.add(s);
   		statements.add(object.getProperty(RDF.type));
   	}
   	s=object.getProperty(HASINTEGER);
   	if(s!=null){
   		statements.add(s);
   		statements.add(object.getProperty(RDF.type));
   	}
   	s=object.getProperty(HASHEXBINARY);
   	if(s!=null){
   		statements.add(s);
   		statements.add(object.getProperty(RDF.type));
   	}
	return statements;
}
 
開發者ID:BenzclyZhang,項目名稱:BimSPARQL,代碼行數:35,代碼來源:GeometryTripleExtractor.java

示例7: retrieveList2

import com.hp.hpl.jena.rdf.model.Resource; //導入方法依賴的package包/類
private HashSet<Statement> retrieveList2(HashSet<Statement> statements,Statement s){
	statements.add(s);
	statements=removePrimaryTypes(statements,s);
	Resource list=s.getSubject();
	statements.add(list.getProperty(RDF.type));
	Statement st = list.getProperty(model.getProperty(Namespace.LIST+"hasNext"));
	if(st!=null){
	statements.add(st);
	if (st.getObject() instanceof Resource && ((Resource)st.getObject()).getProperty(model.getProperty(Namespace.LIST+"hasContents"))!=null){
		statements=retrieveList2(statements,((Resource)st.getObject()).getProperty(model.getProperty(Namespace.LIST+"hasContents")));
	}
	}
	return statements;
}
 
開發者ID:BenzclyZhang,項目名稱:BimSPARQL,代碼行數:15,代碼來源:GeometryTripleExtractor.java

示例8: doGet

import com.hp.hpl.jena.rdf.model.Resource; //導入方法依賴的package包/類
protected void doGet(HttpServletRequest request,
		HttpServletResponse response) throws IOException, ServletException {
	D2RServer server = D2RServer.fromServletContext(getServletContext());
	server.checkMappingFileChanged();
	String relativeResourceURI = request.getRequestURI().substring(
			request.getContextPath().length()
					+ request.getServletPath().length());
	// Some servlet containers keep the leading slash, some don't
	if (!"".equals(relativeResourceURI)
			&& "/".equals(relativeResourceURI.substring(0, 1))) {
		relativeResourceURI = relativeResourceURI.substring(1);
	}
	if (request.getQueryString() != null) {
		relativeResourceURI = relativeResourceURI + "?"
				+ request.getQueryString();
	}

	/* Determine service stem, i.e. vocab/ in /[vocab/]data */
	int servicePos;
	if (-1 == (servicePos = request.getServletPath().indexOf(
			"/" + D2RServer.getDataServiceName())))
		throw new ServletException("Expected to find service path /"
				+ D2RServer.getDataServiceName());
	String serviceStem = request.getServletPath().substring(1,
			servicePos + 1);

	String resourceURI = RequestParamHandler
			.removeOutputRequestParam(server.resourceBaseURI(serviceStem)
					+ relativeResourceURI);
	String documentURL = server.dataURL(serviceStem, relativeResourceURI);

	String pageURL = server.pageURL(serviceStem, relativeResourceURI);

	String sparqlQuery = "DESCRIBE <" + resourceURI + ">";
	QueryExecution qe = QueryExecutionFactory.create(sparqlQuery,
			server.dataset());
	if (server.getConfig().getPageTimeout() > 0) {
		qe.setTimeout(Math.round(server.getConfig().getPageTimeout() * 1000));
	}
	Model description = qe.execDescribe();
	qe.close();
	
	if (description.size() == 0) {
		response.sendError(404);
	}
	if (description.qnameFor(FOAF.primaryTopic.getURI()) == null
			&& description.getNsPrefixURI("foaf") == null) {
		description.setNsPrefix("foaf", FOAF.NS);
	}
	Resource resource = description.getResource(resourceURI);

	Resource document = description.getResource(documentURL);
	document.addProperty(FOAF.primaryTopic, resource);

	Statement label = resource.getProperty(RDFS.label);
	if (label != null) {
		document.addProperty(RDFS.label,
				"RDF Description of " + label.getString());
	}
	server.addDocumentMetadata(description, document);
	if (server.getConfig().serveMetadata()) {
		// add document metadata from template
		Model resourceMetadataTemplate = server.getConfig().getResourceMetadataTemplate(
				server, getServletContext());
		MetadataCreator resourceMetadataCreator = new MetadataCreator(
				server, resourceMetadataTemplate);
		description.add(resourceMetadataCreator.addMetadataFromTemplate(
				resourceURI, documentURL, pageURL));
		
		Map<String, String> descPrefixes = description.getNsPrefixMap();
		descPrefixes.putAll(resourceMetadataTemplate.getNsPrefixMap());
		description.setNsPrefixes(descPrefixes);
	}
	// TODO: Add a Content-Location header
	new ModelResponse(description, request, response).serve();
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:77,代碼來源:ResourceDescriptionServlet.java

示例9: listRelatedStatements

import com.hp.hpl.jena.rdf.model.Resource; //導入方法依賴的package包/類
private List<Statement> listRelatedStatements(Resource r) {
	List<Statement> statements = new ArrayList<Statement>();
	StmtIterator st1 = model.listStatements(r, null, (RDFNode) null);
	StmtIterator st2 = model.listStatements(r, null, (String) null);
	StmtIterator st3 = model.listStatements(null, null, r);
	StmtIterator stmt = model.listStatements(null, RDF.first, r);
	while (stmt.hasNext()) {
		Statement s = stmt.next();
		Resource list = s.getSubject();
		if (list.getProperty(RDF.rest)!=null && list.getProperty(RDF.rest).getObject().equals(RDF.nil)) {
			statements.add(list.getProperty(RDF.rest));
			StmtIterator st = model.listStatements(null, RDF.rest, list);
			while (st.hasNext()) {
				statements.addAll(retrieveList(new ArrayList<Statement>(),
						st.next()));
			}
		}

	}

	while (st1.hasNext()) {
		Statement statement=st1.next();
		statements.add(statement);
           if(statement.getObject() instanceof Resource){ 
           	if (((Resource)statement.getObject()).getProperty(RDF.value)!=null){
           	statements.add(statement.getObject().asResource().getProperty(RDF.value));
           	statements.add(statement.getObject().asResource().getProperty(RDF.type));

           }            	if (((Resource)statement.getObject()).getProperty(RDF.first)!=null){
           	statements.addAll(retrieveList2(new ArrayList<Statement>(),((Resource)statement.getObject()).getProperty(RDF.first)));
           	}
           }
	}
	while (st2.hasNext()) {
		statements.add(st2.next());
	}
	while (st3.hasNext()) {
		statements.add(st3.next());
	}
	return statements;
}
 
開發者ID:BenzclyZhang,項目名稱:BimSPARQL,代碼行數:42,代碼來源:IfcSemanticExtractor.java

示例10: singleValueInference

import com.hp.hpl.jena.rdf.model.Resource; //導入方法依賴的package包/類
private void singleValueInference(Resource property,String propertyName,String propertyType){
	
	String lastTP=new String();
       if(propertyType.equals("Q_LENGTH")){
       	lastTP="?p ifcowl:lengthValue_IfcQuantityLength ?val .\n";
       }
       else if(propertyType.equals("Q_WEIGHT")){
       	lastTP="?p ifcowl:weightValue_IfcQuantityWeight ?val .\n";
       }
       else if(propertyType.equals("Q_TIME")){
       	lastTP="?p ifcowl:timeValue_IfcQuantityTime ?val .\n";
       }
       else if(propertyType.equals("Q_AREA")){
       	lastTP="?p ifcowl:areaValue_IfcQuantityArea ?val .\n";
       }
       else if(propertyType.equals("Q_COUNT")){
       	lastTP="?p ifcowl:countValue_IfcQuantityCount ?val .\n";
       }else if (propertyType.equals("Q_VOLUME")){
       	lastTP="?p ifcowl:volumeValue_IfcQuantityVolume ?val .\n";
       }

       if(lastTP.length()>0){
	String query="SELECT ?str\n"
			+	"WHERE {\n"
		  + " ?arg1 schm:hasQuantity ?p .\n"
		    +"?p ifcowl:name_IfcPhysicalQuantity ?name .\n"
		   + "?name express:hasString \""+propertyName+"\" .\n"
		   +lastTP
		   +"?val express:hasDouble ?str ."
		+"}";	
		
		if(property.getProperty(SPIN.body)==null){
			Query q=ARQ2SPIN.parseQuery(query, model);
		property.addProperty(SPIN.body, q);
		Resource bnode=model.createResource();
		bnode.addProperty(RDF.type, SPL.Argument);
		bnode.addProperty(SPL.predicate,SP.arg1);
		bnode.addProperty(SPL.valueType, RDFS.Resource);
		property.addProperty(SPIN.constraint,bnode);
		}
       }
}
 
開發者ID:BenzclyZhang,項目名稱:BimSPARQL,代碼行數:43,代碼來源:QuantityParser.java


注:本文中的com.hp.hpl.jena.rdf.model.Resource.getProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。