private void checkRecurse() throws ParseException { if (recurseCount++ >= 100) { throw new ParseException("Infinite Recursion detected parsing query '" + qstr + "'"); } }
/** Returns the numeric value of the hexadecimal character */ private static final int hexToInt(char c) throws ParseException { if ('0' <= c && c <= '9') { return c - '0'; } else if ('a' <= c && c <= 'f'){ return c - 'a' + 10; } else if ('A' <= c && c <= 'F') { return c - 'A' + 10; } else { throw new ParseException("None-hex character in unicode escape sequence: " + c); } }
/** Returns the numeric value of the hexadecimal character */ private static final int hexToInt(char c) throws ParseException { if ('0' <= c && c <= '9') { return c - '0'; } else if ('a' <= c && c <= 'f'){ return c - 'a' + 10; } else if ('A' <= c && c <= 'F') { return c - 'A' + 10; } else { throw new ParseException("None-hex character in unicode escape sequence: " + c); } }
void expect(String s) throws ParseException { eatws(); int slen=s.length(); if (val.regionMatches(pos, s, 0, slen)) { pos+=slen; } else { throw new ParseException("Expected '"+s+"' at position " + pos + " in '"+val+"'"); } }
String getId() throws ParseException { eatws(); int id_start=pos; if (pos<end && Character.isJavaIdentifierStart(val.charAt(pos))) { pos++; while (pos<end) { char ch = val.charAt(pos); if (!Character.isJavaIdentifierPart(ch) && ch!='.') { break; } pos++; } return val.substring(id_start, pos); } throw new ParseException("Expected identifier at pos " + pos + " str='" + val + "'"); }
protected Query getFieldQuery(String term, String value) throws ParseException{ if(term.equals(RAMBufferedDataStore.KEY_STRING_INDEX_FILED)) return new TermQuery(new Term(term,value)); try { Converter converter = ipp.getConverter(term); if(converter!=null){ String modifiedPart1 = converter.format(value); return new TermQuery(new Term(term,modifiedPart1)); } } catch (NumberFormatException e) { e.printStackTrace(); throw new ParseException(e.getMessage()); } return super.getFieldQuery(term, value); } }
throw new ParseException("'*' not allowed as first character in PrefixQuery"); if (lowercaseExpandedTerms) { termStr = termStr.toLowerCase();
String getQuotedString() throws ParseException { eatws(); char delim = peekChar(); if (!(delim=='\"' || delim=='\'')) { return null; } int val_start = ++pos; StringBuilder sb = new StringBuilder(); // needed for escaping for(;;) { if (pos>=end) { throw new ParseException("Missing end quote for string at pos " + (val_start-1) + " str='"+val+"'"); } char ch = val.charAt(pos); if (ch=='\\') { ch = pos<end ? val.charAt(pos++) : 0; } else if (ch==delim) { pos++; return sb.toString(); } sb.append(ch); pos++; } }
/** Parses a query string, returning a * <a href="lucene.search.Query.html">Query</a>. * @param query the query string to be parsed. * @throws ParseException if the parsing fails */ public Query parse(String query) throws ParseException { ReInit(new FastCharStream(new StringReader(query))); try { return Query(field); } catch (TokenMgrError tme) { throw new ParseException(tme.getMessage()); } catch (BooleanQuery.TooManyClauses tmc) { throw new ParseException("Too many boolean clauses"); } }
throw new ParseException("'*' or '?' not allowed as first character in WildcardQuery"); if (lowercaseExpandedTerms) { termStr = termStr.toLowerCase();
/** Parses a query string, returning a {@link org.apache.lucene.search.Query}. * @param query the query string to be parsed. * @throws ParseException if the parsing fails */ public Query parse(String query) throws ParseException { ReInit(new FastCharStream(new StringReader(query))); try { // TopLevelQuery is a Query followed by the end-of-input (EOF) Query res = TopLevelQuery(field); return res!=null ? res : newBooleanQuery(false); } catch (ParseException tme) { // rethrow to include the original query: throw new ParseException("Cannot parse '" +query+ "': " + tme.getMessage()); } catch (TokenMgrError tme) { throw new ParseException("Cannot parse '" +query+ "': " + tme.getMessage()); } catch (BooleanQuery.TooManyClauses tmc) { throw new ParseException("Cannot parse '" +query+ "': too many boolean clauses"); } }
/** Parses a query string, returning a {@link org.apache.lucene.search.Query}. * @param query the query string to be parsed. * @throws ParseException if the parsing fails */ public Query parse(String query) throws ParseException { ReInit(new FastCharStream(new StringReader(query))); try { // TopLevelQuery is a Query followed by the end-of-input (EOF) Query res = TopLevelQuery(field); return res!=null ? res : newBooleanQuery(false); } catch (ParseException tme) { // rethrow to include the original query: throw new ParseException("Cannot parse '" +query+ "': " + tme.getMessage()); } catch (TokenMgrError tme) { throw new ParseException("Cannot parse '" +query+ "': " + tme.getMessage()); } catch (BooleanQuery.TooManyClauses tmc) { throw new ParseException("Cannot parse '" +query+ "': too many boolean clauses"); } }
protected Query getRangeQuery(String field, String part1, String part2, boolean inclusive) throws ParseException{ try { Converter converter = ipp.getConverter(field); if(converter!=null){ part1 = converter.format(part1); part2 = converter.format(part2); } } catch (NumberFormatException e) { e.printStackTrace(); throw new ParseException(e.getMessage()); } return super.getRangeQuery(field, part1, part2, inclusive); }
throw new ParseException(e.getMessage()); throw new ParseException(e.getMessage());
protected Term getTerm(String field, String text) throws ParseException { try { if (spellChecker.exist(text)) { return super.getTerm(field, text); } String[] similarWords = spellChecker.suggestSimilar(text, 1); if (similarWords.length == 0) { return super.getTerm(field, text); } suggestedQuery = true; return super.getTerm(field, similarWords[0]); } catch (IOException e) { throw new ParseException("Failed to spell check suggest " + e.getMessage()); } }
protected Term getTerm(String field, String text) throws ParseException { try { if (spellChecker.exist(text)) { return super.getTerm(field, text); } String[] similarWords = spellChecker.suggestSimilar(text, 1); if (similarWords.length == 0) { return super.getTerm(field, text); } suggestedQuery = true; return super.getTerm(field, similarWords[0]); } catch (IOException e) { throw new ParseException("Failed to spell check suggest " + e.getMessage()); } }
throw new ParseException(e.getMessage()); } finally { try {
final public int Conjunction() throws ParseException { int ret = CONJ_NONE; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case AND: case OR: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case AND: jj_consume_token(AND); ret = CONJ_AND; break; case OR: jj_consume_token(OR); ret = CONJ_OR; break; default: jj_la1[0] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: jj_la1[1] = jj_gen; ; } {if (true) return ret;} throw new Error("Missing return statement in function"); }
final public int Conjunction() throws ParseException { int ret = CONJ_NONE; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case AND: case OR: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case AND: jj_consume_token(AND); ret = CONJ_AND; break; case OR: jj_consume_token(OR); ret = CONJ_OR; break; default: jj_la1[0] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: jj_la1[1] = jj_gen; ; } {if (true) return ret;} throw new Error("Missing return statement in function"); }
final public int Conjunction() throws ParseException { int ret = CONJ_NONE; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case AND: case OR: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case AND: jj_consume_token(AND); ret = CONJ_AND; break; case OR: jj_consume_token(OR); ret = CONJ_OR; break; default: jj_la1[0] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: jj_la1[1] = jj_gen; ; } {if (true) return ret;} throw new Error("Missing return statement in function"); }