本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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 );
}
示例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");
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}