/* * See http://www.w3.org/TR/rdf-sparql-query paragraph 11.4.4 * * "(STR) Returns the lexical form of a literal; returns the codepoint representation of an IRI." * * @see http://www.w3.org/TR/rdf-sparql-query */ private void convertStr(E_Str expr) { logger.debug("convertStr " + expr.toString()); expr.getArg().visit(this); Expression arg = expression.pop(); if (arg instanceof AttributeExprEx) { // make a new AttributeExprEx with changed NodeMaker, which returns plain literal // TODO this seems to work, but needs more testing. AttributeExprEx attribute = (AttributeExprEx) arg; TypedNodeMaker nodeMaker = (TypedNodeMaker) attribute.getNodeMaker(); TypedNodeMaker newNodeMaker = new TypedNodeMaker( TypedNodeMaker.PLAIN_LITERAL, nodeMaker.valueMaker(), nodeMaker.isUnique()); logger.debug("changing nodemaker " + nodeMaker + " to " + newNodeMaker); expression.push( new AttributeExprEx((Attribute) attribute.attributes().iterator().next(), newNodeMaker)); } else if (arg instanceof ConstantEx) { ConstantEx constant = (ConstantEx) arg; Node node = constant.getNode(); String lexicalForm = node.getLiteral().getLexicalForm(); node = Node.createLiteral(lexicalForm); ConstantEx constantEx = new ConstantEx(NodeValue.makeNode(node).asString(), node); logger.debug("pushing " + constantEx); expression.push(constantEx); } else { conversionFailed(expr); } }