protected Component parseValueComp( TokenStream tokens ) { if (tokens.matchesAnyOf("eq", "ne", "lt", "le", "gt")) { throw new ParsingException(tokens.nextPosition(), "XPath value comparisons using 'eq', 'ne', 'lt', 'le', or 'gt' are not supported"); } return null; }
protected Component parseValueComp( TokenStream tokens ) { if (tokens.matchesAnyOf("eq", "ne", "lt", "le", "gt")) { throw new ParsingException(tokens.nextPosition(), "XPath value comparisons using 'eq', 'ne', 'lt', 'le', or 'gt' are not supported"); } return null; }
protected Component parseExpr( TokenStream tokens ) { Component result = parseExprSingle(tokens); if (tokens.matches(',')) { throw new ParsingException(tokens.nextPosition(), "Multiple XPath expressions are not supported"); } return result; }
protected Component parseMultiplicativeExpr( TokenStream tokens ) { Component result = parseUnaryExpr(tokens); if (tokens.matchesAnyOf("+", "div", "idiv", "mod")) { throw new ParsingException(tokens.nextPosition(), "XPath multiplicative expressions using '+', 'div', 'idiv', or 'mod' are not supported"); } return result; }
protected Component parseInstanceofExpr( TokenStream tokens ) { Component result = parseTreatExpr(tokens); if (tokens.matches("instance", "of")) { throw new ParsingException(tokens.nextPosition(), "XPath 'instance of' expressions are not supported"); } return result; }
protected Component parseRangeExpr( TokenStream tokens ) { Component result = parseAdditiveExpr(tokens); if (tokens.matches("to")) { throw new ParsingException(tokens.nextPosition(), "XPath range expressions with 'to' are not supported"); } return result; }
protected Component parseInstanceofExpr( TokenStream tokens ) { Component result = parseTreatExpr(tokens); if (tokens.matches("instance", "of")) { throw new ParsingException(tokens.nextPosition(), "XPath 'instance of' expressions are not supported"); } return result; }
protected Component parseCastableExpr( TokenStream tokens ) { Component result = parseCastExpr(tokens); if (tokens.matches("castable", "as")) { throw new ParsingException(tokens.nextPosition(), "XPath 'castable as' expressions are not supported"); } return result; }
protected Component parseExpr( TokenStream tokens ) { Component result = parseExprSingle(tokens); if (tokens.matches(',')) { throw new ParsingException(tokens.nextPosition(), "Multiple XPath expressions are not supported"); } return result; }
protected Component parseTreatExpr( TokenStream tokens ) { Component result = parseCastableExpr(tokens); if (tokens.matches("treat", "as")) { throw new ParsingException(tokens.nextPosition(), "XPath 'treat as' expressions are not supported"); } return result; }
protected Component parseRangeExpr( TokenStream tokens ) { Component result = parseAdditiveExpr(tokens); if (tokens.matches("to")) { throw new ParsingException(tokens.nextPosition(), "XPath range expressions with 'to' are not supported"); } return result; }
protected Component parseMultiplicativeExpr( TokenStream tokens ) { Component result = parseUnaryExpr(tokens); if (tokens.matchesAnyOf("+", "div", "idiv", "mod")) { throw new ParsingException(tokens.nextPosition(), "XPath multiplicative expressions using '+', 'div', 'idiv', or 'mod' are not supported"); } return result; }
protected Component parseCastableExpr( TokenStream tokens ) { Component result = parseCastExpr(tokens); if (tokens.matches("castable", "as")) { throw new ParsingException(tokens.nextPosition(), "XPath 'castable as' expressions are not supported"); } return result; }
protected Component parseCastExpr( TokenStream tokens ) { Component result = parseComparisonExpr(tokens); if (tokens.matches("cast", "as")) { throw new ParsingException(tokens.nextPosition(), "XPath 'cast as' expressions are not supported"); } return result; }
protected Component parseTreatExpr( TokenStream tokens ) { Component result = parseCastableExpr(tokens); if (tokens.matches("treat", "as")) { throw new ParsingException(tokens.nextPosition(), "XPath 'treat as' expressions are not supported"); } return result; }
protected Component parseCastExpr( TokenStream tokens ) { Component result = parseComparisonExpr(tokens); if (tokens.matches("cast", "as")) { throw new ParsingException(tokens.nextPosition(), "XPath 'cast as' expressions are not supported"); } return result; }
protected NodeComparisonOperator parseNodeComp( TokenStream tokens ) { if (tokens.matches("is") || tokens.matches("<", "<") || tokens.matches(">", ">")) { throw new ParsingException(tokens.nextPosition(), "XPath 'is', '<<' and '>>' expressions are not supported"); } return null; }
protected NodeComparisonOperator parseNodeComp( TokenStream tokens ) { if (tokens.matches("is") || tokens.matches("<", "<") || tokens.matches(">", ">")) { throw new ParsingException(tokens.nextPosition(), "XPath 'is', '<<' and '>>' expressions are not supported"); } return null; }
@Test public void shouldFindNextPositionStartIndex() { makeCaseInsensitive(); // "Select all columns from this table"; tokens.consume(); // Next position should be line 1, column 8 assertThat(tokens.nextPosition().getIndexInContent(), is(7)); assertThat(tokens.nextPosition().getColumn(), is(8)); assertThat(tokens.nextPosition().getLine(), is(1)); }
protected Operator parseComparisonOperator( TokenStream tokens ) { if (tokens.canConsume("=")) return Operator.EQUAL_TO; if (tokens.canConsume("LIKE")) return Operator.LIKE; if (tokens.canConsume("!", "=")) return Operator.NOT_EQUAL_TO; if (tokens.canConsume("<", ">")) return Operator.NOT_EQUAL_TO; if (tokens.canConsume("<", "=")) return Operator.LESS_THAN_OR_EQUAL_TO; if (tokens.canConsume(">", "=")) return Operator.GREATER_THAN_OR_EQUAL_TO; if (tokens.canConsume("<")) return Operator.LESS_THAN; if (tokens.canConsume(">")) return Operator.GREATER_THAN; Position pos = tokens.nextPosition(); String msg = GraphI18n.expectingComparisonOperator.text(tokens.consume(), pos.getLine(), pos.getColumn()); throw new ParsingException(pos, msg); }