本文整理了Java中org.apache.lucene.queryParser.ParseException.<init>()
方法的一些代码示例,展示了ParseException.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ParseException.<init>()
方法的具体详情如下:
包路径:org.apache.lucene.queryParser.ParseException
类名称:ParseException
方法名:<init>
[英]The following constructors are for use by you for whatever purpose you can think of. Constructing the exception in this manner makes the exception behave in the normal way - i.e., as documented in the class "Throwable". The fields "errorToken", "expectedTokenSequences", and "tokenImage" do not contain relevant information. The JavaCC generated code does not use these constructors.
[中]以下构造函数供您用于任何您能想到的目的。以这种方式构造异常会使异常以正常方式运行——即,如类“Throwable”中所述。字段“errorToken”、“expectedTokenSequences”和“tokenImage”不包含相关信息。JavaCC生成的代码不使用这些构造函数。
代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core
private void checkRecurse() throws ParseException {
if (recurseCount++ >= 100) {
throw new ParseException("Infinite Recursion detected parsing query '" + qstr + "'");
}
}
代码示例来源:origin: org.apache.lucene/lucene-core-jfrog
/** 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);
}
}
代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene
/** 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);
}
}
代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core
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+"'");
}
}
代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core
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 + "'");
}
代码示例来源:origin: org.terracotta.modules/tim-searchable
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);
}
}
代码示例来源:origin: org.apache.lucene/lucene-core-jfrog
throw new ParseException("'*' not allowed as first character in PrefixQuery");
if (lowercaseExpandedTerms) {
termStr = termStr.toLowerCase();
代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core
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++;
}
}
代码示例来源:origin: lucene/lucene
/** 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");
}
}
代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene
throw new ParseException("'*' or '?' not allowed as first character in WildcardQuery");
if (lowercaseExpandedTerms) {
termStr = termStr.toLowerCase();
代码示例来源:origin: org.apache.lucene/lucene-core-jfrog
/** 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");
}
}
代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene
/** 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");
}
}
代码示例来源:origin: org.terracotta.modules/tim-searchable
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);
}
代码示例来源:origin: org.cytoscape/search-impl
throw new ParseException(e.getMessage());
throw new ParseException(e.getMessage());
代码示例来源:origin: org.compass-project/compass
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());
}
}
代码示例来源:origin: org.compass-project/compass
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());
}
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-core
throw new ParseException(e.getMessage());
} finally {
try {
代码示例来源:origin: lucene/lucene
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");
}
代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene
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");
}
代码示例来源:origin: org.apache.lucene/lucene-core-jfrog
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");
}
内容来源于网络,如有侵权,请联系作者删除!