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


Java BindingSet.getBindingNames方法代碼示例

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


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

示例1: runSPARQL

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
/**
 * Execute a SELECT SPARQL query against the graph
 * 
 * @param qs
 *            SELECT SPARQL query
 * @return list of solutions, each containing a hashmap of bindings
 */
public List runSPARQL(String qs) {
	try {
		RepositoryConnection con = therepository.getConnection();
		try {
			TupleQuery query = con.prepareTupleQuery(org.openrdf.query.QueryLanguage.SPARQL, qs);
			TupleQueryResult qres = query.evaluate();
			ArrayList reslist = new ArrayList();
			while (qres.hasNext()) {
				BindingSet b = qres.next();
				Set names = b.getBindingNames();
				HashMap hm = new HashMap();
				for (Object n : names) {
					hm.put((String) n, b.getValue((String) n));
				}
				reslist.add(hm);
			}
			return reslist;
		} finally {
			con.close();
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:dvcama,項目名稱:resource-to-sparqlresult,代碼行數:33,代碼來源:SimpleGraph.java

示例2: takeCrossProduct

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
/**
 * This method compute the cross product of the BindingSet passed to the PCJ
 * and the PCJ BindingSet.  It verifies that only common variables are unassured
 * variables, and if leftBs and rightBs have distinct values for a given variable,
 * this method uses the value from leftBs in the cross product BindingSet - this
 * is effectively performing a LeftJoin.
 *
 * @param leftBs - BindingSet passed to PCJ
 * @param rightBs - PCJ BindingSet
 * @return - cross product BindingSet
 */
private BindingSet takeCrossProduct(BindingSet leftBs, BindingSet rightBs) {
	if (bindingSetsIntersect(leftBs, rightBs)) {
		return EMPTY_BINDINGSET;
	}
	QueryBindingSet bs = new QueryBindingSet(leftBs);

	//only add Bindings corresponding to variables that have no value
	//assigned.  This takes into account case where leftBs and rightBs
	//share a common, unAssuredVariable.  In this case, use value corresponding
	//to leftBs, which is effectively performing a LeftJoin.
	for(String s: rightBs.getBindingNames()) {
		if(bs.getValue(s) == null) {
			bs.addBinding(s, rightBs.getValue(s));
		}
	}
	return bs;
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:29,代碼來源:PCJKeyToCrossProductBindingSetIterator.java

示例3: getThingHasMetPlace

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
/**
 * This method is responsible for retrieving the Things that has met a specific place
 * The place is given as a parameter. This method is responsible for translating the 
 * SPARQL template query, and returning the desired values back to the user.
 * The values are returned in a list containing maps (key-value pairs).
 * 
 * @param place the specific place (either its URI or its name - depending on the template SPARQL query)
 * @return a list containing maps with key value pairs
 * @throws QueryExecutionException for any error that might occur during the execution of the query. */
public List<Map<String,String>> getThingHasMetPlace(String place) throws QueryExecutionException{
    List<Map<String,String>> retList=new ArrayList<>();
    String sparqlQuery=FundamentalQueriesResources.getSparqlQuery(FundamentalQueriesResources.THING_HAS_MET_PLACE, place);
    List<BindingSet> results=this.repoManager.query(sparqlQuery);
    logger.info("getThingHasMetPlace returned "+results.size()+" results");
    for(BindingSet result : results){
        Map<String,String> record=new HashMap<>();
        for(String param : result.getBindingNames()){
            record.put(param, result.getBinding(param).getValue().stringValue());
        }
        retList.add(record);
    }
    System.out.println("FQ QUERY"+sparqlQuery);
    return retList;
}
 
開發者ID:isl,項目名稱:LifeWatch_Greece,代碼行數:25,代碼來源:ThingService.java

示例4: handleTuple

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
@Override
public void handleTuple( BindingSet set, ValueFactory fac ) {
  Map<String, T> map = new HashMap<>();
  for ( String variable : set.getBindingNames() ) {
    map.put( variable, convertValue( variable, set.getValue( variable ), fac ) );
  }
  add( map );
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:9,代碼來源:ListOfMapsQueryAdapter.java

示例5: performSelect

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
protected Object performSelect(final String query, final String auth, final Boolean infer) throws RepositoryException, MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException {
    final TupleQuery tupleQuery = connection.prepareTupleQuery(
            QueryLanguage.SPARQL, query);
    if (auth != null && auth.length() > 0) {
        tupleQuery.setBinding(CONF_QUERY_AUTH, valueFactory.createLiteral(auth));
    }
    if (infer != null) {
        tupleQuery.setBinding(CONF_INFER, valueFactory.createLiteral(infer));
    }
    if (CbSailEndpoint.CbSailOutput.BINARY.equals(queryOutput)) {
        final List listOutput = new ArrayList();
        final TupleQueryResultHandlerBase handler = new TupleQueryResultHandlerBase() {
            @Override
            public void handleSolution(final BindingSet bindingSet) throws TupleQueryResultHandlerException {
                final Map<String, String> map = new HashMap<String, String>();
                for (final String s : bindingSet.getBindingNames()) {
                    map.put(s, bindingSet.getBinding(s).getValue().stringValue());
                }
                listOutput.add(map);
            }
        };
        tupleQuery.evaluate(handler);
        return listOutput;
    } else if (CbSailEndpoint.CbSailOutput.XML.equals(queryOutput)) {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final SPARQLResultsXMLWriter sparqlWriter = new SPARQLResultsXMLWriter(baos);
        tupleQuery.evaluate(sparqlWriter);
        return new String(baos.toByteArray(), StandardCharsets.UTF_8);
    } else {
        throw new IllegalArgumentException("Query Output[" + queryOutput + "] is not recognized");
    }
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:33,代碼來源:CbSailProducer.java

示例6: getActorMeasuredDimension

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
/**
 * This method is responsible for retrieving the Actors that measured specific dimensions.
 * The dimension is given as a parameter. This method is responsible for translating the 
 * SPARQL template query, and returning the desired values back to the user.
 * The values are returned in a list containing maps (key-value pairs).
 * 
 * @param dimension the given dimension (either its URI or its name - depending on the template SPARQL query)
 * @return the results as a list containing maps with key-value pairs
 * @throws QueryExecutionException for any error that might occur during the execution of the query. */
public List<Map<String,String>> getActorMeasuredDimension(String dimension) throws QueryExecutionException{
    List<Map<String,String>> retList=new ArrayList<>();
    String sparqlQuery=FundamentalQueriesResources.getSparqlQuery(FundamentalQueriesResources.ACTOR_MEASURED_DIMENSION, dimension);
    List<BindingSet> results=this.repoManager.query(sparqlQuery);
    logger.info("getActorFromTime returned "+results.size()+" results");
    for(BindingSet result : results){
        Map<String,String> record=new HashMap<>();
        for(String param : result.getBindingNames()){
            record.put(param, result.getBinding(param).getValue().stringValue());
        }
        retList.add(record);
    }
    return retList;
}
 
開發者ID:isl,項目名稱:LifeWatch_Greece,代碼行數:24,代碼來源:ActorService.java

示例7: removeConstants

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
private BindingSet removeConstants(BindingSet bs) {
	QueryBindingSet bSet = new QueryBindingSet();
	for (String s : bs.getBindingNames()) {
		if (!s.startsWith(ExternalTupleSet.CONST_PREFIX)) {
			bSet.addBinding(bs.getBinding(s));
		}
	}
	return bSet;
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:10,代碼來源:BindingSetHashJoinIterator.java

示例8: getDimensionByActor

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
/**
 * This method is responsible for retrieving the Dimension that are related to a specific actor. 
 * The actor is given as a parameter. This method is responsible for translating the 
 * SPARQL template query, and returning the desired values back to the user.
 * The values are returned in a list containing maps (key-value pairs).
 * 
 * @param actor the given actor (either its URI or its name - depending on the template SPARQL query)
 * @return a list containing maps with key value pairs
 * @throws QueryExecutionException for any error that might occur during the execution of the query. */
public List<Map<String,String>> getDimensionByActor(String actor) throws QueryExecutionException{
    List<Map<String,String>> retList=new ArrayList<>();
    String sparqlQuery=FundamentalQueriesResources.getSparqlQuery(FundamentalQueriesResources.DIMENSION_BY_ACTOR, actor);
    List<BindingSet> results=this.repoManager.query(sparqlQuery);
    logger.info("getDimensionByActor returned "+results.size()+" results");
    for(BindingSet result : results){
        Map<String,String> record=new HashMap<>();
        for(String param : result.getBindingNames()){
            record.put(param, result.getBinding(param).getValue().stringValue());
        }
        retList.add(record);
    }
    return retList;
}
 
開發者ID:isl,項目名稱:LifeWatch_Greece,代碼行數:24,代碼來源:DimensionService.java

示例9: bindingSetsIntersect

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
private boolean bindingSetsIntersect(BindingSet bs1, BindingSet bs2) {

		for(String s: bs1.getBindingNames()) {
			if(bs2.getValue(s) != null && !unAssuredVariables.contains(s)) {
				return true;
			}
		}
		return false;
	}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:10,代碼來源:PCJKeyToCrossProductBindingSetIterator.java

示例10: getThingFromPlace

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
/**
 * This method is responsible for retrieving the Things from the given place. 
 * The place is given as a parameter. This method is responsible for translating the 
 * SPARQL template query, and returning the desired values back to the user.
 * The values are returned in a list containing maps (key-value pairs).
 * 
 * @param place the place (either its URI or its name - depending on the template SPARQL query)
 * @return a list containing maps with key value pairs
 * @throws QueryExecutionException for any error that might occur during the execution of the query. */
public List<Map<String,String>> getThingFromPlace(String place) throws QueryExecutionException{
    List<Map<String,String>> retList=new ArrayList<>();
    String sparqlQuery=FundamentalQueriesResources.getSparqlQuery(FundamentalQueriesResources.THING_FROM_PLACE, place);
    List<BindingSet> results=this.repoManager.query(sparqlQuery);
    logger.info("getThingFromPlace returned "+results.size()+" results");
    for(BindingSet result : results){
        Map<String,String> record=new HashMap<>();
        for(String param : result.getBindingNames()){
            record.put(param, result.getBinding(param).getValue().stringValue());
        }
        retList.add(record);
    }
    return retList;
}
 
開發者ID:isl,項目名稱:LifeWatch_Greece,代碼行數:24,代碼來源:ThingService.java

示例11: getEventHasMetActor

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
/**
 * This method is responsible for retrieving the Event which has met a specific actor. 
 * The actor is given as a parameter. This method is responsible for translating the 
 * SPARQL template query, and returning the desired values back to the user.
 * The values are returned in a list containing maps (key-value pairs).
 * 
 * @param actor the given actor (either its URI or its name - depending on the template SPARQL query)
 * @return a list containing maps with key value pairs
 * @throws QueryExecutionException for any error that might occur during the execution of the query. */
public List<Map<String,String>> getEventHasMetActor(String actor) throws QueryExecutionException{
    List<Map<String,String>> retList=new ArrayList<>();
    String sparqlQuery=FundamentalQueriesResources.getSparqlQuery(FundamentalQueriesResources.EVENT_HAS_MET_ACTOR, actor);
    List<BindingSet> results=this.repoManager.query(sparqlQuery);
    logger.info("getEventHasMetActor returned "+results.size()+" results");
    for(BindingSet result : results){
        Map<String,String> record=new HashMap<>();
        for(String param : result.getBindingNames()){
            record.put(param, result.getBinding(param).getValue().stringValue());
        }
        retList.add(record);
    }
    return retList;
}
 
開發者ID:isl,項目名稱:LifeWatch_Greece,代碼行數:24,代碼來源:EventService.java

示例12: getDimensionOfPlace

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
/**
 * This method is responsible for retrieving the Dimension of a place. 
 * The place is given as a parameter. This method is responsible for translating the 
 * SPARQL template query, and returning the desired values back to the user.
 * The values are returned in a list containing maps (key-value pairs).
 * 
 * @param place the given place (either its URI or its name - depending on the template SPARQL query)
 * @return a list containing maps with key value pairs
 * @throws QueryExecutionException for any error that might occur during the execution of the query. */
public List<Map<String,String>> getDimensionOfPlace(String place) throws QueryExecutionException{
    List<Map<String,String>> retList=new ArrayList<>();
    String sparqlQuery=FundamentalQueriesResources.getSparqlQuery(FundamentalQueriesResources.DIMENSION_OF_PLACE, place);
    List<BindingSet> results=this.repoManager.query(sparqlQuery);
    logger.info("getDimensionOfPlace returned "+results.size()+" results");
    for(BindingSet result : results){
        Map<String,String> record=new HashMap<>();
        for(String param : result.getBindingNames()){
            record.put(param, result.getBinding(param).getValue().stringValue());
        }
        retList.add(record);
    }
    return retList;
}
 
開發者ID:isl,項目名稱:LifeWatch_Greece,代碼行數:24,代碼來源:DimensionService.java

示例13: setAll

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
public Builder setAll(final BindingSet bindings) {
    Arrays.fill(this.values, null);
    for (final String name : bindings.getBindingNames()) {
        set(name, bindings.getValue(name));
    }
    return this;
}
 
開發者ID:dkmfbk,項目名稱:knowledgestore,代碼行數:8,代碼來源:CompactBindingSet.java

示例14: getThingHasMetActor

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
/**
 * This method is responsible for retrieving the Things that has a specific actor 
 * The actor is given as a parameter. This method is responsible for translating the 
 * SPARQL template query, and returning the desired values back to the user.
 * The values are returned in a list containing maps (key-value pairs).
 * 
 * @param actor the specific actor (either its URI or its name - depending on the template SPARQL query)
 * @return a list containing maps with key value pairs
 * @throws QueryExecutionException for any error that might occur during the execution of the query. */
public List<Map<String,String>> getThingHasMetActor(String actor) throws QueryExecutionException{
    List<Map<String,String>> retList=new ArrayList<>();
    String sparqlQuery=FundamentalQueriesResources.getSparqlQuery(FundamentalQueriesResources.THING_HAS_MET_ACTOR, actor);
    List<BindingSet> results=this.repoManager.query(sparqlQuery);
    logger.info("getThingHasMetActor returned "+results.size()+" results");
    for(BindingSet result : results){
        Map<String,String> record=new HashMap<>();
        for(String param : result.getBindingNames()){
            record.put(param, result.getBinding(param).getValue().stringValue());
        }
        retList.add(record);
    }
    return retList;
}
 
開發者ID:isl,項目名稱:LifeWatch_Greece,代碼行數:24,代碼來源:ThingService.java

示例15: getDimensionByEvent

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
/**
 * This method is responsible for retrieving the Dimension that are related to a specific event. 
 * The event is given as a parameter. This method is responsible for translating the 
 * SPARQL template query, and returning the desired values back to the user.
 * The values are returned in a list containing maps (key-value pairs).
 * 
 * @param event the given event (either its URI or its name - depending on the template SPARQL query)
 * @return a list containing maps with key value pairs
 * @throws QueryExecutionException for any error that might occur during the execution of the query. */
public List<Map<String,String>> getDimensionByEvent(String event) throws QueryExecutionException{
    List<Map<String,String>> retList=new ArrayList<>();
    String sparqlQuery=FundamentalQueriesResources.getSparqlQuery(FundamentalQueriesResources.DIMENSION_BY_EVENT, event);
    List<BindingSet> results=this.repoManager.query(sparqlQuery);
    logger.info("getDimensionByEvent returned "+results.size()+" results");
    for(BindingSet result : results){
        Map<String,String> record=new HashMap<>();
        for(String param : result.getBindingNames()){
            record.put(param, result.getBinding(param).getValue().stringValue());
        }
        retList.add(record);
    }
    return retList;
}
 
開發者ID:isl,項目名稱:LifeWatch_Greece,代碼行數:24,代碼來源:DimensionService.java


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