Class SPARQLQueries
java.lang.Object
org.eclipse.rdf4j.query.parser.sparql.SPARQLQueries
Utility functions for working with SPARQL query strings.
- Author:
- Jeen Broekstra
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Escape the supplied string with backslashes for any special characters, so it can be used as a string literal value in a SPARQL query.static String
getPrefixClauses
(Iterable<Namespace> namespaces) Creates a string representing of the suppliednamespaces
as SPARQL prefix declarations.static String
Un-escapes a backslash-escaped SPARQL literal value string.
-
Constructor Details
-
SPARQLQueries
public SPARQLQueries()
-
-
Method Details
-
getPrefixClauses
Creates a string representing of the suppliednamespaces
as SPARQL prefix declarations. This can be used when composing a SPARQL query string in code, for example:String query = SPARQLQueries.getPrefixClauses(connection.getNamespaces()) + "SELECT * WHERE { ?s ex:myprop ?o }";
- Parameters:
namespaces
- one or moreNamespace
objects.- Returns:
- one or more SPARQL prefix declarations (each separated by a newline), as a String.
- Since:
- 3.6.0
-
escape
-
unescape
Un-escapes a backslash-escaped SPARQL literal value string. Any recognized \-escape sequences are substituted with their un-escaped value.- Parameters:
s
- An SPARQL literal string with backslash escapes.- Returns:
- The un-escaped string.
- Throws:
IllegalArgumentException
- If the supplied string is not a correctly escaped SPARQL string.- Since:
- 3.6.0
- See Also:
-