You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2012/09/21 19:22:27 UTC
svn commit: r1388574 [27/45] - in /lucene/dev/branches/LUCENE-2878: ./
dev-tools/ dev-tools/eclipse/ dev-tools/eclipse/dot.settings/
dev-tools/idea/ dev-tools/idea/.idea/ dev-tools/idea/.idea/libraries/
dev-tools/idea/lucene/ dev-tools/idea/lucene/anal...
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java Fri Sep 21 17:21:34 2012
@@ -40,16 +40,19 @@ import org.apache.lucene.queryparser.fle
import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser;
import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode;
+/**
+ * Parser for the standard Lucene syntax
+ */
public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserConstants {
- private static final int CONJ_NONE =0;
- private static final int CONJ_AND =2;
- private static final int CONJ_OR =2;
+ private static final int CONJ_NONE =0;
+ private static final int CONJ_AND =2;
+ private static final int CONJ_OR =2;
// syntax parser constructor
public StandardSyntaxParser() {
- this(new FastCharStream(new StringReader("")));
+ this(new FastCharStream(new StringReader("")));
}
/** Parses a query string, returning a {@link org.apache.lucene.queryparser.flexible.core.nodes.QueryNode}.
* @param query the query string to be parsed.
@@ -140,10 +143,10 @@ public class StandardSyntaxParser implem
// This makes sure that there is no garbage after the query string
final public QueryNode TopLevelQuery(CharSequence field) throws ParseException {
- QueryNode q;
+ QueryNode q;
q = Query(field);
jj_consume_token(0);
- {if (true) return q;}
+ {if (true) return q;}
throw new Error("Missing return statement in function");
}
@@ -181,23 +184,23 @@ public class StandardSyntaxParser implem
break label_1;
}
c = DisjQuery(field);
- if (clauses == null) {
- clauses = new Vector<QueryNode>();
- clauses.addElement(first);
- }
- clauses.addElement(c);
+ if (clauses == null) {
+ clauses = new Vector<QueryNode>();
+ clauses.addElement(first);
+ }
+ clauses.addElement(c);
}
if (clauses != null) {
- {if (true) return new BooleanQueryNode(clauses);}
- } else {
- {if (true) return first;}
- }
+ {if (true) return new BooleanQueryNode(clauses);}
+ } else {
+ {if (true) return first;}
+ }
throw new Error("Missing return statement in function");
}
final public QueryNode DisjQuery(CharSequence field) throws ParseException {
- QueryNode first, c;
- Vector<QueryNode> clauses = null;
+ QueryNode first, c;
+ Vector<QueryNode> clauses = null;
first = ConjQuery(field);
label_2:
while (true) {
@@ -218,7 +221,7 @@ public class StandardSyntaxParser implem
clauses.addElement(c);
}
if (clauses != null) {
- {if (true) return new OrQueryNode(clauses);}
+ {if (true) return new OrQueryNode(clauses);}
} else {
{if (true) return first;}
}
@@ -226,8 +229,8 @@ public class StandardSyntaxParser implem
}
final public QueryNode ConjQuery(CharSequence field) throws ParseException {
- QueryNode first, c;
- Vector<QueryNode> clauses = null;
+ QueryNode first, c;
+ Vector<QueryNode> clauses = null;
first = ModClause(field);
label_3:
while (true) {
@@ -248,7 +251,7 @@ public class StandardSyntaxParser implem
clauses.addElement(c);
}
if (clauses != null) {
- {if (true) return new AndQueryNode(clauses);}
+ {if (true) return new AndQueryNode(clauses);}
} else {
{if (true) return first;}
}
@@ -269,27 +272,27 @@ public class StandardSyntaxParser implem
// if (mods == ModifierQueryNode.Modifier.MOD_NONE) firstQuery=q;
//
// // do not create modifier nodes with MOD_NONE
-// if (mods != ModifierQueryNode.Modifier.MOD_NONE) {
-// q = new ModifierQueryNode(q, mods);
-// }
-// clauses.add(q);
+// if (mods != ModifierQueryNode.Modifier.MOD_NONE) {
+// q = new ModifierQueryNode(q, mods);
+// }
+// clauses.add(q);
// }
// (
// conj=Conjunction() mods=Modifiers() q=Clause(field)
// {
-// // do not create modifier nodes with MOD_NONE
-// if (mods != ModifierQueryNode.Modifier.MOD_NONE) {
-// q = new ModifierQueryNode(q, mods);
-// }
-// clauses.add(q);
-// //TODO: figure out what to do with AND and ORs
+// // do not create modifier nodes with MOD_NONE
+// if (mods != ModifierQueryNode.Modifier.MOD_NONE) {
+// q = new ModifierQueryNode(q, mods);
+// }
+// clauses.add(q);
+// //TODO: figure out what to do with AND and ORs
// }
// )*
// {
// if (clauses.size() == 1 && firstQuery != null)
// return firstQuery;
// else {
-// return new BooleanQueryNode(clauses);
+// return new BooleanQueryNode(clauses);
// }
// }
// }
@@ -298,10 +301,10 @@ public class StandardSyntaxParser implem
ModifierQueryNode.Modifier mods;
mods = Modifiers();
q = Clause(field);
- if (mods != ModifierQueryNode.Modifier.MOD_NONE) {
- q = new ModifierQueryNode(q, mods);
- }
- {if (true) return q;}
+ if (mods != ModifierQueryNode.Modifier.MOD_NONE) {
+ q = new ModifierQueryNode(q, mods);
+ }
+ {if (true) return q;}
throw new Error("Missing return statement in function");
}
@@ -375,18 +378,18 @@ public class StandardSyntaxParser implem
}
switch (operator.kind) {
case OP_LESSTHAN:
- lowerInclusive = true;
- upperInclusive = false;
+ lowerInclusive = true;
+ upperInclusive = false;
- qLower = new FieldQueryNode(field,
+ qLower = new FieldQueryNode(field,
"*", term.beginColumn, term.endColumn);
- qUpper = new FieldQueryNode(field,
+ qUpper = new FieldQueryNode(field,
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
break;
case OP_LESSTHANEQ:
- lowerInclusive = true;
- upperInclusive = true;
+ lowerInclusive = true;
+ upperInclusive = true;
qLower = new FieldQueryNode(field,
"*", term.beginColumn, term.endColumn);
@@ -394,8 +397,8 @@ public class StandardSyntaxParser implem
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
break;
case OP_MORETHAN:
- lowerInclusive = false;
- upperInclusive = true;
+ lowerInclusive = false;
+ upperInclusive = true;
qLower = new FieldQueryNode(field,
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
@@ -403,8 +406,8 @@ public class StandardSyntaxParser implem
"*", term.beginColumn, term.endColumn);
break;
case OP_MORETHANEQ:
- lowerInclusive = true;
- upperInclusive = true;
+ lowerInclusive = true;
+ upperInclusive = true;
qLower = new FieldQueryNode(field,
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
@@ -485,18 +488,18 @@ public class StandardSyntaxParser implem
}
}
if (boost != null) {
- float f = (float)1.0;
- try {
- f = Float.valueOf(boost.image).floatValue();
- // avoid boosting null queries, such as those caused by stop words
- if (q != null) {
- q = new BoostQueryNode(q, f);
- }
- } catch (Exception ignored) {
- /* Should this be handled somehow? (defaults to "no boost", if
+ float f = (float)1.0;
+ try {
+ f = Float.valueOf(boost.image).floatValue();
+ // avoid boosting null queries, such as those caused by stop words
+ if (q != null) {
+ q = new BoostQueryNode(q, f);
+ }
+ } catch (Exception ignored) {
+ /* Should this be handled somehow? (defaults to "no boost", if
* boost number is invalid)
*/
- }
+ }
}
if (group) { q = new GroupQueryNode(q);}
{if (true) return q;}
@@ -519,7 +522,7 @@ public class StandardSyntaxParser implem
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case TERM:
term = jj_consume_token(TERM);
- q = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
+ q = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
break;
case REGEXPTERM:
term = jj_consume_token(REGEXPTERM);
@@ -561,16 +564,16 @@ public class StandardSyntaxParser implem
;
}
if (fuzzy) {
- float fms = defaultMinSimilarity;
- try {
+ float fms = defaultMinSimilarity;
+ try {
fms = Float.valueOf(fuzzySlop.image.substring(1)).floatValue();
- } catch (Exception ignored) { }
- if(fms < 0.0f){
- {if (true) throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_LIMITS));}
- } else if (fms >= 1.0f && fms != (int) fms) {
- {if (true) throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_EDITS));}
- }
- q = new FuzzyQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), fms, term.beginColumn, term.endColumn);
+ } catch (Exception ignored) { }
+ if(fms < 0.0f){
+ {if (true) throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_LIMITS));}
+ } else if (fms >= 1.0f && fms != (int) fms) {
+ {if (true) throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_EDITS));}
+ }
+ q = new FuzzyQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), fms, term.beginColumn, term.endColumn);
} else if (regexp) {
String re = term.image.substring(1, term.image.length()-1);
q = new RegexpQueryNode(field, re, 0, re.length());
@@ -653,9 +656,9 @@ public class StandardSyntaxParser implem
}
qLower = new FieldQueryNode(field,
- EscapeQuerySyntaxImpl.discardEscapeChar(goop1.image), goop1.beginColumn, goop1.endColumn);
- qUpper = new FieldQueryNode(field,
- EscapeQuerySyntaxImpl.discardEscapeChar(goop2.image), goop2.beginColumn, goop2.endColumn);
+ EscapeQuerySyntaxImpl.discardEscapeChar(goop1.image), goop1.beginColumn, goop1.endColumn);
+ qUpper = new FieldQueryNode(field,
+ EscapeQuerySyntaxImpl.discardEscapeChar(goop2.image), goop2.beginColumn, goop2.endColumn);
q = new TermRangeQueryNode(qLower, qUpper, startInc ? true : false, endInc ? true : false);
break;
case QUOTED:
@@ -687,8 +690,8 @@ public class StandardSyntaxParser implem
}
catch (Exception ignored) {
/* Should this be handled somehow? (defaults to "no PhraseSlop", if
- * slop number is invalid)
- */
+ * slop number is invalid)
+ */
}
}
break;
@@ -697,20 +700,20 @@ public class StandardSyntaxParser implem
jj_consume_token(-1);
throw new ParseException();
}
- if (boost != null) {
- float f = (float)1.0;
- try {
- f = Float.valueOf(boost.image).floatValue();
- // avoid boosting null queries, such as those caused by stop words
- if (q != null) {
- q = new BoostQueryNode(q, f);
- }
- } catch (Exception ignored) {
- /* Should this be handled somehow? (defaults to "no boost", if
- * boost number is invalid)
- */
- }
+ if (boost != null) {
+ float f = (float)1.0;
+ try {
+ f = Float.valueOf(boost.image).floatValue();
+ // avoid boosting null queries, such as those caused by stop words
+ if (q != null) {
+ q = new BoostQueryNode(q, f);
}
+ } catch (Exception ignored) {
+ /* Should this be handled somehow? (defaults to "no boost", if
+ * boost number is invalid)
+ */
+ }
+ }
{if (true) return q;}
throw new Error("Missing return statement in function");
}
@@ -729,30 +732,6 @@ public class StandardSyntaxParser implem
finally { jj_save(1, xla); }
}
- private boolean jj_3R_4() {
- Token xsp;
- xsp = jj_scanpos;
- if (jj_scan_token(15)) {
- jj_scanpos = xsp;
- if (jj_scan_token(16)) return true;
- }
- if (jj_3R_6()) return true;
- return false;
- }
-
- private boolean jj_3R_6() {
- Token xsp;
- xsp = jj_scanpos;
- if (jj_3R_7()) {
- jj_scanpos = xsp;
- if (jj_3R_8()) {
- jj_scanpos = xsp;
- if (jj_3R_9()) return true;
- }
- }
- return false;
- }
-
private boolean jj_3_2() {
if (jj_scan_token(TERM)) return true;
Token xsp;
@@ -769,39 +748,34 @@ public class StandardSyntaxParser implem
return false;
}
- private boolean jj_3R_10() {
- if (jj_scan_token(TERM)) return true;
- return false;
- }
-
private boolean jj_3R_11() {
if (jj_scan_token(REGEXPTERM)) return true;
return false;
}
- private boolean jj_3R_8() {
+ private boolean jj_3_1() {
+ if (jj_scan_token(TERM)) return true;
Token xsp;
xsp = jj_scanpos;
- if (jj_3R_12()) {
+ if (jj_scan_token(15)) {
jj_scanpos = xsp;
- if (jj_scan_token(27)) return true;
+ if (jj_scan_token(16)) return true;
}
return false;
}
- private boolean jj_3_1() {
- if (jj_scan_token(TERM)) return true;
+ private boolean jj_3R_8() {
Token xsp;
xsp = jj_scanpos;
- if (jj_scan_token(15)) {
+ if (jj_3R_12()) {
jj_scanpos = xsp;
- if (jj_scan_token(16)) return true;
+ if (jj_scan_token(27)) return true;
}
return false;
}
- private boolean jj_3R_9() {
- if (jj_scan_token(QUOTED)) return true;
+ private boolean jj_3R_10() {
+ if (jj_scan_token(TERM)) return true;
return false;
}
@@ -818,6 +792,11 @@ public class StandardSyntaxParser implem
return false;
}
+ private boolean jj_3R_9() {
+ if (jj_scan_token(QUOTED)) return true;
+ return false;
+ }
+
private boolean jj_3R_5() {
Token xsp;
xsp = jj_scanpos;
@@ -842,6 +821,30 @@ public class StandardSyntaxParser implem
return false;
}
+ private boolean jj_3R_4() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(15)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(16)) return true;
+ }
+ if (jj_3R_6()) return true;
+ return false;
+ }
+
+ private boolean jj_3R_6() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_7()) {
+ jj_scanpos = xsp;
+ if (jj_3R_8()) {
+ jj_scanpos = xsp;
+ if (jj_3R_9()) return true;
+ }
+ }
+ return false;
+ }
+
/** Generated Token Manager. */
public StandardSyntaxParserTokenManager token_source;
/** Current token. */
@@ -983,7 +986,7 @@ public class StandardSyntaxParser implem
return (jj_ntk = jj_nt.kind);
}
- private java.util.List jj_expentries = new java.util.ArrayList();
+ private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
private int[] jj_expentry;
private int jj_kind = -1;
private int[] jj_lasttokens = new int[100];
@@ -998,7 +1001,7 @@ public class StandardSyntaxParser implem
for (int i = 0; i < jj_endpos; i++) {
jj_expentry[i] = jj_lasttokens[i];
}
- jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) {
+ jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext();) {
int[] oldentry = (int[])(it.next());
if (oldentry.length == jj_expentry.length) {
for (int i = 0; i < jj_expentry.length; i++) {
@@ -1046,7 +1049,7 @@ public class StandardSyntaxParser implem
jj_add_error_token(0, 0);
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
- exptokseq[i] = (int[])jj_expentries.get(i);
+ exptokseq[i] = jj_expentries.get(i);
}
return new ParseException(token, exptokseq, tokenImage);
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj Fri Sep 21 17:21:34 2012
@@ -52,16 +52,19 @@ import org.apache.lucene.queryparser.fle
import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser;
import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode;
+/**
+ * Parser for the standard Lucene syntax
+ */
public class StandardSyntaxParser implements SyntaxParser {
- private static final int CONJ_NONE =0;
- private static final int CONJ_AND =2;
- private static final int CONJ_OR =2;
+ private static final int CONJ_NONE =0;
+ private static final int CONJ_AND =2;
+ private static final int CONJ_OR =2;
// syntax parser constructor
public StandardSyntaxParser() {
- this(new FastCharStream(new StringReader("")));
+ this(new FastCharStream(new StringReader("")));
}
/** Parses a query string, returning a {@link org.apache.lucene.queryparser.flexible.core.nodes.QueryNode}.
* @param query the query string to be parsed.
@@ -175,13 +178,13 @@ ModifierQueryNode.Modifier Modifiers() :
// This makes sure that there is no garbage after the query string
QueryNode TopLevelQuery(CharSequence field) :
{
- QueryNode q;
+ QueryNode q;
}
{
- q=Query(field) <EOF>
- {
- return q;
- }
+ q=Query(field) <EOF>
+ {
+ return q;
+ }
}
// These changes were made to introduce operator precedence:
@@ -206,25 +209,25 @@ QueryNode Query(CharSequence field) :
(
c=DisjQuery(field)
{
- if (clauses == null) {
- clauses = new Vector<QueryNode>();
- clauses.addElement(first);
- }
- clauses.addElement(c);
+ if (clauses == null) {
+ clauses = new Vector<QueryNode>();
+ clauses.addElement(first);
+ }
+ clauses.addElement(c);
}
)*
{
if (clauses != null) {
- return new BooleanQueryNode(clauses);
- } else {
- return first;
- }
+ return new BooleanQueryNode(clauses);
+ } else {
+ return first;
+ }
}
}
QueryNode DisjQuery(CharSequence field) : {
- QueryNode first, c;
- Vector<QueryNode> clauses = null;
+ QueryNode first, c;
+ Vector<QueryNode> clauses = null;
}
{
first = ConjQuery(field)
@@ -240,7 +243,7 @@ QueryNode DisjQuery(CharSequence field)
)*
{
if (clauses != null) {
- return new OrQueryNode(clauses);
+ return new OrQueryNode(clauses);
} else {
return first;
}
@@ -248,8 +251,8 @@ QueryNode DisjQuery(CharSequence field)
}
QueryNode ConjQuery(CharSequence field) : {
- QueryNode first, c;
- Vector<QueryNode> clauses = null;
+ QueryNode first, c;
+ Vector<QueryNode> clauses = null;
}
{
first = ModClause(field)
@@ -265,7 +268,7 @@ QueryNode ConjQuery(CharSequence field)
)*
{
if (clauses != null) {
- return new AndQueryNode(clauses);
+ return new AndQueryNode(clauses);
} else {
return first;
}
@@ -286,27 +289,27 @@ QueryNode ConjQuery(CharSequence field)
// if (mods == ModifierQueryNode.Modifier.MOD_NONE) firstQuery=q;
//
// // do not create modifier nodes with MOD_NONE
-// if (mods != ModifierQueryNode.Modifier.MOD_NONE) {
-// q = new ModifierQueryNode(q, mods);
-// }
-// clauses.add(q);
+// if (mods != ModifierQueryNode.Modifier.MOD_NONE) {
+// q = new ModifierQueryNode(q, mods);
+// }
+// clauses.add(q);
// }
// (
// conj=Conjunction() mods=Modifiers() q=Clause(field)
// {
-// // do not create modifier nodes with MOD_NONE
-// if (mods != ModifierQueryNode.Modifier.MOD_NONE) {
-// q = new ModifierQueryNode(q, mods);
-// }
-// clauses.add(q);
-// //TODO: figure out what to do with AND and ORs
+// // do not create modifier nodes with MOD_NONE
+// if (mods != ModifierQueryNode.Modifier.MOD_NONE) {
+// q = new ModifierQueryNode(q, mods);
+// }
+// clauses.add(q);
+// //TODO: figure out what to do with AND and ORs
// }
// )*
// {
// if (clauses.size() == 1 && firstQuery != null)
// return firstQuery;
// else {
-// return new BooleanQueryNode(clauses);
+// return new BooleanQueryNode(clauses);
// }
// }
// }
@@ -317,10 +320,10 @@ QueryNode ModClause(CharSequence field)
}
{
mods=Modifiers() q= Clause(field) {
- if (mods != ModifierQueryNode.Modifier.MOD_NONE) {
- q = new ModifierQueryNode(q, mods);
- }
- return q;
+ if (mods != ModifierQueryNode.Modifier.MOD_NONE) {
+ q = new ModifierQueryNode(q, mods);
+ }
+ return q;
}
}
@@ -344,18 +347,18 @@ QueryNode Clause(CharSequence field) : {
}
switch (operator.kind) {
case OP_LESSTHAN:
- lowerInclusive = true;
- upperInclusive = false;
-
- qLower = new FieldQueryNode(field,
+ lowerInclusive = true;
+ upperInclusive = false;
+
+ qLower = new FieldQueryNode(field,
"*", term.beginColumn, term.endColumn);
- qUpper = new FieldQueryNode(field,
+ qUpper = new FieldQueryNode(field,
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
break;
case OP_LESSTHANEQ:
- lowerInclusive = true;
- upperInclusive = true;
+ lowerInclusive = true;
+ upperInclusive = true;
qLower = new FieldQueryNode(field,
"*", term.beginColumn, term.endColumn);
@@ -363,8 +366,8 @@ QueryNode Clause(CharSequence field) : {
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
break;
case OP_MORETHAN:
- lowerInclusive = false;
- upperInclusive = true;
+ lowerInclusive = false;
+ upperInclusive = true;
qLower = new FieldQueryNode(field,
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
@@ -372,9 +375,9 @@ QueryNode Clause(CharSequence field) : {
"*", term.beginColumn, term.endColumn);
break;
case OP_MORETHANEQ:
- lowerInclusive = true;
- upperInclusive = true;
-
+ lowerInclusive = true;
+ upperInclusive = true;
+
qLower = new FieldQueryNode(field,
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
qUpper = new FieldQueryNode(field,
@@ -398,18 +401,18 @@ QueryNode Clause(CharSequence field) : {
)
{
if (boost != null) {
- float f = (float)1.0;
- try {
- f = Float.valueOf(boost.image).floatValue();
- // avoid boosting null queries, such as those caused by stop words
- if (q != null) {
- q = new BoostQueryNode(q, f);
- }
- } catch (Exception ignored) {
- /* Should this be handled somehow? (defaults to "no boost", if
+ float f = (float)1.0;
+ try {
+ f = Float.valueOf(boost.image).floatValue();
+ // avoid boosting null queries, such as those caused by stop words
+ if (q != null) {
+ q = new BoostQueryNode(q, f);
+ }
+ } catch (Exception ignored) {
+ /* Should this be handled somehow? (defaults to "no boost", if
* boost number is invalid)
- */
- }
+ */
+ }
}
if (group) { q = new GroupQueryNode(q);}
return q;
@@ -430,7 +433,7 @@ QueryNode Term(CharSequence field) : {
{
(
(
- term=<TERM> { q = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn); }
+ term=<TERM> { q = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn); }
| term=<REGEXPTERM> { regexp=true; }
| term=<NUMBER>
)
@@ -438,16 +441,16 @@ QueryNode Term(CharSequence field) : {
[ <CARAT> boost=<NUMBER> [ fuzzySlop=<FUZZY_SLOP> { fuzzy=true; } ] ]
{
if (fuzzy) {
- float fms = defaultMinSimilarity;
- try {
+ float fms = defaultMinSimilarity;
+ try {
fms = Float.valueOf(fuzzySlop.image.substring(1)).floatValue();
- } catch (Exception ignored) { }
- if(fms < 0.0f){
- throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_LIMITS));
- } else if (fms >= 1.0f && fms != (int) fms) {
- throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_EDITS));
- }
- q = new FuzzyQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), fms, term.beginColumn, term.endColumn);
+ } catch (Exception ignored) { }
+ if(fms < 0.0f){
+ throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_LIMITS));
+ } else if (fms >= 1.0f && fms != (int) fms) {
+ throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_EDITS));
+ }
+ q = new FuzzyQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), fms, term.beginColumn, term.endColumn);
} else if (regexp) {
String re = term.image.substring(1, term.image.length()-1);
q = new RegexpQueryNode(field, re, 0, re.length());
@@ -468,9 +471,9 @@ QueryNode Term(CharSequence field) : {
}
qLower = new FieldQueryNode(field,
- EscapeQuerySyntaxImpl.discardEscapeChar(goop1.image), goop1.beginColumn, goop1.endColumn);
- qUpper = new FieldQueryNode(field,
- EscapeQuerySyntaxImpl.discardEscapeChar(goop2.image), goop2.beginColumn, goop2.endColumn);
+ EscapeQuerySyntaxImpl.discardEscapeChar(goop1.image), goop1.beginColumn, goop1.endColumn);
+ qUpper = new FieldQueryNode(field,
+ EscapeQuerySyntaxImpl.discardEscapeChar(goop2.image), goop2.beginColumn, goop2.endColumn);
q = new TermRangeQueryNode(qLower, qUpper, startInc ? true : false, endInc ? true : false);
}
| term=<QUOTED> {q = new QuotedFieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image.substring(1, term.image.length()-1)), term.beginColumn + 1, term.endColumn - 1);}
@@ -486,28 +489,28 @@ QueryNode Term(CharSequence field) : {
}
catch (Exception ignored) {
/* Should this be handled somehow? (defaults to "no PhraseSlop", if
- * slop number is invalid)
- */
+ * slop number is invalid)
+ */
}
}
}
)
{
- if (boost != null) {
- float f = (float)1.0;
- try {
- f = Float.valueOf(boost.image).floatValue();
- // avoid boosting null queries, such as those caused by stop words
- if (q != null) {
- q = new BoostQueryNode(q, f);
- }
- } catch (Exception ignored) {
- /* Should this be handled somehow? (defaults to "no boost", if
- * boost number is invalid)
- */
- }
- }
+ if (boost != null) {
+ float f = (float)1.0;
+ try {
+ f = Float.valueOf(boost.image).floatValue();
+ // avoid boosting null queries, such as those caused by stop words
+ if (q != null) {
+ q = new BoostQueryNode(q, f);
+ }
+ } catch (Exception ignored) {
+ /* Should this be handled somehow? (defaults to "no boost", if
+ * boost number is invalid)
+ */
+ }
+ }
return q;
}
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java Fri Sep 21 17:21:34 2012
@@ -1,12 +1,19 @@
-/* Generated By:JavaCC: Do not edit this line. Token.java Version 4.1 */
-/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null */
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
+/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package org.apache.lucene.queryparser.flexible.standard.parser;
/**
* Describes the input token stream.
*/
-public class Token {
+public class Token implements java.io.Serializable {
+
+ /**
+ * The version identifier for this Serializable class.
+ * Increment only if the <i>serialized</i> form of the
+ * class changes.
+ */
+ private static final long serialVersionUID = 1L;
/**
* An integer that describes the kind of this token. This numbering
@@ -75,7 +82,7 @@ public class Token {
*/
public Token(int kind)
{
- this(kind, null);
+ this(kind, null);
}
/**
@@ -83,8 +90,8 @@ public class Token {
*/
public Token(int kind, String image)
{
- this.kind = kind;
- this.image = image;
+ this.kind = kind;
+ this.image = image;
}
/**
@@ -92,7 +99,7 @@ public class Token {
*/
public String toString()
{
- return image;
+ return image;
}
/**
@@ -109,16 +116,16 @@ public class Token {
*/
public static Token newToken(int ofKind, String image)
{
- switch(ofKind)
- {
- default : return new Token(ofKind, image);
- }
+ switch(ofKind)
+ {
+ default : return new Token(ofKind, image);
+ }
}
public static Token newToken(int ofKind)
{
- return newToken(ofKind, null);
+ return newToken(ofKind, null);
}
}
-/* JavaCC - OriginalChecksum=3b4fe6dcfcfa24a81f1c6ceffae5f73a (do not edit this line) */
+/* JavaCC - OriginalChecksum=ea8b1e55950603be28e2f63dcd544ab4 (do not edit this line) */
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java Fri Sep 21 17:21:34 2012
@@ -1,141 +1,147 @@
-/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 4.1 */
+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */
/* JavaCCOptions: */
package org.apache.lucene.queryparser.flexible.standard.parser;
/** Token Manager Error. */
-@SuppressWarnings("serial")
public class TokenMgrError extends Error
{
- /*
- * Ordinals for various reasons why an Error of this type can be thrown.
- */
-
- /**
- * Lexical error occurred.
- */
- static final int LEXICAL_ERROR = 0;
-
- /**
- * An attempt was made to create a second instance of a static token manager.
- */
- static final int STATIC_LEXER_ERROR = 1;
-
- /**
- * Tried to change to an invalid lexical state.
- */
- static final int INVALID_LEXICAL_STATE = 2;
-
- /**
- * Detected (and bailed out of) an infinite loop in the token manager.
- */
- static final int LOOP_DETECTED = 3;
-
- /**
- * Indicates the reason why the exception is thrown. It will have
- * one of the above 4 values.
- */
- int errorCode;
-
- /**
- * Replaces unprintable characters by their escaped (or unicode escaped)
- * equivalents in the given string
- */
- protected static final String addEscapes(String str) {
- StringBuffer retval = new StringBuffer();
- char ch;
- for (int i = 0; i < str.length(); i++) {
- switch (str.charAt(i))
- {
- case 0 :
- continue;
- case '\b':
- retval.append("\\b");
- continue;
- case '\t':
- retval.append("\\t");
- continue;
- case '\n':
- retval.append("\\n");
- continue;
- case '\f':
- retval.append("\\f");
- continue;
- case '\r':
- retval.append("\\r");
- continue;
- case '\"':
- retval.append("\\\"");
- continue;
- case '\'':
- retval.append("\\\'");
- continue;
- case '\\':
- retval.append("\\\\");
- continue;
- default:
- if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
- String s = "0000" + Integer.toString(ch, 16);
- retval.append("\\u" + s.substring(s.length() - 4, s.length()));
- } else {
- retval.append(ch);
- }
- continue;
- }
+ /**
+ * The version identifier for this Serializable class.
+ * Increment only if the <i>serialized</i> form of the
+ * class changes.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /*
+ * Ordinals for various reasons why an Error of this type can be thrown.
+ */
+
+ /**
+ * Lexical error occurred.
+ */
+ static final int LEXICAL_ERROR = 0;
+
+ /**
+ * An attempt was made to create a second instance of a static token manager.
+ */
+ static final int STATIC_LEXER_ERROR = 1;
+
+ /**
+ * Tried to change to an invalid lexical state.
+ */
+ static final int INVALID_LEXICAL_STATE = 2;
+
+ /**
+ * Detected (and bailed out of) an infinite loop in the token manager.
+ */
+ static final int LOOP_DETECTED = 3;
+
+ /**
+ * Indicates the reason why the exception is thrown. It will have
+ * one of the above 4 values.
+ */
+ int errorCode;
+
+ /**
+ * Replaces unprintable characters by their escaped (or unicode escaped)
+ * equivalents in the given string
+ */
+ protected static final String addEscapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
}
- return retval.toString();
- }
-
- /**
- * Returns a detailed message for the Error when it is thrown by the
- * token manager to indicate a lexical error.
- * Parameters :
- * EOFSeen : indicates if EOF caused the lexical error
- * curLexState : lexical state in which this error occurred
- * errorLine : line number when the error occurred
- * errorColumn : column number when the error occurred
- * errorAfter : prefix that was seen before this error occurred
- * curchar : the offending character
- * Note: You can customize the lexical error message by modifying this method.
- */
- protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
- return("Lexical error at line " +
- errorLine + ", column " +
- errorColumn + ". Encountered: " +
- (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
- "after : \"" + addEscapes(errorAfter) + "\"");
- }
-
- /**
- * You can also modify the body of this method to customize your error messages.
- * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
- * of end-users concern, so you can return something like :
- *
- * "Internal Error : Please file a bug report .... "
- *
- * from this method for such cases in the release version of your parser.
- */
- public String getMessage() {
- return super.getMessage();
- }
-
- /*
- * Constructors of various flavors follow.
- */
-
- /** No arg constructor. */
- public TokenMgrError() {
- }
-
- /** Constructor with message and reason. */
- public TokenMgrError(String message, int reason) {
- super(message);
- errorCode = reason;
- }
-
- /** Full Constructor. */
- public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
- this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
- }
+ }
+ return retval.toString();
+ }
+
+ /**
+ * Returns a detailed message for the Error when it is thrown by the
+ * token manager to indicate a lexical error.
+ * Parameters :
+ * EOFSeen : indicates if EOF caused the lexical error
+ * curLexState : lexical state in which this error occurred
+ * errorLine : line number when the error occurred
+ * errorColumn : column number when the error occurred
+ * errorAfter : prefix that was seen before this error occurred
+ * curchar : the offending character
+ * Note: You can customize the lexical error message by modifying this method.
+ */
+ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
+ return("Lexical error at line " +
+ errorLine + ", column " +
+ errorColumn + ". Encountered: " +
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
+ "after : \"" + addEscapes(errorAfter) + "\"");
+ }
+
+ /**
+ * You can also modify the body of this method to customize your error messages.
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
+ * of end-users concern, so you can return something like :
+ *
+ * "Internal Error : Please file a bug report .... "
+ *
+ * from this method for such cases in the release version of your parser.
+ */
+ public String getMessage() {
+ return super.getMessage();
+ }
+
+ /*
+ * Constructors of various flavors follow.
+ */
+
+ /** No arg constructor. */
+ public TokenMgrError() {
+ }
+
+ /** Constructor with message and reason. */
+ public TokenMgrError(String message, int reason) {
+ super(message);
+ errorCode = reason;
+ }
+
+ /** Full Constructor. */
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
+ }
}
-/* JavaCC - OriginalChecksum=1efb3d906925f2478637c66473b79bae (do not edit this line) */
+/* JavaCC - OriginalChecksum=be88283d82a985d82a34dda46bcf42d5 (do not edit this line) */
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/OpenRangeQueryNodeProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/OpenRangeQueryNodeProcessor.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/OpenRangeQueryNodeProcessor.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/OpenRangeQueryNodeProcessor.java Fri Sep 21 17:21:34 2012
@@ -19,6 +19,7 @@ package org.apache.lucene.queryparser.fl
import java.util.List;
+import org.apache.lucene.search.TermRangeQuery; // javadocs
import org.apache.lucene.queryparser.flexible.core.QueryNodeException;
import org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode;
import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode;
@@ -26,6 +27,9 @@ import org.apache.lucene.queryparser.fle
import org.apache.lucene.queryparser.flexible.core.util.UnescapedCharSequence;
import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode;
+/**
+ * Processes {@link TermRangeQuery}s with open ranges.
+ */
public class OpenRangeQueryNodeProcessor extends QueryNodeProcessorImpl {
final public static String OPEN_RANGE_TOKEN = "*";
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/CharStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/CharStream.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/CharStream.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/CharStream.java Fri Sep 21 17:21:34 2012
@@ -1,5 +1,5 @@
-/* Generated By:JavaCC: Do not edit this line. CharStream.java Version 4.1 */
-/* JavaCCOptions:STATIC=false */
+/* Generated By:JavaCC: Do not edit this line. CharStream.java Version 5.0 */
+/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package org.apache.lucene.queryparser.surround.parser;
/**
@@ -17,7 +17,8 @@ package org.apache.lucene.queryparser.su
* operation.
*/
-public interface CharStream {
+public
+interface CharStream {
/**
* Returns the next character from the selected input. The method
@@ -26,6 +27,7 @@ public interface CharStream {
*/
char readChar() throws java.io.IOException;
+ @Deprecated
/**
* Returns the column position of the character last read.
* @deprecated
@@ -33,6 +35,7 @@ public interface CharStream {
*/
int getColumn();
+ @Deprecated
/**
* Returns the line number of the character last read.
* @deprecated
@@ -109,4 +112,4 @@ public interface CharStream {
void Done();
}
-/* JavaCC - OriginalChecksum=def574f5a8956cf01b79ebe7bce95e74 (do not edit this line) */
+/* JavaCC - OriginalChecksum=242ae59b965491e225a44534cbc73b42 (do not edit this line) */
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/FastCharStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/FastCharStream.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/FastCharStream.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/FastCharStream.java Fri Sep 21 17:21:34 2012
@@ -26,13 +26,13 @@ import java.io.*;
public final class FastCharStream implements CharStream {
char[] buffer = null;
- int bufferLength = 0; // end of valid chars
- int bufferPosition = 0; // next char to read
+ int bufferLength = 0; // end of valid chars
+ int bufferPosition = 0; // next char to read
- int tokenStart = 0; // offset in buffer
- int bufferStart = 0; // position in file of buffer
+ int tokenStart = 0; // offset in buffer
+ int bufferStart = 0; // position in file of buffer
- Reader input; // source of chars
+ Reader input; // source of chars
/** Constructs from a Reader. */
public FastCharStream(Reader r) {
@@ -48,24 +48,24 @@ public final class FastCharStream implem
private final void refill() throws IOException {
int newPosition = bufferLength - tokenStart;
- if (tokenStart == 0) { // token won't fit in buffer
- if (buffer == null) { // first time: alloc buffer
- buffer = new char[2048];
+ if (tokenStart == 0) { // token won't fit in buffer
+ if (buffer == null) { // first time: alloc buffer
+ buffer = new char[2048];
} else if (bufferLength == buffer.length) { // grow buffer
- char[] newBuffer = new char[buffer.length*2];
- System.arraycopy(buffer, 0, newBuffer, 0, bufferLength);
- buffer = newBuffer;
+ char[] newBuffer = new char[buffer.length * 2];
+ System.arraycopy(buffer, 0, newBuffer, 0, bufferLength);
+ buffer = newBuffer;
}
- } else { // shift token to front
+ } else { // shift token to front
System.arraycopy(buffer, tokenStart, buffer, 0, newPosition);
}
- bufferLength = newPosition; // update state
+ bufferLength = newPosition; // update state
bufferPosition = newPosition;
bufferStart += tokenStart;
tokenStart = 0;
- int charsRead = // fill space in buffer
+ int charsRead = // fill space in buffer
input.read(buffer, newPosition, buffer.length-newPosition);
if (charsRead == -1)
throw new IOException("read past eof");
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java Fri Sep 21 17:21:34 2012
@@ -1,4 +1,4 @@
-/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 4.1 */
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */
/* JavaCCOptions:KEEP_LINE_COL=null */
package org.apache.lucene.queryparser.surround.parser;
@@ -14,24 +14,24 @@ package org.apache.lucene.queryparser.su
public class ParseException extends Exception {
/**
+ * The version identifier for this Serializable class.
+ * Increment only if the <i>serialized</i> form of the
+ * class changes.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
* This constructor is used by the method "generateParseException"
* in the generated parser. Calling this constructor generates
* a new object of this type with the fields "currentToken",
- * "expectedTokenSequences", and "tokenImage" set. The boolean
- * flag "specialConstructor" is also set to true to indicate that
- * this constructor was used to create this object.
- * This constructor calls its super class with the empty string
- * to force the "toString" method of parent class "Throwable" to
- * print the error message in the form:
- * ParseException: <result of getMessage>
+ * "expectedTokenSequences", and "tokenImage" set.
*/
public ParseException(Token currentTokenVal,
int[][] expectedTokenSequencesVal,
String[] tokenImageVal
)
{
- super("");
- specialConstructor = true;
+ super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal));
currentToken = currentTokenVal;
expectedTokenSequences = expectedTokenSequencesVal;
tokenImage = tokenImageVal;
@@ -49,21 +49,13 @@ public class ParseException extends Exce
public ParseException() {
super();
- specialConstructor = false;
}
/** Constructor with message. */
public ParseException(String message) {
super(message);
- specialConstructor = false;
}
- /**
- * This variable determines which constructor was used to create
- * this object and thereby affects the semantics of the
- * "getMessage" method (see below).
- */
- protected boolean specialConstructor;
/**
* This is the last token that has been consumed successfully. If
@@ -87,19 +79,16 @@ public class ParseException extends Exce
public String[] tokenImage;
/**
- * This method has the standard behavior when this object has been
- * created using the standard constructors. Otherwise, it uses
- * "currentToken" and "expectedTokenSequences" to generate a parse
+ * It uses "currentToken" and "expectedTokenSequences" to generate a parse
* error message and returns it. If this object has been created
* due to a parse error, and you do not catch it (it gets thrown
- * from the parser), then this method is called during the printing
- * of the final stack trace, and hence the correct error message
+ * from the parser) the correct error message
* gets displayed.
*/
- public String getMessage() {
- if (!specialConstructor) {
- return super.getMessage();
- }
+ private static String initialise(Token currentToken,
+ int[][] expectedTokenSequences,
+ String[] tokenImage) {
+ String eol = System.getProperty("line.separator", "\n");
StringBuffer expected = new StringBuffer();
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
@@ -149,7 +138,7 @@ public class ParseException extends Exce
* when these raw version cannot be used as part of an ASCII
* string literal.
*/
- protected String add_escapes(String str) {
+ static String add_escapes(String str) {
StringBuffer retval = new StringBuffer();
char ch;
for (int i = 0; i < str.length(); i++) {
@@ -195,4 +184,4 @@ public class ParseException extends Exce
}
}
-/* JavaCC - OriginalChecksum=10f9a58db50336511327c43cc760ac21 (do not edit this line) */
+/* JavaCC - OriginalChecksum=bd8163f41bf2fd1bb00f025fce3dcaaf (do not edit this line) */
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java Fri Sep 21 17:21:34 2012
@@ -52,7 +52,7 @@ public class QueryParser implements Quer
/* CHECKME: These should be the same as for the tokenizer. How? */
final char truncator = '*';
final char anyChar = '?';
- final char quote = '\"';
+ final char quote = '\u005c"';
final char fieldOperator = ':';
final char comma = ','; /* prefix list separator */
final char carat = '^'; /* weight operator */
@@ -644,7 +644,7 @@ public class QueryParser implements Quer
return (jj_ntk = jj_nt.kind);
}
- private java.util.List jj_expentries = new java.util.ArrayList();
+ private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
private int[] jj_expentry;
private int jj_kind = -1;
private int[] jj_lasttokens = new int[100];
@@ -659,7 +659,7 @@ public class QueryParser implements Quer
for (int i = 0; i < jj_endpos; i++) {
jj_expentry[i] = jj_lasttokens[i];
}
- jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) {
+ jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext();) {
int[] oldentry = (int[])(it.next());
if (oldentry.length == jj_expentry.length) {
for (int i = 0; i < jj_expentry.length; i++) {
@@ -704,7 +704,7 @@ public class QueryParser implements Quer
jj_add_error_token(0, 0);
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
- exptokseq[i] = (int[])jj_expentries.get(i);
+ exptokseq[i] = jj_expentries.get(i);
}
return new ParseException(token, exptokseq, tokenImage);
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/Token.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/Token.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/Token.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/Token.java Fri Sep 21 17:21:34 2012
@@ -1,12 +1,19 @@
-/* Generated By:JavaCC: Do not edit this line. Token.java Version 4.1 */
-/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null */
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
+/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package org.apache.lucene.queryparser.surround.parser;
/**
* Describes the input token stream.
*/
-public class Token {
+public class Token implements java.io.Serializable {
+
+ /**
+ * The version identifier for this Serializable class.
+ * Increment only if the <i>serialized</i> form of the
+ * class changes.
+ */
+ private static final long serialVersionUID = 1L;
/**
* An integer that describes the kind of this token. This numbering
@@ -75,7 +82,7 @@ public class Token {
*/
public Token(int kind)
{
- this(kind, null);
+ this(kind, null);
}
/**
@@ -83,8 +90,8 @@ public class Token {
*/
public Token(int kind, String image)
{
- this.kind = kind;
- this.image = image;
+ this.kind = kind;
+ this.image = image;
}
/**
@@ -92,7 +99,7 @@ public class Token {
*/
public String toString()
{
- return image;
+ return image;
}
/**
@@ -109,16 +116,16 @@ public class Token {
*/
public static Token newToken(int ofKind, String image)
{
- switch(ofKind)
- {
- default : return new Token(ofKind, image);
- }
+ switch(ofKind)
+ {
+ default : return new Token(ofKind, image);
+ }
}
public static Token newToken(int ofKind)
{
- return newToken(ofKind, null);
+ return newToken(ofKind, null);
}
}
-/* JavaCC - OriginalChecksum=072a7ad2709e5810f5c35fa113fa0c8b (do not edit this line) */
+/* JavaCC - OriginalChecksum=f2df701e24da1cf2d025118ce6efdd2f (do not edit this line) */
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java Fri Sep 21 17:21:34 2012
@@ -1,141 +1,147 @@
-/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 4.1 */
+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */
/* JavaCCOptions: */
package org.apache.lucene.queryparser.surround.parser;
/** Token Manager Error. */
-@SuppressWarnings("serial")
public class TokenMgrError extends Error
{
- /*
- * Ordinals for various reasons why an Error of this type can be thrown.
- */
-
- /**
- * Lexical error occurred.
- */
- static final int LEXICAL_ERROR = 0;
-
- /**
- * An attempt was made to create a second instance of a static token manager.
- */
- static final int STATIC_LEXER_ERROR = 1;
-
- /**
- * Tried to change to an invalid lexical state.
- */
- static final int INVALID_LEXICAL_STATE = 2;
-
- /**
- * Detected (and bailed out of) an infinite loop in the token manager.
- */
- static final int LOOP_DETECTED = 3;
-
- /**
- * Indicates the reason why the exception is thrown. It will have
- * one of the above 4 values.
- */
- int errorCode;
-
- /**
- * Replaces unprintable characters by their escaped (or unicode escaped)
- * equivalents in the given string
- */
- protected static final String addEscapes(String str) {
- StringBuffer retval = new StringBuffer();
- char ch;
- for (int i = 0; i < str.length(); i++) {
- switch (str.charAt(i))
- {
- case 0 :
- continue;
- case '\b':
- retval.append("\\b");
- continue;
- case '\t':
- retval.append("\\t");
- continue;
- case '\n':
- retval.append("\\n");
- continue;
- case '\f':
- retval.append("\\f");
- continue;
- case '\r':
- retval.append("\\r");
- continue;
- case '\"':
- retval.append("\\\"");
- continue;
- case '\'':
- retval.append("\\\'");
- continue;
- case '\\':
- retval.append("\\\\");
- continue;
- default:
- if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
- String s = "0000" + Integer.toString(ch, 16);
- retval.append("\\u" + s.substring(s.length() - 4, s.length()));
- } else {
- retval.append(ch);
- }
- continue;
- }
+ /**
+ * The version identifier for this Serializable class.
+ * Increment only if the <i>serialized</i> form of the
+ * class changes.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /*
+ * Ordinals for various reasons why an Error of this type can be thrown.
+ */
+
+ /**
+ * Lexical error occurred.
+ */
+ static final int LEXICAL_ERROR = 0;
+
+ /**
+ * An attempt was made to create a second instance of a static token manager.
+ */
+ static final int STATIC_LEXER_ERROR = 1;
+
+ /**
+ * Tried to change to an invalid lexical state.
+ */
+ static final int INVALID_LEXICAL_STATE = 2;
+
+ /**
+ * Detected (and bailed out of) an infinite loop in the token manager.
+ */
+ static final int LOOP_DETECTED = 3;
+
+ /**
+ * Indicates the reason why the exception is thrown. It will have
+ * one of the above 4 values.
+ */
+ int errorCode;
+
+ /**
+ * Replaces unprintable characters by their escaped (or unicode escaped)
+ * equivalents in the given string
+ */
+ protected static final String addEscapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
}
- return retval.toString();
- }
-
- /**
- * Returns a detailed message for the Error when it is thrown by the
- * token manager to indicate a lexical error.
- * Parameters :
- * EOFSeen : indicates if EOF caused the lexical error
- * curLexState : lexical state in which this error occurred
- * errorLine : line number when the error occurred
- * errorColumn : column number when the error occurred
- * errorAfter : prefix that was seen before this error occurred
- * curchar : the offending character
- * Note: You can customize the lexical error message by modifying this method.
- */
- protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
- return("Lexical error at line " +
- errorLine + ", column " +
- errorColumn + ". Encountered: " +
- (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
- "after : \"" + addEscapes(errorAfter) + "\"");
- }
-
- /**
- * You can also modify the body of this method to customize your error messages.
- * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
- * of end-users concern, so you can return something like :
- *
- * "Internal Error : Please file a bug report .... "
- *
- * from this method for such cases in the release version of your parser.
- */
- public String getMessage() {
- return super.getMessage();
- }
-
- /*
- * Constructors of various flavors follow.
- */
-
- /** No arg constructor. */
- public TokenMgrError() {
- }
-
- /** Constructor with message and reason. */
- public TokenMgrError(String message, int reason) {
- super(message);
- errorCode = reason;
- }
-
- /** Full Constructor. */
- public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
- this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
- }
+ }
+ return retval.toString();
+ }
+
+ /**
+ * Returns a detailed message for the Error when it is thrown by the
+ * token manager to indicate a lexical error.
+ * Parameters :
+ * EOFSeen : indicates if EOF caused the lexical error
+ * curLexState : lexical state in which this error occurred
+ * errorLine : line number when the error occurred
+ * errorColumn : column number when the error occurred
+ * errorAfter : prefix that was seen before this error occurred
+ * curchar : the offending character
+ * Note: You can customize the lexical error message by modifying this method.
+ */
+ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
+ return("Lexical error at line " +
+ errorLine + ", column " +
+ errorColumn + ". Encountered: " +
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
+ "after : \"" + addEscapes(errorAfter) + "\"");
+ }
+
+ /**
+ * You can also modify the body of this method to customize your error messages.
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
+ * of end-users concern, so you can return something like :
+ *
+ * "Internal Error : Please file a bug report .... "
+ *
+ * from this method for such cases in the release version of your parser.
+ */
+ public String getMessage() {
+ return super.getMessage();
+ }
+
+ /*
+ * Constructors of various flavors follow.
+ */
+
+ /** No arg constructor. */
+ public TokenMgrError() {
+ }
+
+ /** Constructor with message and reason. */
+ public TokenMgrError(String message, int reason) {
+ super(message);
+ errorCode = reason;
+ }
+
+ /** Full Constructor. */
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
+ }
}
-/* JavaCC - OriginalChecksum=9cfe06f5ffcaac4b72c928c9ced2f5e7 (do not edit this line) */
+/* JavaCC - OriginalChecksum=8c69a370d9a9893140562c8bb911678c (do not edit this line) */
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/AndQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/AndQuery.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/AndQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/AndQuery.java Fri Sep 21 17:21:34 2012
@@ -21,6 +21,9 @@ import java.util.List;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.BooleanClause;
+/**
+ * Factory for conjunctions
+ */
public class AndQuery extends ComposedQuery {
public AndQuery(List<SrndQuery> queries, boolean inf, String opName) {
super(queries, inf, opName);
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/BasicQueryFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/BasicQueryFactory.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/BasicQueryFactory.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/BasicQueryFactory.java Fri Sep 21 17:21:34 2012
@@ -29,6 +29,7 @@ import org.apache.lucene.index.Term;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
+/** Factory for creating basic term queries */
public class BasicQueryFactory {
public BasicQueryFactory(int maxBasicQueries) {
this.maxBasicQueries = maxBasicQueries;
@@ -47,9 +48,9 @@ public class BasicQueryFactory {
public String toString() {
return getClass().getName()
- + "(maxBasicQueries: " + maxBasicQueries
- + ", queriesMade: " + queriesMade
- + ")";
+ + "(maxBasicQueries: " + maxBasicQueries
+ + ", queriesMade: " + queriesMade
+ + ")";
}
private boolean atMax() {
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/ComposedQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/ComposedQuery.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/ComposedQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/ComposedQuery.java Fri Sep 21 17:21:34 2012
@@ -22,6 +22,7 @@ import java.util.Iterator;
import org.apache.lucene.search.Query;
+/** Base class for composite queries (such as AND/OR/NOT) */
public abstract class ComposedQuery extends SrndQuery {
public ComposedQuery(List<SrndQuery> qs, boolean operatorInfix, String opName) {
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/DistanceQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/DistanceQuery.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/DistanceQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/DistanceQuery.java Fri Sep 21 17:21:34 2012
@@ -26,6 +26,7 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.spans.SpanNearQuery;
import org.apache.lucene.search.spans.SpanQuery;
+/** Factory for NEAR queries */
public class DistanceQuery extends ComposedQuery implements DistanceSubQuery {
public DistanceQuery(
List<SrndQuery> queries,
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/DistanceSubQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/DistanceSubQuery.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/DistanceSubQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/DistanceSubQuery.java Fri Sep 21 17:21:34 2012
@@ -18,6 +18,10 @@ package org.apache.lucene.queryparser.su
import java.io.IOException;
+/**
+ * Interface for queries that can be nested as subqueries
+ * into a span near.
+ */
public interface DistanceSubQuery {
/** When distanceSubQueryNotAllowed() returns non null, the reason why the subquery
* is not allowed as a distance subquery is returned.
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/FieldsQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/FieldsQuery.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/FieldsQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/FieldsQuery.java Fri Sep 21 17:21:34 2012
@@ -22,6 +22,9 @@ import java.util.Iterator;
import org.apache.lucene.search.Query;
+/**
+ * Forms an OR query of the provided query across multiple fields.
+ */
public class FieldsQuery extends SrndQuery { /* mostly untested */
private SrndQuery q;
private List<String> fieldNames;
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/NotQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/NotQuery.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/NotQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/NotQuery.java Fri Sep 21 17:21:34 2012
@@ -21,6 +21,9 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.BooleanClause;
+/**
+ * Factory for prohibited clauses
+ */
public class NotQuery extends ComposedQuery {
public NotQuery(List<SrndQuery> queries, String opName) { super(queries, true /* infix */, opName); }
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/OrQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/OrQuery.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/OrQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/OrQuery.java Fri Sep 21 17:21:34 2012
@@ -23,6 +23,9 @@ import org.apache.lucene.search.BooleanC
import java.io.IOException;
+/**
+ * Factory for disjunctions
+ */
public class OrQuery extends ComposedQuery implements DistanceSubQuery {
public OrQuery(List<SrndQuery> queries, boolean infix, String opName) {
super(queries, infix, opName);
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/RewriteQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/RewriteQuery.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/RewriteQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/RewriteQuery.java Fri Sep 21 17:21:34 2012
@@ -45,19 +45,19 @@ abstract class RewriteQuery<SQ extends S
@Override
public String toString(String field) {
return getClass().getName()
- + (field == null ? "" : "(unused: " + field + ")")
- + "(" + fieldName
- + ", " + srndQuery.toString()
- + ", " + qf.toString()
- + ")";
+ + (field == null ? "" : "(unused: " + field + ")")
+ + "(" + fieldName
+ + ", " + srndQuery.toString()
+ + ", " + qf.toString()
+ + ")";
}
@Override
public int hashCode() {
return getClass().hashCode()
- ^ fieldName.hashCode()
- ^ qf.hashCode()
- ^ srndQuery.hashCode();
+ ^ fieldName.hashCode()
+ ^ qf.hashCode()
+ ^ srndQuery.hashCode();
}
@Override
@@ -68,8 +68,8 @@ abstract class RewriteQuery<SQ extends S
return false;
RewriteQuery other = (RewriteQuery)obj;
return fieldName.equals(other.fieldName)
- && qf.equals(other.qf)
- && srndQuery.equals(other.srndQuery);
+ && qf.equals(other.qf)
+ && srndQuery.equals(other.srndQuery);
}
/** @throws UnsupportedOperationException */
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SimpleTerm.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SimpleTerm.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SimpleTerm.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SimpleTerm.java Fri Sep 21 17:21:34 2012
@@ -22,6 +22,9 @@ import org.apache.lucene.index.IndexRead
import org.apache.lucene.index.Term;
import org.apache.lucene.search.Query;
+/**
+ * Base class for queries that expand to sets of simple terms.
+ */
public abstract class SimpleTerm
extends SrndQuery
implements DistanceSubQuery, Comparable<SimpleTerm>
@@ -67,6 +70,10 @@ public abstract class SimpleTerm
String fieldName,
MatchingTermVisitor mtv) throws IOException;
+ /**
+ * Callback to visit each matching term during "rewrite"
+ * in {@link #visitMatchingTerm(Term)}
+ */
public interface MatchingTermVisitor {
void visitMatchingTerm(Term t)throws IOException;
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SimpleTermRewriteQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SimpleTermRewriteQuery.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SimpleTermRewriteQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SimpleTermRewriteQuery.java Fri Sep 21 17:21:34 2012
@@ -37,16 +37,16 @@ class SimpleTermRewriteQuery extends Rew
public Query rewrite(IndexReader reader) throws IOException {
final List<Query> luceneSubQueries = new ArrayList<Query>();
srndQuery.visitMatchingTerms(reader, fieldName,
- new SimpleTerm.MatchingTermVisitor() {
- public void visitMatchingTerm(Term term) throws IOException {
- luceneSubQueries.add(qf.newTermQuery(term));
- }
- });
+ new SimpleTerm.MatchingTermVisitor() {
+ public void visitMatchingTerm(Term term) throws IOException {
+ luceneSubQueries.add(qf.newTermQuery(term));
+ }
+ });
return (luceneSubQueries.size() == 0) ? SrndQuery.theEmptyLcnQuery
- : (luceneSubQueries.size() == 1) ? luceneSubQueries.get(0)
- : SrndBooleanQuery.makeBooleanQuery(
- /* luceneSubQueries all have default weight */
- luceneSubQueries, BooleanClause.Occur.SHOULD); /* OR the subquery terms */
+ : (luceneSubQueries.size() == 1) ? luceneSubQueries.get(0)
+ : SrndBooleanQuery.makeBooleanQuery(
+ /* luceneSubQueries all have default weight */
+ luceneSubQueries, BooleanClause.Occur.SHOULD); /* OR the subquery terms */
}
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SpanNearClauseFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SpanNearClauseFactory.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SpanNearClauseFactory.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SpanNearClauseFactory.java Fri Sep 21 17:21:34 2012
@@ -64,6 +64,9 @@ import org.apache.lucene.search.spans.Sp
import org.apache.lucene.search.spans.SpanTermQuery;
+/**
+ * Factory for {@link SpanOrQuery}
+ */
public class SpanNearClauseFactory { // FIXME: rename to SpanClauseFactory
public SpanNearClauseFactory(IndexReader reader, String fieldName, BasicQueryFactory qf) {
this.reader = reader;
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndPrefixQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndPrefixQuery.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndPrefixQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndPrefixQuery.java Fri Sep 21 17:21:34 2012
@@ -27,6 +27,9 @@ import org.apache.lucene.index.MultiFiel
import java.io.IOException;
+/**
+ * Query that matches String prefixes
+ */
public class SrndPrefixQuery extends SimpleTerm {
private final BytesRef prefixRef;
public SrndPrefixQuery(String prefix, boolean quoted, char truncator) {
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndQuery.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndQuery.java Fri Sep 21 17:21:34 2012
@@ -20,6 +20,7 @@ import org.apache.lucene.search.BooleanC
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Query;
+/** Lowest level base class for surround queries */
public abstract class SrndQuery implements Cloneable {
public SrndQuery() {}
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndTermQuery.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndTermQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndTermQuery.java Fri Sep 21 17:21:34 2012
@@ -26,6 +26,9 @@ import org.apache.lucene.index.MultiFiel
import org.apache.lucene.util.BytesRef;
+/**
+ * Simple single-term clause
+ */
public class SrndTermQuery extends SimpleTerm {
public SrndTermQuery(String termText, boolean quoted) {
super(quoted);
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndTruncQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndTruncQuery.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndTruncQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndTruncQuery.java Fri Sep 21 17:21:34 2012
@@ -29,7 +29,9 @@ import java.io.IOException;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
-
+/**
+ * Query that matches wildcards
+ */
public class SrndTruncQuery extends SimpleTerm {
public SrndTruncQuery(String truncated, char unlimited, char mask) {
super(false); /* not quoted */
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/TooManyBasicQueries.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/TooManyBasicQueries.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/TooManyBasicQueries.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/TooManyBasicQueries.java Fri Sep 21 17:21:34 2012
@@ -18,6 +18,10 @@ package org.apache.lucene.queryparser.su
import java.io.IOException; /* subclass to be usable from within Query.rewrite() */
+/**
+ * Exception thrown when {@link BasicQueryFactory} would exceed the limit
+ * of query clauses.
+ */
public class TooManyBasicQueries extends IOException {
public TooManyBasicQueries(int maxBasicQueries) {
super("Exceeded maximum of " + maxBasicQueries + " basic queries.");
Modified: lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/CoreParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/CoreParser.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/CoreParser.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/CoreParser.java Fri Sep 21 17:21:34 2012
@@ -153,5 +153,5 @@ public class CoreParser implements Query
public Query getQuery(Element e) throws ParserException {
return queryFactory.getQuery(e);
- }
+ }
}