protected void throwNoMoreContent() throws ParsingException { String msg = CommonI18n.noMoreContent.text(); Position pos = tokens.isEmpty() ? new Position(-1, 1, 0) : tokens.get(tokens.size() - 1).position(); throw new ParsingException(pos, msg); }
protected Term parseFullTextSearchExpression( String expression, Position startOfExpression ) { try { return new FullTextSearchParser().parse(expression); } catch (ParsingException e) { // Convert the position in the exception into a position in the query. Position queryPos = startOfExpression.add(e.getPosition()); throw new ParsingException(queryPos, e.getMessage()); } }
@Test public void shouldConvertPositionWhenUnableToParseFullTextSearchExpression() { try { parser.parseFullTextSearchExpression("", new Position(500, 100, 13)); fail("Should have thrown an exception"); } catch (ParsingException e) { assertThat(e.getPosition().getLine(), is(100)); assertThat(e.getPosition().getColumn(), is(13)); assertThat(e.getPosition().getIndexInContent(), is(500)); } }
@Override public QueryCommand parseQuery( String query, TypeSystem typeSystem ) throws InvalidQueryException { // Parse the terms ... try { PARSER.parse(query); } catch (ParsingException e) { throw new InvalidQueryException(query, e.getMessage()); } // Now create a query that represents this full-text search ... Constraint constraint = new FullTextSearch(FULL_TEXT_SELECTOR_NAME, query); return new SelectQuery(FULL_TEXT_SOURCE, constraint, FULL_TEXT_ORDERING, FULL_TEXT_COLUMNS, Limit.NONE, FULL_TEXT_DISTINCT); }
rootNode = parsers.parse(IoUtil.read(stream), fileName); } catch (ParsingException e) { LOGGER.error(e, DdlSequencerI18n.errorParsingDdlContent, e.getLocalizedMessage()); return false; } catch (IOException e) {
@Test public void shouldConvertPositionWhenUnableToParseFullTextSearchExpression() { try { parser.parseFullTextSearchExpression("", new Position(500, 100, 13)); fail("Should have thrown an exception"); } catch (ParsingException e) { assertThat(e.getPosition().getLine(), is(100)); assertThat(e.getPosition().getColumn(), is(13)); assertThat(e.getPosition().getIndexInContent(), is(500)); } }
@Override public QueryCommand parseQuery( String query, TypeSystem typeSystem ) throws InvalidQueryException { // Parse the terms ... try { PARSER.parse(query); } catch (ParsingException e) { throw new InvalidQueryException(query, e.getMessage()); } // Now create a query that represents this full-text search ... Constraint constraint = new FullTextSearch(FULL_TEXT_SELECTOR_NAME, query); return new SelectQuery(FULL_TEXT_SOURCE, constraint, FULL_TEXT_ORDERING, FULL_TEXT_COLUMNS, Limit.NONE, FULL_TEXT_DISTINCT); }
rootNode = parsers.parse(IoUtil.read(stream), fileName); } catch (ParsingException e) { LOGGER.error(e, DdlSequencerI18n.errorParsingDdlContent, e.getLocalizedMessage()); return false; } catch (IOException e) {
protected void throwNoMoreContent() throws ParsingException { String msg = CommonI18n.noMoreContent.text(); Position pos = tokens.isEmpty() ? new Position(-1, 1, 0) : tokens.get(tokens.size() - 1).position(); throw new ParsingException(pos, msg); }
protected Term parseFullTextSearchExpression( String expression, Position startOfExpression ) { try { return new FullTextSearchParser().parse(expression); } catch (ParsingException e) { // Convert the position in the exception into a position in the query. Position queryPos = startOfExpression.add(e.getPosition()); throw new ParsingException(queryPos, e.getMessage()); } }
} catch (ParsingException e) { String reason = e.getMessage(); throw new InvalidQueryException(JcrI18n.queryCannotBeParsedUsingLanguage.text(language, expression, reason)); } catch (org.modeshape.jcr.query.parse.InvalidQueryException e) {
protected void throwNoMoreContent() throws ParsingException { String msg = CommonI18n.noMoreContent.text(); Position pos = tokens.isEmpty() ? new Position(-1, 1, 0) : tokens.get(tokens.size() - 1).position(); throw new ParsingException(pos, msg); }
protected Term parseFullTextSearchExpression( String expression, Position startOfExpression ) { try { return new FullTextSearchParser().parse(expression); } catch (ParsingException e) { // Convert the position in the exception into a position in the query. Position queryPos = startOfExpression.add(e.getPosition()); throw new ParsingException(queryPos, e.getMessage()); } }
} catch (ParsingException e) { String reason = e.getMessage(); throw new InvalidQueryException(JcrI18n.queryCannotBeParsedUsingLanguage.text(language, expression, reason)); } catch (org.modeshape.jcr.query.parse.InvalidQueryException e) {
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 parseExprSingle( TokenStream tokens ) { if (tokens.matches("for", "$", ANY_VALUE, "IN")) { throw new ParsingException(tokens.nextPosition(), "XPath 'for' expressions are not supported"); } if (tokens.matches("some", "$", ANY_VALUE, "IN")) { throw new ParsingException(tokens.nextPosition(), "XPath 'some' expressions are not supported"); } if (tokens.matches("every", "$", ANY_VALUE, "IN")) { throw new ParsingException(tokens.nextPosition(), "XPath 'every' expressions are not supported"); } if (tokens.matches("if", "(", ANY_VALUE, "IN")) { throw new ParsingException(tokens.nextPosition(), "XPath if-then-else expressions are not supported"); } return parseOrExpr(tokens); }
protected Component parseExprSingle( TokenStream tokens ) { if (tokens.matches("for", "$", ANY_VALUE, "IN")) { throw new ParsingException(tokens.nextPosition(), "XPath 'for' expressions are not supported"); } if (tokens.matches("some", "$", ANY_VALUE, "IN")) { throw new ParsingException(tokens.nextPosition(), "XPath 'some' expressions are not supported"); } if (tokens.matches("every", "$", ANY_VALUE, "IN")) { throw new ParsingException(tokens.nextPosition(), "XPath 'every' expressions are not supported"); } if (tokens.matches("if", "(", ANY_VALUE, "IN")) { throw new ParsingException(tokens.nextPosition(), "XPath if-then-else expressions are not supported"); } return parseOrExpr(tokens); }