public static void throwParseException(String msg, int line, int column) { throw new QueryParseException("Line " + line + ", column " + column + ": " + msg, line, column) ; } }
public static void throwParseException(String msg, int line, int column) { throw new QueryParseException("Line " + line + ", column " + column + ": " + msg, line, column) ; }
private static QueryParseException makeException(String msg, int line, int column) { return new QueryParseException(msg, line, column) ; }
private static QueryParseException makeException(String msg, int line, int column) { return new QueryParseException(msg, line, column) ; }
public static void throwParseException(String msg) { throw new QueryParseException(msg, -1, -1) ; }
protected void finishBindingValueRow(int line, int col) { //if ( variables.size() != currentValueRow().size() ) if ( currentColumn+1 != variables.size() ) { String msg = String.format("Mismatch: %d variables but %d values",variables.size(), currentColumn+1) ; msg = QueryParseException.formatMessage(msg, line, col) ; throw new QueryParseException(msg, line , col) ; } }
protected void finishDataBlockValueRow(int line, int col) { //if ( variables.size() != currentValueRow().size() ) if ( currentColumn+1 != variables.size() ) { String msg = String.format("Mismatch: %d variables but %d values",variables.size(), currentColumn+1) ; msg = QueryParseException.formatMessage(msg, line, col) ; throw new QueryParseException(msg, line , col) ; } }
private int makeMask(String modifiers) { if ( modifiers == null ) return 0 ; int newMask = 0 ; for ( int i = 0 ; i < modifiers.length() ; i++ ) { switch(modifiers.charAt(i)) { //case 'i' : newMask |= Pattern.CASE_INSENSITIVE; break ; case 'i' : // Need both (Java 1.4) newMask |= Pattern.UNICODE_CASE ; newMask |= Pattern.CASE_INSENSITIVE; break ; case 'm' : newMask |= Pattern.MULTILINE ; break ; case 's' : newMask |= Pattern.DOTALL ; break ; //case 'x' : newMask |= Pattern.; break ; default : throw new QueryParseException("Illegal flag in regex modifiers: "+modifiers.charAt(i), -1, -1) ; } } return newMask ; }
protected long integerValue(String s) { try { if ( s.startsWith("+") ) s = s.substring(1) ; if ( s.startsWith("0x") ) { // Hex s = s.substring(2) ; return Long.parseLong(s, 16) ; } return Long.parseLong(s) ; } catch (NumberFormatException ex) { try { // Possible too large for a long. BigInteger integer = new BigInteger(s) ; throwParseException("Number '"+s+"' is a valid number but can't not be stored in a long") ; } catch (NumberFormatException ex2) {} throw new QueryParseException(ex, -1, -1) ; } }
@Override public void visit(ElementBind el) { Var var = el.getVar() ; if ( acc.contains(var) ) throw new QueryParseException("Variable used when already in-scope: "+var+" in "+el, -1 , -1) ; checkAssignment(acc, el.getExpr(), var) ; }
private static void check(Collection<Var> scope, ElementBind el) { Var var = el.getVar() ; if ( scope.contains(var) ) throw new QueryParseException("BIND: Variable used when already in-scope: "+var+" in "+el, -1 , -1) ; checkAssignment(scope, el.getExpr(), var) ; }
private static void checkAssignment(Collection<Var> scope, Expr expr, Var var) { // Project SELECT ?x if ( expr == null ) return ; // expr not null if ( scope.contains(var) ) throw new QueryParseException("Variable used when already in-scope: "+var+" in "+fmtAssignment(expr, var), -1 , -1) ; // test for impossible variables - bound() is a bit odd. if ( false ) { Set<Var> vars = expr.getVarsMentioned() ; for ( Var v : vars ) { if ( !scope.contains(v) ) throw new QueryParseException("Variable used in expression is not in-scope: "+v+" in "+expr, -1 , -1) ; } } }
private static void checkAssignment(Collection<Var> scope, Expr expr, Var var) { // Project SELECT ?x if ( expr == null ) return ; // expr not null if ( scope.contains(var) ) throw new QueryParseException("Variable used when already in-scope: "+var+" in "+fmtAssignment(expr, var), -1 , -1) ; // test for impossible variables - bound() is a bit odd. if ( false ) { Set<Var> vars = expr.getVarsMentioned() ; for ( Var v : vars ) { if ( !scope.contains(v) ) throw new QueryParseException("Variable used in expression is not in-scope: "+v+" in "+expr, -1 , -1) ; } } }
@Override protected void check(Triple t) { if ( Var.isVar(getGraph()) ) throw new QueryParseException("Variables not permitted in data quad", -1, -1) ; if ( Var.isVar(t.getSubject()) || Var.isVar(t.getPredicate()) || Var.isVar(t.getObject())) throw new QueryParseException("Variables not permitted in data quad", -1, -1) ; if ( t.getSubject().isLiteral() ) throw new QueryParseException("Literals not allowed as subjects in data", -1, -1) ; }
private static void check(Collection<Var> scope, ElementService el) { if ( ARQ.isStrictMode() && el.getServiceNode().isVariable() ) { Var var = Var.alloc(el.getServiceNode()) ; if ( ! scope.contains(var) ) throw new QueryParseException("SERVICE: Variable not already in-scope: "+var+" in "+el, -1 , -1) ; } } }
@Override protected void check(Triple t) { if ( Var.isVar(getGraph()) ) throw new QueryParseException("Variables not permitted in data quad", -1, -1) ; if ( Var.isVar(t.getSubject()) || Var.isVar(t.getPredicate()) || Var.isVar(t.getObject())) throw new QueryParseException("Variables not permitted in data quad", -1, -1) ; }
@Override protected void check(Quad quad) { if ( Var.isVar(quad.getGraph()) || Var.isVar(quad.getSubject()) || Var.isVar(quad.getPredicate()) || Var.isVar(quad.getObject())) throw new QueryParseException("Variables not permitted in data quad", -1, -1) ; if ( quad.getSubject().isLiteral() ) throw new QueryParseException("Literals not allowed as subjects in quad data", -1, -1) ; } }
@Override protected void check(Quad t) { if ( Var.isVar(t.getGraph()) || Var.isVar(t.getSubject()) || Var.isVar(t.getPredicate()) || Var.isVar(t.getObject())) throw new QueryParseException("Variables not permitted in data quad", -1, -1) ; } }
private static void check(Query query, Collection<Var> vars) { // Check any expressions are assigned to fresh variables. checkExprListAssignment(vars, query.getProject()) ; // Check for SELECT * GROUP BY // Legal in ARQ, not in SPARQL 1.1 if ( ! Syntax.syntaxARQ.equals(query.getSyntax()) ) { if ( query.isQueryResultStar() && query.hasGroupBy() ) throw new QueryParseException("SELECT * not legal with GROUP BY", -1 , -1) ; } // Check any variable in an expression is in scope (if GROUP BY) checkExprVarUse(query) ; // Check GROUP BY AS // ENABLE if ( false && query.hasGroupBy() ) { VarExprList exprList2 = query.getGroupBy() ; checkExprListAssignment(vars, exprList2) ; // CHECK } }
private static void check(Query query, Collection<Var> vars) { // Check any expressions are assigned to fresh variables. checkExprListAssignment(vars, query.getProject()) ; // Check for SELECT * GROUP BY // Legal in ARQ, not in SPARQL 1.1 if ( ! Syntax.syntaxARQ.equals(query.getSyntax()) ) { if ( query.isQueryResultStar() && query.hasGroupBy() ) throw new QueryParseException("SELECT * not legal with GROUP BY", -1 , -1) ; } // Check any variable in an expression is in scope (if GROUP BY) checkExprVarUse(query) ; // Check GROUP BY AS // ENABLE if ( false && query.hasGroupBy() ) { VarExprList exprList2 = query.getGroupBy() ; checkExprListAssignment(vars, exprList2) ; // CHECK } }