Java Code Examples for org.openrdf.query.BindingSet#getBinding()
The following examples show how to use
org.openrdf.query.BindingSet#getBinding() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SPARQLUpdateTestv2.java From database with GNU General Public License v2.0 | 6 votes |
protected long debugPrintSolutions(final String query) throws QueryEvaluationException, RepositoryException, MalformedQueryException { TupleQueryResult result = con.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); try { long n = 0; while (result.hasNext()) { System.err.println("==> NEXT SOLUTION"); final BindingSet bset = result.next(); for (final String bindingName : bset.getBindingNames()) { final Binding b = bset.getBinding(bindingName); System.err.println(bindingName + " -> " + b); } n++; } return n; } finally { result.close(); } }
Example 2
Source File: GlobalSecurityValidator.java From blazegraph-samples with GNU General Public License v2.0 | 3 votes |
public GlobalSecurityValidator(final Repository repo) { final TupleQueryResult result; try { result = Utils.executeSelectQuery(repo, GRANTED_DOCUMENTS, QueryLanguage.SPARQL); while(result.hasNext()){ BindingSet bs = result.next(); Binding user = bs.getBinding("user"); Binding document = bs.getBinding("doc"); if(securityInfo.containsKey(user)){ securityInfo.get(user).add(document.getValue()); }else{ List<Value> docs = new LinkedList<Value>(); docs.add(document.getValue()); securityInfo.put(user.getValue(), docs); } } } catch (OpenRDFException e) { log.error("Security info was not collected", e); } }
Example 3
Source File: DescribeBindingsCollector.java From database with GNU General Public License v2.0 | 3 votes |
@Override public BindingSet next() throws QueryEvaluationException { if (!open) throw new QueryEvaluationException("Closed"); final BindingSet bs = src.next(); for (IVariable<?> var : originalVars) { final Binding binding = bs.getBinding(var.getName()); if (binding == null) continue; final BigdataValue boundValue = (BigdataValue) binding.getValue(); if (boundValue != null) { if(describedResources.add(boundValue)) { if(log.isInfoEnabled()) { log.info("Will describe: var=" + var + ",boundValue=" + boundValue); } } } } return bs; }
Example 4
Source File: GlobalSecurityValidator.java From blazegraph-samples with GNU General Public License v2.0 | 2 votes |
public GlobalSecurityValidator(final RemoteRepositoryManager m_repo) throws Exception { GraphQueryResult repoDescription = m_repo.getRepositoryDescriptions(); Set<String> namespaces = new HashSet<String>(); while (repoDescription.hasNext()) { Statement stmt = repoDescription.next(); if (stmt.getPredicate() .toString() .equals(SD.KB_NAMESPACE.stringValue())) { namespaces.add(stmt.getObject().stringValue()); } } TupleQueryResult result; for (String namespace : namespaces) { try { RemoteRepository repo = m_repo.getRepositoryForNamespace(namespace); result = repo.prepareTupleQuery(GRANTED_DOCUMENTS).evaluate(); while(result.hasNext()){ BindingSet bs = result.next(); Binding user = bs.getBinding("user"); Binding document = bs.getBinding("doc"); if(securityInfo.containsKey(user)){ securityInfo.get(user).add(document.getValue()); }else{ List<Value> docs = new LinkedList<Value>(); docs.add(document.getValue()); securityInfo.put(user.getValue(), docs); } } } catch (Exception e) { log.error("Security info was not collected", e); } } }