public interface SPARQLBindings extends Map<String,List<SPARQLBinding>>
Represents binding names and values to be sent with a SPARQL Query.
Available for situations where SPARQLQueryDefinition.withBinding methods are not enough.
Example matching an iri:
graphMgr.setDefaultMimetype(RDFMimeTypes.NTRIPLES);
graphMgr.writeAs("http://example.org",
"<http://example.org/s1> <http://example.org/p1> <http://example.org/object1> .\n" +
"<http://example.org/s2> <http://example.org/p2> \"object2\" .\n" +
"<http://example.org/s3> <http://example.org/p3> \"object3\"@en .");
String select = "SELECT * WHERE { ?s ?p ?o }";
SPARQLQueryDefinition qdef = sparqlMgr.newQueryDefinition(select);
SPARQLBindings bindings = qdef.getBindings();
bindings.bind("o", "http://example.org/object1");
JacksonHandle results = sparqlMgr.executeSelect(qdef, new JacksonHandle());
Example matching a literal of rdf data type string (re-using data and variables above):
qdef = sparqlMgr.newQueryDefinition(select);
bindings = qdef.getBindings();
bindings.bind("o", "object2", RDFTypes.STRING);
results = sparqlMgr.executeSelect(qdef, new JacksonHandle());
Example matching a string with a language tag (re-using data and variables above):
qdef = sparqlMgr.newQueryDefinition(select);
bindings = qdef.getBindings();
bindings.bind("o", "object3", new Locale("en"));
results = sparqlMgr.executeSelect(qdef, new JacksonHandle());
For more about RDF literals, see RDF 1.1 section 3.3.
For details about RDF, SPARQL, and semantics in MarkLogic see the Semantics Developer's Guide.
| Modifier and Type | Method and Description |
|---|---|
SPARQLBindings |
bind(String name,
String value)
Bind a variable of type iri.
|
SPARQLBindings |
bind(String name,
String value,
Locale languageTag)
Bind a variable of type
http://www.w3.org/1999/02/22-rdf-syntax-ns#langString with the specified
language tag.
|
SPARQLBindings |
bind(String name,
String value,
RDFTypes datatype)
Bind a variable of specified type.
|
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesSPARQLBindings bind(String name, String value)
Bind a variable of type iri.
name - the bound variable namevalue - the iri valueSPARQLBindings bind(String name, String value, RDFTypes datatype)
Bind a variable of specified type.
name - the bound variable namevalue - the value of the literaldatatype - the literal typeSPARQLBindings bind(String name, String value, Locale languageTag)
Bind a variable of type
http://www.w3.org/1999/02/22-rdf-syntax-ns#langString with the specified
language tag. Note that we call Locale.toLanguageTag()
to get compliant IETF BCP 47 language tags.
name - the bound variable namevalue - the value as a stringlanguageTag - the language and regional modifiers compliant with BCP-47Copyright © 2013-2016 MarkLogic Corporation.