// System.out.println(solutions);
try {
String varname;
QuerySolution sol;
final QueryResult result = QueryResult.createInstance();
Bindings binding;
// System.out.println(solutions.hasNext());
while (solutions.hasNext()) {
sol = solutions.nextSolution();
binding = new BindingsMap(); // Bindings.createNewInstance();
final Iterator<String> it = sol.varNames();
while (it.hasNext()) {
varname = it.next();
if (sol.contains(varname)) {
if (sol.get(varname).isLiteral()) {
if (sol.getLiteral(varname).getDatatypeURI() != null)
binding
.add(
new Variable(varname),
TypedLiteralOriginalContent
.createTypedLiteral(
"\""
+ sol
.getLiteral(
varname)
.getLexicalForm()
+ "\"",
"<"
+ sol
.getLiteral(
varname)
.getDatatypeURI()
+ ">"));
else {
if (sol.getLiteral(varname).getLanguage() != null
&& sol.getLiteral(varname)
.getLanguage().length() > 0) {
binding
.add(
new Variable(varname),
lupos.datastructures.items.literal.LiteralFactory
.createLanguageTaggedLiteral(
"\""
+ sol
.getLiteral(
varname)
.getLexicalForm()
+ "\"",
sol
.getLiteral(
varname)
.getLanguage()));
} else
binding
.add(
new Variable(varname),
lupos.datastructures.items.literal.LiteralFactory
.createLiteral("\""
+ sol
.getLiteral(
varname)
.getLexicalForm()
+ "\""));
}
} else {
if (sol.get(varname).isAnon())
binding
.add(
new Variable(varname),
new lupos.datastructures.items.literal.AnonymousLiteral(
sol
.getResource(
varname)
.toString()));
else
binding
.add(
new Variable(varname),
lupos.datastructures.items.literal.LiteralFactory
.createURILiteral("<"
+ sol