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 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 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 parseUnaryExpr( TokenStream tokens ) { boolean negative = false; // Technically more than one +/- are allowed by the spec while (tokens.matchesAnyOf("+", "-")) { if (tokens.canConsume("-")) negative = true; tokens.canConsume("+"); } Component result = parseUnionExpr(tokens); return negative ? new Negation(result) : result; }
protected Component parseUnaryExpr( TokenStream tokens ) { boolean negative = false; // Technically more than one +/- are allowed by the spec while (tokens.matchesAnyOf("+", "-")) { if (tokens.canConsume("-")) negative = true; tokens.canConsume("+"); } Component result = parseUnionExpr(tokens); return negative ? new Negation(result) : result; }
/** * Parse the property type, if a valid one appears next on the token stream. * * @param tokens the tokens containing the definition; never null * @param propDefn the property definition; never null * @param defaultPropertyType the default property type if none is actually found * @throws ParsingException if there is a problem parsing the content */ protected void parsePropertyType( TokenStream tokens, JcrPropertyDefinitionTemplate propDefn, String defaultPropertyType ) { if (tokens.canConsume('(')) { // Parse the (optional) property type ... String propertyType = defaultPropertyType; if (tokens.matchesAnyOf(VALID_PROPERTY_TYPES)) { propertyType = tokens.consume(); if ("*".equals(propertyType)) propertyType = "UNDEFINED"; } tokens.consume(')'); PropertyType type = PropertyType.valueFor(propertyType.toLowerCase()); int jcrType = PropertyTypeUtil.jcrPropertyTypeFor(type); propDefn.setRequiredType(jcrType); } }
/** * Parse the property type, if a valid one appears next on the token stream. * * @param tokens the tokens containing the definition; never null * @param propDefn the property definition; never null * @param defaultPropertyType the default property type if none is actually found * @throws ParsingException if there is a problem parsing the content */ protected void parsePropertyType( TokenStream tokens, JcrPropertyDefinitionTemplate propDefn, String defaultPropertyType ) { if (tokens.canConsume('(')) { // Parse the (optional) property type ... String propertyType = defaultPropertyType; if (tokens.matchesAnyOf(VALID_PROPERTY_TYPES)) { propertyType = tokens.consume(); if ("*".equals(propertyType)) propertyType = "UNDEFINED"; } tokens.consume(')'); PropertyType type = PropertyType.valueFor(propertyType.toLowerCase()); int jcrType = PropertyTypeUtil.jcrPropertyTypeFor(type); propDefn.setRequiredType(jcrType); } }
@Test public void shouldReturnTrueFromMatchAnyOfIfAnyOfTheTokenValuesMatch() { makeCaseInsensitive(); // Unable to consume unless they all match ... assertThat(tokens.matchesAnyOf("ALL", "COLUMNS"), is(false)); assertThat(tokens.matchesAnyOf("ALL", "COLUMNS", "SELECT"), is(true)); tokens.consume("SELECT"); assertThat(tokens.matchesAnyOf("ALL", "COLUMNS", "SELECT"), is(true)); tokens.consume("ALL"); assertThat(tokens.matchesAnyOf("ALL", "COLUMNS", "SELECT"), is(true)); tokens.consume("COLUMNS"); assertThat(tokens.canConsume("FROM", "THIS", "TABLE"), is(true)); assertThat(tokens.hasNext(), is(false)); }
protected QueryCommand parseQueryCommand( TokenStream tokens, TypeSystem typeSystem ) { QueryCommand command = null; if (tokens.matches("SELECT")) { command = parseQuery(tokens, typeSystem); while (tokens.hasNext()) { if (tokens.matchesAnyOf("UNION", "INTERSECT", "EXCEPT")) { command = parseSetQuery(tokens, command, typeSystem); } else if (tokens.matches(')')) { // There's more in this token stream, but we'll stop reading ... break; } else { Position pos = tokens.previousPosition(); String msg = GraphI18n.unexpectedToken.text(tokens.consume(), pos.getLine(), pos.getColumn()); throw new ParsingException(pos, msg); } } } else { // We expected SELECT ... Position pos = tokens.nextPosition(); String msg = GraphI18n.unexpectedToken.text(tokens.consume(), pos.getLine(), pos.getColumn()); throw new ParsingException(pos, msg); } return command; }
protected QueryCommand parseQueryCommand( TokenStream tokens, TypeSystem typeSystem ) { QueryCommand command = null; if (tokens.matches("SELECT")) { command = parseQuery(tokens, typeSystem); while (tokens.hasNext()) { if (tokens.matchesAnyOf("UNION", "INTERSECT", "EXCEPT")) { command = parseSetQuery(tokens, command, typeSystem); } else if (tokens.matches(')')) { // There's more in this token stream, but we'll stop reading ... break; } else { Position pos = tokens.previousPosition(); String msg = GraphI18n.unexpectedToken.text(tokens.consume(), pos.getLine(), pos.getColumn()); throw new ParsingException(pos, msg); } } } else { // We expected SELECT ... Position pos = tokens.nextPosition(); String msg = GraphI18n.unexpectedToken.text(tokens.consume(), pos.getLine(), pos.getColumn()); throw new ParsingException(pos, msg); } return command; }
protected QueryCommand parseQueryCommand( TokenStream tokens, TypeSystem typeSystem ) { QueryCommand command = null; if (tokens.matches("SELECT")) { command = parseQuery(tokens, typeSystem); while (tokens.hasNext()) { if (tokens.matchesAnyOf("UNION", "INTERSECT", "EXCEPT")) { command = parseSetQuery(tokens, command, typeSystem); } else if (tokens.matches(')')) { // There's more in this token stream, but we'll stop reading ... break; } else { Position pos = tokens.previousPosition(); String msg = GraphI18n.unexpectedToken.text(tokens.consume(), pos.getLine(), pos.getColumn()); throw new ParsingException(pos, msg); } } } else { // We expected SELECT ... Position pos = tokens.nextPosition(); String msg = GraphI18n.unexpectedToken.text(tokens.consume(), pos.getLine(), pos.getColumn()); throw new ParsingException(pos, msg); } return command; }
throw new ParsingException(tokens.previousPosition(), CndI18n.multipleKeywordNotValidInJcr2CndFormat.text(line, column)); } else if (tokens.matchesAnyOf(VALID_ON_PARENT_VERSION)) { onParentVersion = tokens.consume(); tokens.canConsume('?');
throw new ParsingException(tokens.previousPosition(), CndI18n.multipleKeywordNotValidInJcr2CndFormat.text(line, column)); } else if (tokens.matchesAnyOf(VALID_ON_PARENT_VERSION)) { onParentVersion = tokens.consume(); tokens.canConsume('?');
tokens.canConsume('?'); multiple = true; } else if (tokens.matchesAnyOf(VALID_ON_PARENT_VERSION)) { onParentVersion = tokens.consume(); tokens.canConsume('?');
tokens.canConsume('?'); multiple = true; } else if (tokens.matchesAnyOf(VALID_ON_PARENT_VERSION)) { onParentVersion = tokens.consume(); tokens.canConsume('?');