public interface SPARQLBindings extends java.util.Map<java.lang.String,java.util.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(java.lang.String name,
java.lang.String value)
Bind a variable of type iri.
|
SPARQLBindings |
bind(java.lang.String name,
java.lang.String value,
java.util.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(java.lang.String name,
java.lang.String value, RDFTypes datatype)
Bind a variable of specified type.
|
SPARQLBindings bind(java.lang.String name, java.lang.String value)
Bind a variable of type iri.
name - the bound variable namevalue - the iri valueSPARQLBindings bind(java.lang.String name, java.lang.String value, RDFTypes datatype)
Bind a variable of specified type.
name - the bound variable namevalue - the value of the literaldatatype - the literal typeSPARQLBindings bind(java.lang.String name, java.lang.String value, java.util.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 © 2024 MarkLogic Corporation. All Rights Reserved.