@Override public Object visit(ASTQName qnameNode, Object data) throws VisitorException { String qname = qnameNode.getValue(); int colonIdx = qname.indexOf(':'); assert colonIdx >= 0 : "colonIdx should be >= 0: " + colonIdx; String prefix = qname.substring(0, colonIdx); String localName = qname.substring(colonIdx + 1); String namespace = prefixMap.get(prefix); if (namespace == null) { throw new VisitorException("QName '" + qname + "' uses an undefined prefix"); } localName = processEscapes(localName); // Replace the qname node with a new IRI node in the parent node ASTIRI iriNode = new ASTIRI(SyntaxTreeBuilderTreeConstants.JJTIRI); iriNode.setValue(namespace + localName); qnameNode.jjtReplaceWith(iriNode); return null; }
@Override public ValueConstant visit(ASTIRI node, Object data) throws VisitorException { IRI uri; try { uri = valueFactory.createIRI(node.getValue()); } catch (IllegalArgumentException e) { // invalid URI throw new VisitorException(e.getMessage()); } return new ValueConstant(uri); }
public Object visit(ASTIRI node, Object data) throws VisitorException { return node.childrenAccept(this, data); }
@Override public Object visit(final ASTQName qnameNode, final Object data) throws VisitorException { final String qname = qnameNode.getValue(); final int colonIdx = qname.indexOf(':'); assert colonIdx >= 0 : "colonIdx should be >= 0: " + colonIdx; final String prefix = qname.substring(0, colonIdx); String localName = qname.substring(colonIdx + 1); String namespace = this.namespacesOut.get(prefix); if (namespace == null) { // [FC] added lookup of default namespace namespace = this.namespacesIn.get(prefix); } if (namespace == null) { throw new VisitorException("QName '" + qname + "' uses an undefined prefix"); } localName = processEscapesAndHex(localName); final ASTIRI iriNode = new ASTIRI(SyntaxTreeBuilderTreeConstants.JJTIRI); iriNode.setValue(namespace + localName); qnameNode.jjtReplaceWith(iriNode); return null; }
private static Map<String, String> parseHelper(final ASTOperationContainer qc) throws MalformedQueryException { final List<ASTPrefixDecl> prefixDeclList = qc.getPrefixDeclList(); final Map<String, String> prefixMap = new LinkedHashMap<String, String>(); for (final ASTPrefixDecl prefixDecl : prefixDeclList) { final String prefix = prefixDecl.getPrefix(); final String iri = prefixDecl.getIRI().getValue(); if (prefixMap.containsKey(prefix)) { throw new MalformedQueryException("Multiple prefix declarations for prefix '" + prefix + "'"); } prefixMap.put(prefix, iri); } final QNameProcessor visitor = new QNameProcessor(prefixMap); try { qc.jjtAccept(visitor, null); } catch (final VisitorException e) { throw new MalformedQueryException(e); } return prefixMap; }
@Override public Object visit(final ASTQName qnameNode, final Object data) throws VisitorException { final String qname = qnameNode.getValue(); final int colonIdx = qname.indexOf(':'); assert colonIdx >= 0 : "colonIdx should be >= 0: " + colonIdx; final String prefix = qname.substring(0, colonIdx); String localName = qname.substring(colonIdx + 1); String namespace = this.prefixMap.get(prefix); if (namespace == null) { // [FC] added lookup of default namespace namespace = Data.getNamespaceMap().get(prefix); } if (namespace == null) { throw new VisitorException("QName '" + qname + "' uses an undefined prefix"); } localName = processEscapesAndHex(localName); final ASTIRI iriNode = new ASTIRI(SyntaxTreeBuilderTreeConstants.JJTIRI); iriNode.setValue(namespace + localName); qnameNode.jjtReplaceWith(iriNode); return null; }
uri = SimpleValueFactory.getInstance().createIRI(astIri.getValue());
final public void IRI() throws ParseException { /*@bgen(jjtree) IRI */ ASTIRI jjtn000 = new ASTIRI(JJTIRI); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);Token t; try { t = jj_consume_token(Q_IRI_REF); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.setValue(_trimString(t.image, 1)); } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } }
@Override public ValueConstant visit(ASTRDFLiteral node, Object data) throws VisitorException { String label = (String)node.getLabel().jjtAccept(this, null); String lang = node.getLang(); ASTIRI datatypeNode = node.getDatatype(); Literal literal; if (datatypeNode != null) { IRI datatype; try { datatype = valueFactory.createIRI(datatypeNode.getValue()); } catch (IllegalArgumentException e) { // invalid URI throw new VisitorException(e.getMessage()); } literal = valueFactory.createLiteral(label, datatype); } else if (lang != null) { literal = valueFactory.createLiteral(label, lang); } else { literal = valueFactory.createLiteral(label); } return new ValueConstant(literal); }
final public void Verb() throws ParseException { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case Q_IRI_REF: case PNAME_NS: case PNAME_LN: case VAR1: case VAR2: VarOrIRIref(); break; case IS_A: jj_consume_token(IS_A); ASTIRI jjtn001 = new ASTIRI(JJTIRI); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { jjtree.closeNodeScope(jjtn001, true); jjtc001 = false; jjtn001.setValue(RDF.TYPE.toString()); } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, true); } } break; default: jj_la1[94] = jj_gen; jj_consume_token(-1); throw new ParseException(); } }
for (final ASTPrefixDecl prefixDecl : prefixDeclList) { final String prefix = prefixDecl.getPrefix(); final String iri = prefixDecl.getIRI().getValue(); if (prefixes.containsKey(prefix)) { throw new MalformedQueryException("Multiple prefix declarations for prefix '"
String iri = prefixDecl.getIRI().getValue();
case IS_A: jj_consume_token(IS_A); ASTIRI jjtn001 = new ASTIRI(JJTIRI); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); jjtree.closeNodeScope(jjtn001, true); jjtc001 = false; jjtn001.setValue(RDF.TYPE.toString()); } finally { if (jjtc001) { case IS_A: jj_consume_token(IS_A); ASTIRI jjtn002 = new ASTIRI(JJTIRI); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); jjtree.closeNodeScope(jjtn002, true); jjtc002 = false; jjtn002.setValue(RDF.TYPE.toString()); } finally { if (jjtc002) {