Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Setting string literal with dollar sign in ParameterizedSparqlString

$
0
0
Hey,

I'm using the following code to build a SPARQL query that will check
user credentials:

QuerySolutionMap qsm = new QuerySolutionMap();
qsm.add("name", ResourceFactory.createTypedLiteral(username));
qsm.add("password", ResourceFactory.createTypedLiteral(passwordHash));
ParameterizedSparqlString queryString = new
ParameterizedSparqlString(sparqlString, qsm);
Query query = queryString.asQuery();

The passwordHash might contain $ characters, in which case I get the
following exception:

java.lang.IllegalArgumentException: Illegal group reference
java.util.regex.Matcher.appendReplacement(Matcher.java:808)
java.util.regex.Matcher.replaceAll(Matcher.java:906)
com.hp.hpl.jena.query.ParameterizedSparqlString.toString(ParameterizedSparqlString.java:616)
com.hp.hpl.jena.query.ParameterizedSparqlString.asQuery(ParameterizedSparqlString.java:654)

I read about the issue and tried to escape the replacement string:

passwordHash = Matcher.quoteReplacement(passwordHash)

However, this did not solve the problem. I take it's a regexp issue.
Any ideas on how to work around it?

Martynas
graphityhq.com

Viewing all articles
Browse latest Browse all 5648

Trending Articles