You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by cc...@apache.org on 2012/02/28 23:43:28 UTC
[Lucene.Net] svn commit: r1294875 [21/45] - in /incubator/lucene.net/trunk: ./ build/
build/vs2010/contrib/ build/vs2010/test/ doc/ src/ src/contrib/Analyzers/
src/contrib/Analyzers/AR/ src/contrib/Analyzers/BR/
src/contrib/Analyzers/CJK/ src/contrib/Analyzers/Cn/ ...
Modified: incubator/lucene.net/trunk/src/core/QueryParser/QueryParser.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/QueryParser/QueryParser.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/QueryParser/QueryParser.cs (original)
+++ incubator/lucene.net/trunk/src/core/QueryParser/QueryParser.cs Tue Feb 28 22:43:08 2012
@@ -18,7 +18,10 @@
/* Generated By:JavaCC: Do not edit this line. QueryParser.java */
using System;
-
+using System.Collections.Generic;
+using System.Linq;
+using Lucene.Net.Support;
+using Lucene.Net.Util;
using Analyzer = Lucene.Net.Analysis.Analyzer;
using CachingTokenFilter = Lucene.Net.Analysis.CachingTokenFilter;
using TokenStream = Lucene.Net.Analysis.TokenStream;
@@ -27,7 +30,6 @@ using TermAttribute = Lucene.Net.Analysi
using DateField = Lucene.Net.Documents.DateField;
using DateTools = Lucene.Net.Documents.DateTools;
using Term = Lucene.Net.Index.Term;
-using Parameter = Lucene.Net.Util.Parameter;
using BooleanClause = Lucene.Net.Search.BooleanClause;
using BooleanQuery = Lucene.Net.Search.BooleanQuery;
using FuzzyQuery = Lucene.Net.Search.FuzzyQuery;
@@ -37,6 +39,7 @@ using MultiTermQuery = Lucene.Net.Search
using PhraseQuery = Lucene.Net.Search.PhraseQuery;
using PrefixQuery = Lucene.Net.Search.PrefixQuery;
using Query = Lucene.Net.Search.Query;
+using Single = Lucene.Net.Support.Single;
using TermQuery = Lucene.Net.Search.TermQuery;
using TermRangeQuery = Lucene.Net.Search.TermRangeQuery;
using WildcardQuery = Lucene.Net.Search.WildcardQuery;
@@ -163,7 +166,7 @@ namespace Lucene.Net.QueryParsers
// the default date resolution
internal DateTools.Resolution dateResolution = null;
// maps field names to date resolutions
- internal System.Collections.IDictionary fieldToDateResolution = null;
+ internal IDictionary<string, DateTools.Resolution> fieldToDateResolution = null;
// The collator to use when determining range inclusion,
// for use when constructing RangeQuerys.
@@ -172,28 +175,7 @@ namespace Lucene.Net.QueryParsers
/// <summary>The default operator for parsing queries.
/// Use <see cref="QueryParser.SetDefaultOperator" /> to change it.
/// </summary>
- [Serializable]
- public sealed class Operator:Parameter
- {
- internal Operator(System.String name):base(name)
- {
- }
- public static readonly Operator OR = new Operator("OR");
- public static readonly Operator AND = new Operator("AND");
- }
-
-
- /// <summary>Constructs a query parser.</summary>
- /// <param name="f"> the default field for query terms.
- /// </param>
- /// <param name="a"> used to find terms in the query text.
- /// </param>
- /// <deprecated> Use <see cref="QueryParser(Version, String, Analyzer)" /> instead
- /// </deprecated>
- [Obsolete("Use QueryParser(Version, String, Analyzer) instead")]
- public QueryParser(System.String f, Analyzer a):this(Version.LUCENE_24, f, a)
- {
- }
+ public enum Operator { OR, AND }
/// <summary> Constructs a query parser.
///
@@ -387,38 +369,7 @@ namespace Lucene.Net.QueryParsers
{
return lowercaseExpandedTerms;
}
-
- /// <deprecated> Please use <see cref="SetMultiTermRewriteMethod" /> instead.
- /// </deprecated>
- [Obsolete("Please use SetMultiTermRewriteMethod instead.")]
- public virtual void SetUseOldRangeQuery(bool useOldRangeQuery)
- {
- if (useOldRangeQuery)
- {
- SetMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
- }
- else
- {
- SetMultiTermRewriteMethod(MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
- }
- }
-
-
- /// <deprecated> Please use <see cref="GetMultiTermRewriteMethod" /> instead.
- /// </deprecated>
- [Obsolete("Please use GetMultiTermRewriteMethod} instead.")]
- public virtual bool GetUseOldRangeQuery()
- {
- if (GetMultiTermRewriteMethod() == MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
+
/// <summary> By default QueryParser uses <see cref="MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT" />
/// when creating a PrefixQuery, WildcardQuery or RangeQuery. This implementation is generally preferable because it
/// a) Runs faster b) Does not have the scarcity of terms unduly influence score
@@ -481,8 +432,8 @@ namespace Lucene.Net.QueryParsers
if (fieldToDateResolution == null)
{
- // lazily initialize HashMap
- fieldToDateResolution = new System.Collections.Hashtable();
+ // lazily initialize Dictionary
+ fieldToDateResolution = new HashMap<string,DateTools.Resolution>();
}
fieldToDateResolution[fieldName] = dateResolution;
@@ -506,7 +457,7 @@ namespace Lucene.Net.QueryParsers
return this.dateResolution;
}
- DateTools.Resolution resolution = (DateTools.Resolution) fieldToDateResolution[fieldName];
+ DateTools.Resolution resolution = fieldToDateResolution[fieldName];
if (resolution == null)
{
// no date resolutions set for the given field; return default date resolution instead
@@ -540,16 +491,8 @@ namespace Lucene.Net.QueryParsers
{
return rangeCollator;
}
-
- /// <deprecated> use <see cref="AddClause(System.Collections.IList, int, int, Query)" /> instead.
- /// </deprecated>
- [Obsolete("use AddClause(List, int, int, Query) instead.")]
- protected internal virtual void AddClause(System.Collections.ArrayList clauses, int conj, int mods, Query q)
- {
- AddClause((System.Collections.IList) clauses, conj, mods, q);
- }
-
- protected internal virtual void AddClause(System.Collections.IList clauses, int conj, int mods, Query q)
+
+ protected internal virtual void AddClause(IList<BooleanClause> clauses, int conj, int mods, Query q)
{
bool required, prohibited;
@@ -557,8 +500,8 @@ namespace Lucene.Net.QueryParsers
// unless it's already prohibited
if (clauses.Count > 0 && conj == CONJ_AND)
{
- BooleanClause c = (BooleanClause) clauses[clauses.Count - 1];
- if (!c.IsProhibited())
+ BooleanClause c = clauses[clauses.Count - 1];
+ if (!c.Prohibited)
c.SetOccur(BooleanClause.Occur.MUST);
}
@@ -568,8 +511,8 @@ namespace Lucene.Net.QueryParsers
// unless it's prohibited (that means we leave -a OR b but +a OR b-->a OR b)
// notice if the input is a OR b, first term is parsed as required; without
// this modification a OR b would parsed as +a OR b
- BooleanClause c = (BooleanClause) clauses[clauses.Count - 1];
- if (!c.IsProhibited())
+ BooleanClause c = clauses[clauses.Count - 1];
+ if (!c.Prohibited)
c.SetOccur(BooleanClause.Occur.SHOULD);
}
@@ -641,13 +584,13 @@ namespace Lucene.Net.QueryParsers
}
if (success)
{
- if (buffer.HasAttribute(typeof(TermAttribute)))
+ if (buffer.HasAttribute<TermAttribute>())
{
- termAtt = (TermAttribute) buffer.GetAttribute(typeof(TermAttribute));
+ termAtt = buffer.GetAttribute<TermAttribute>();
}
- if (buffer.HasAttribute(typeof(PositionIncrementAttribute)))
+ if (buffer.HasAttribute<PositionIncrementAttribute>())
{
- posIncrAtt = (PositionIncrementAttribute) buffer.GetAttribute(typeof(PositionIncrementAttribute));
+ posIncrAtt = buffer.GetAttribute<PositionIncrementAttribute>();
}
}
@@ -742,7 +685,7 @@ namespace Lucene.Net.QueryParsers
// phrase query:
MultiPhraseQuery mpq = NewMultiPhraseQuery();
mpq.SetSlop(phraseSlop);
- System.Collections.ArrayList multiTerms = new System.Collections.ArrayList();
+ IList<Term> multiTerms = new List<Term>();
int position = - 1;
for (int i = 0; i < numTokens; i++)
{
@@ -767,11 +710,11 @@ namespace Lucene.Net.QueryParsers
{
if (enablePositionIncrements)
{
- mpq.Add((Term[]) multiTerms.ToArray(typeof(Term)), position);
+ mpq.Add(multiTerms.ToArray(), position);
}
else
{
- mpq.Add((Term[]) multiTerms.ToArray(typeof(Term)));
+ mpq.Add(multiTerms.ToArray());
}
multiTerms.Clear();
}
@@ -780,11 +723,11 @@ namespace Lucene.Net.QueryParsers
}
if (enablePositionIncrements)
{
- mpq.Add((Term[]) multiTerms.ToArray(typeof(Term)), position);
+ mpq.Add(multiTerms.ToArray(), position);
}
else
{
- mpq.Add((Term[]) multiTerms.ToArray(typeof(Term)));
+ mpq.Add(multiTerms.ToArray());
}
return mpq;
}
@@ -1050,30 +993,7 @@ namespace Lucene.Net.QueryParsers
/// </returns>
/// <exception cref="ParseException">throw in overridden method to disallow
/// </exception>
- /// <deprecated> use <see cref="GetBooleanQuery(System.Collections.IList)" /> instead
- /// </deprecated>
- [Obsolete("use GetBooleanQuery(List) instead")]
- protected internal virtual Query GetBooleanQuery(System.Collections.ArrayList clauses)
- {
- return GetBooleanQuery((System.Collections.IList) clauses, false);
- }
-
- /// <summary> Factory method for generating query, given a set of clauses.
- /// By default creates a boolean query composed of clauses passed in.
- ///
- /// Can be overridden by extending classes, to modify query being
- /// returned.
- ///
- /// </summary>
- /// <param name="clauses">List that contains <see cref="BooleanClause" /> instances
- /// to join.
- ///
- /// </param>
- /// <returns> Resulting <see cref="Query" /> object.
- /// </returns>
- /// <exception cref="ParseException">throw in overridden method to disallow
- /// </exception>
- protected internal virtual Query GetBooleanQuery(System.Collections.IList clauses)
+ protected internal virtual Query GetBooleanQuery(IList<BooleanClause> clauses)
{
return GetBooleanQuery(clauses, false);
}
@@ -1095,41 +1015,16 @@ namespace Lucene.Net.QueryParsers
/// </returns>
/// <exception cref="ParseException">throw in overridden method to disallow
/// </exception>
- /// <deprecated> use <see cref="GetBooleanQuery(System.Collections.IList, bool)" /> instead
- /// </deprecated>
- [Obsolete("use GetBooleanQuery(List, bool) instead")]
- protected internal virtual Query GetBooleanQuery(System.Collections.ArrayList clauses, bool disableCoord)
- {
- return GetBooleanQuery((System.Collections.IList) clauses, disableCoord);
- }
-
- /// <summary> Factory method for generating query, given a set of clauses.
- /// By default creates a boolean query composed of clauses passed in.
- ///
- /// Can be overridden by extending classes, to modify query being
- /// returned.
- ///
- /// </summary>
- /// <param name="clauses">List that contains <see cref="BooleanClause" /> instances
- /// to join.
- /// </param>
- /// <param name="disableCoord">true if coord scoring should be disabled.
- ///
- /// </param>
- /// <returns> Resulting <see cref="Query" /> object.
- /// </returns>
- /// <exception cref="ParseException">throw in overridden method to disallow
- /// </exception>
- protected internal virtual Query GetBooleanQuery(System.Collections.IList clauses, bool disableCoord)
+ protected internal virtual Query GetBooleanQuery(IList<BooleanClause> clauses, bool disableCoord)
{
if (clauses.Count == 0)
{
return null; // all clause words were filtered away by the analyzer.
}
BooleanQuery query = NewBooleanQuery(disableCoord);
- for (int i = 0; i < clauses.Count; i++)
+ foreach(BooleanClause clause in clauses)
{
- query.Add((BooleanClause) clauses[i]);
+ query.Add(clause);
}
return query;
}
@@ -1271,7 +1166,7 @@ namespace Lucene.Net.QueryParsers
if (codePointMultiplier > 0)
{
codePoint += HexToInt(curChar) * codePointMultiplier;
- codePointMultiplier = SupportClass.Number.URShift(codePointMultiplier, 4);
+ codePointMultiplier = Number.URShift(codePointMultiplier, 4);
if (codePointMultiplier == 0)
{
output[length++] = (char) codePoint;
@@ -1351,11 +1246,14 @@ namespace Lucene.Net.QueryParsers
{
char c = s[i];
// These characters are part of the query syntax and must be escaped
- if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':' || c == '^' || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' || c == '~' || c == '*' || c == '?' || c == '|' || c == '&')
- {
- sb.Append('\\');
- }
- sb.Append(c);
+ if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' ||
+ c == ')' || c == ':' || c == '^' || c == '[' || c == ']' ||
+ c == '\"' || c == '{' || c == '}' || c == '~' || c == '*' ||
+ c == '?' || c == '|' || c == '&')
+ {
+ sb.Append('\\');
+ }
+ sb.Append(c);
}
return sb.ToString();
}
@@ -1384,19 +1282,18 @@ namespace Lucene.Net.QueryParsers
int ret = CONJ_NONE;
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
-
- case Lucene.Net.QueryParsers.QueryParserConstants.AND:
- case Lucene.Net.QueryParsers.QueryParserConstants.OR:
+ case Lucene.Net.QueryParsers.QueryParserConstants.AndToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.OrToken:
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.AND:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.AND);
+ case Lucene.Net.QueryParsers.QueryParserConstants.AndToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.AndToken);
ret = CONJ_AND;
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.OR:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.OR);
+ case Lucene.Net.QueryParsers.QueryParserConstants.OrToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.OrToken);
ret = CONJ_OR;
break;
@@ -1427,24 +1324,24 @@ namespace Lucene.Net.QueryParsers
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.NOT:
- case Lucene.Net.QueryParsers.QueryParserConstants.PLUS:
- case Lucene.Net.QueryParsers.QueryParserConstants.MINUS:
+ case Lucene.Net.QueryParsers.QueryParserConstants.NotToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.PlusToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.MinusToken:
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.PLUS:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.PLUS);
+ case Lucene.Net.QueryParsers.QueryParserConstants.PlusToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.PlusToken);
ret = MOD_REQ;
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.MINUS:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.MINUS);
+ case Lucene.Net.QueryParsers.QueryParserConstants.MinusToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.MinusToken);
ret = MOD_NOT;
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.NOT:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.NOT);
+ case Lucene.Net.QueryParsers.QueryParserConstants.NotToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.NotToken);
ret = MOD_NOT;
break;
@@ -1484,7 +1381,7 @@ namespace Lucene.Net.QueryParsers
public Query Query(System.String field)
{
- System.Collections.IList clauses = new System.Collections.ArrayList();
+ IList<BooleanClause> clauses = new List<BooleanClause>();
Query q, firstQuery = null;
int conj, mods;
mods = Modifiers();
@@ -1497,20 +1394,20 @@ namespace Lucene.Net.QueryParsers
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.AND:
- case Lucene.Net.QueryParsers.QueryParserConstants.OR:
- case Lucene.Net.QueryParsers.QueryParserConstants.NOT:
- case Lucene.Net.QueryParsers.QueryParserConstants.PLUS:
- case Lucene.Net.QueryParsers.QueryParserConstants.MINUS:
- case Lucene.Net.QueryParsers.QueryParserConstants.LPAREN:
- case Lucene.Net.QueryParsers.QueryParserConstants.STAR:
- case Lucene.Net.QueryParsers.QueryParserConstants.QUOTED:
- case Lucene.Net.QueryParsers.QueryParserConstants.TERM:
- case Lucene.Net.QueryParsers.QueryParserConstants.PREFIXTERM:
- case Lucene.Net.QueryParsers.QueryParserConstants.WILDTERM:
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_START:
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_START:
- case Lucene.Net.QueryParsers.QueryParserConstants.NUMBER:
+ case Lucene.Net.QueryParsers.QueryParserConstants.AndToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.OrToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.NotToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.PlusToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.MinusToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.LParanToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.StarToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.QuotedToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.TermToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.PrefixTermToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.WildTermToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeInStartToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeExStartToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.NumberToken:
;
break;
@@ -1551,15 +1448,15 @@ label_1_brk: ; // {{Aroush-2.9}} this l
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.TERM:
- fieldToken = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.TERM);
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.COLON);
+ case Lucene.Net.QueryParsers.QueryParserConstants.TermToken:
+ fieldToken = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.TermToken);
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.ColonToken);
field = DiscardEscapeChar(fieldToken.image);
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.STAR:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.STAR);
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.COLON);
+ case Lucene.Net.QueryParsers.QueryParserConstants.StarToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.StarToken);
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.ColonToken);
field = "*";
break;
@@ -1577,27 +1474,27 @@ label_1_brk: ; // {{Aroush-2.9}} this l
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.STAR:
- case Lucene.Net.QueryParsers.QueryParserConstants.QUOTED:
- case Lucene.Net.QueryParsers.QueryParserConstants.TERM:
- case Lucene.Net.QueryParsers.QueryParserConstants.PREFIXTERM:
- case Lucene.Net.QueryParsers.QueryParserConstants.WILDTERM:
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_START:
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_START:
- case Lucene.Net.QueryParsers.QueryParserConstants.NUMBER:
+ case Lucene.Net.QueryParsers.QueryParserConstants.StarToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.QuotedToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.TermToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.PrefixTermToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.WildTermToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeInStartToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeExStartToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.NumberToken:
q = Term(field);
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.LPAREN:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.LPAREN);
+ case Lucene.Net.QueryParsers.QueryParserConstants.LParanToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.LParanToken);
q = Query(field);
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RPAREN);
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RParenToken);
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.CARAT:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.CARAT);
- boost = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.NUMBER);
+ case Lucene.Net.QueryParsers.QueryParserConstants.CaratToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.CaratToken);
+ boost = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.NumberToken);
break;
default:
@@ -1619,7 +1516,7 @@ label_1_brk: ; // {{Aroush-2.9}} this l
float f = (float) 1.0;
try
{
- f = (float) SupportClass.Single.Parse(boost.image);
+ f = (float) Single.Parse(boost.image);
q.SetBoost(f);
}
catch (System.Exception ignored)
@@ -1643,35 +1540,35 @@ label_1_brk: ; // {{Aroush-2.9}} this l
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.STAR:
- case Lucene.Net.QueryParsers.QueryParserConstants.TERM:
- case Lucene.Net.QueryParsers.QueryParserConstants.PREFIXTERM:
- case Lucene.Net.QueryParsers.QueryParserConstants.WILDTERM:
- case Lucene.Net.QueryParsers.QueryParserConstants.NUMBER:
+ case Lucene.Net.QueryParsers.QueryParserConstants.StarToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.TermToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.PrefixTermToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.WildTermToken:
+ case Lucene.Net.QueryParsers.QueryParserConstants.NumberToken:
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.TERM:
- term = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.TERM);
+ case Lucene.Net.QueryParsers.QueryParserConstants.TermToken:
+ term = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.TermToken);
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.STAR:
- term = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.STAR);
+ case Lucene.Net.QueryParsers.QueryParserConstants.StarToken:
+ term = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.StarToken);
wildcard = true;
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.PREFIXTERM:
- term = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.PREFIXTERM);
+ case Lucene.Net.QueryParsers.QueryParserConstants.PrefixTermToken:
+ term = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.PrefixTermToken);
prefix = true;
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.WILDTERM:
- term = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.WILDTERM);
+ case Lucene.Net.QueryParsers.QueryParserConstants.WildTermToken:
+ term = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.WildTermToken);
wildcard = true;
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.NUMBER:
- term = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.NUMBER);
+ case Lucene.Net.QueryParsers.QueryParserConstants.NumberToken:
+ term = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.NumberToken);
break;
default:
@@ -1683,8 +1580,8 @@ label_1_brk: ; // {{Aroush-2.9}} this l
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.FUZZY_SLOP:
- fuzzySlop = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.FUZZY_SLOP);
+ case Lucene.Net.QueryParsers.QueryParserConstants.FuzzySlopToken:
+ fuzzySlop = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.FuzzySlopToken);
fuzzy = true;
break;
@@ -1697,14 +1594,14 @@ label_1_brk: ; // {{Aroush-2.9}} this l
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.CARAT:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.CARAT);
- boost = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.NUMBER);
+ case Lucene.Net.QueryParsers.QueryParserConstants.CaratToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.CaratToken);
+ boost = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.NumberToken);
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.FUZZY_SLOP:
- fuzzySlop = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.FUZZY_SLOP);
+ case Lucene.Net.QueryParsers.QueryParserConstants.FuzzySlopToken:
+ fuzzySlop = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.FuzzySlopToken);
fuzzy = true;
break;
@@ -1736,7 +1633,7 @@ label_1_brk: ; // {{Aroush-2.9}} this l
float fms = fuzzyMinSim;
try
{
- fms = (float) SupportClass.Single.Parse(fuzzySlop.image.Substring(1));
+ fms = (float) Single.Parse(fuzzySlop.image.Substring(1));
}
catch (System.Exception ignored)
{
@@ -1756,17 +1653,17 @@ label_1_brk: ; // {{Aroush-2.9}} this l
}
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_START:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_START);
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeInStartToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RangeInStartToken);
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_GOOP:
- goop1 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_GOOP);
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeInGoopToken:
+ goop1 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RangeInGoopToken);
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_QUOTED:
- goop1 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_QUOTED);
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeInQuotedToken:
+ goop1 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RangeInQuotedToken);
break;
default:
@@ -1778,8 +1675,8 @@ label_1_brk: ; // {{Aroush-2.9}} this l
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_TO:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_TO);
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeInToToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RangeInToToken);
break;
default:
@@ -1791,12 +1688,12 @@ label_1_brk: ; // {{Aroush-2.9}} this l
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_GOOP:
- goop2 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_GOOP);
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeInGoopToken:
+ goop2 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RangeInGoopToken);
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_QUOTED:
- goop2 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_QUOTED);
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeInQuotedToken:
+ goop2 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RangeInQuotedToken);
break;
default:
@@ -1805,13 +1702,13 @@ label_1_brk: ; // {{Aroush-2.9}} this l
throw new ParseException();
}
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_END);
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RangeInEndToken);
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.CARAT:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.CARAT);
- boost = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.NUMBER);
+ case Lucene.Net.QueryParsers.QueryParserConstants.CaratToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.CaratToken);
+ boost = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.NumberToken);
break;
default:
@@ -1820,28 +1717,28 @@ label_1_brk: ; // {{Aroush-2.9}} this l
break;
}
- if (goop1.kind == Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_QUOTED)
+ if (goop1.kind == Lucene.Net.QueryParsers.QueryParserConstants.RangeInQuotedToken)
{
goop1.image = goop1.image.Substring(1, (goop1.image.Length - 1) - (1));
}
- if (goop2.kind == Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_QUOTED)
+ if (goop2.kind == Lucene.Net.QueryParsers.QueryParserConstants.RangeInQuotedToken)
{
goop2.image = goop2.image.Substring(1, (goop2.image.Length - 1) - (1));
}
q = GetRangeQuery(field, DiscardEscapeChar(goop1.image), DiscardEscapeChar(goop2.image), true);
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_START:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_START);
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeExStartToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RangeExStartToken);
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_GOOP:
- goop1 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_GOOP);
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeExGoopToken:
+ goop1 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RangeExGoopToken);
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_QUOTED:
- goop1 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_QUOTED);
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeExQuotedToken:
+ goop1 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RangeExQuotedToken);
break;
default:
@@ -1853,8 +1750,8 @@ label_1_brk: ; // {{Aroush-2.9}} this l
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_TO:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_TO);
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeExToToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RangeExToToken);
break;
default:
@@ -1866,12 +1763,12 @@ label_1_brk: ; // {{Aroush-2.9}} this l
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_GOOP:
- goop2 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_GOOP);
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeExGoopToken:
+ goop2 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RangeExGoopToken);
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_QUOTED:
- goop2 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_QUOTED);
+ case Lucene.Net.QueryParsers.QueryParserConstants.RangeExQuotedToken:
+ goop2 = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RangeExQuotedToken);
break;
default:
@@ -1880,13 +1777,13 @@ label_1_brk: ; // {{Aroush-2.9}} this l
throw new ParseException();
}
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_END);
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.RangeExEndToken);
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.CARAT:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.CARAT);
- boost = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.NUMBER);
+ case Lucene.Net.QueryParsers.QueryParserConstants.CaratToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.CaratToken);
+ boost = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.NumberToken);
break;
default:
@@ -1895,11 +1792,11 @@ label_1_brk: ; // {{Aroush-2.9}} this l
break;
}
- if (goop1.kind == Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_QUOTED)
+ if (goop1.kind == Lucene.Net.QueryParsers.QueryParserConstants.RangeExQuotedToken)
{
goop1.image = goop1.image.Substring(1, (goop1.image.Length - 1) - (1));
}
- if (goop2.kind == Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_QUOTED)
+ if (goop2.kind == Lucene.Net.QueryParsers.QueryParserConstants.RangeExQuotedToken)
{
goop2.image = goop2.image.Substring(1, (goop2.image.Length - 1) - (1));
}
@@ -1907,13 +1804,13 @@ label_1_brk: ; // {{Aroush-2.9}} this l
q = GetRangeQuery(field, DiscardEscapeChar(goop1.image), DiscardEscapeChar(goop2.image), false);
break;
- case Lucene.Net.QueryParsers.QueryParserConstants.QUOTED:
- term = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.QUOTED);
+ case Lucene.Net.QueryParsers.QueryParserConstants.QuotedToken:
+ term = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.QuotedToken);
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.FUZZY_SLOP:
- fuzzySlop = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.FUZZY_SLOP);
+ case Lucene.Net.QueryParsers.QueryParserConstants.FuzzySlopToken:
+ fuzzySlop = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.FuzzySlopToken);
break;
default:
@@ -1925,9 +1822,9 @@ label_1_brk: ; // {{Aroush-2.9}} this l
switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
{
- case Lucene.Net.QueryParsers.QueryParserConstants.CARAT:
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.CARAT);
- boost = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.NUMBER);
+ case Lucene.Net.QueryParsers.QueryParserConstants.CaratToken:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.CaratToken);
+ boost = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.NumberToken);
break;
default:
@@ -1942,7 +1839,7 @@ label_1_brk: ; // {{Aroush-2.9}} this l
{
try
{
- s = (int) SupportClass.Single.Parse(fuzzySlop.image.Substring(1));
+ s = (int) Single.Parse(fuzzySlop.image.Substring(1));
}
catch (System.Exception ignored)
{
@@ -1962,7 +1859,7 @@ label_1_brk: ; // {{Aroush-2.9}} this l
float f = (float) 1.0;
try
{
- f = (float) SupportClass.Single.Parse(boost.image);
+ f = (float) Single.Parse(boost.image);
}
catch (System.Exception ignored)
{
@@ -2003,9 +1900,9 @@ label_1_brk: ; // {{Aroush-2.9}} this l
private bool Jj_3R_2()
{
- if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.TERM))
+ if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.TermToken))
return true;
- if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.COLON))
+ if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.ColonToken))
return true;
return false;
}
@@ -2025,9 +1922,9 @@ label_1_brk: ; // {{Aroush-2.9}} this l
private bool Jj_3R_3()
{
- if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.STAR))
+ if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.StarToken))
return true;
- if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.COLON))
+ if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.ColonToken))
return true;
return false;
}
@@ -2218,7 +2115,7 @@ label_1_brk: ; // {{Aroush-2.9}} this l
return (jj_ntk = jj_nt.kind);
}
- private System.Collections.IList jj_expentries = new System.Collections.ArrayList();
+ private IList<int[]> jj_expentries = new List<int[]>();
private int[] jj_expentry;
private int jj_kind = - 1;
private int[] jj_lasttokens = new int[100];
@@ -2286,7 +2183,7 @@ label_1_brk: ; // {{Aroush-2.9}} this l
int[][] exptokseq = new int[jj_expentries.Count][];
for (int i = 0; i < jj_expentries.Count; i++)
{
- exptokseq[i] = (int[]) jj_expentries[i];
+ exptokseq[i] = jj_expentries[i];
}
return new ParseException(token, exptokseq, Lucene.Net.QueryParsers.QueryParserConstants.tokenImage);
}
Modified: incubator/lucene.net/trunk/src/core/QueryParser/QueryParserConstants.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/QueryParser/QueryParserConstants.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/QueryParser/QueryParserConstants.cs (original)
+++ incubator/lucene.net/trunk/src/core/QueryParser/QueryParserConstants.cs Tue Feb 28 22:43:08 2012
@@ -29,81 +29,81 @@ namespace Lucene.Net.QueryParsers
public class QueryParserConstants
{
/// <summary>End of File. </summary>
- public const int EOF = 0;
+ protected internal const int EndOfFileToken = 0;
/// <summary>RegularExpression Id. </summary>
- public const int _NUM_CHAR = 1;
+ protected internal const int NumCharToken = 1;
/// <summary>RegularExpression Id. </summary>
- public const int _ESCAPED_CHAR = 2;
+ protected internal const int EscapedCharToken = 2;
/// <summary>RegularExpression Id. </summary>
- public const int _TERM_START_CHAR = 3;
+ protected internal const int TermStartCharToken = 3;
/// <summary>RegularExpression Id. </summary>
- public const int _TERM_CHAR = 4;
+ protected internal const int TermCharToken = 4;
/// <summary>RegularExpression Id. </summary>
- public const int _WHITESPACE = 5;
+ protected internal const int WhitespaceToken = 5;
/// <summary>RegularExpression Id. </summary>
- public const int _QUOTED_CHAR = 6;
+ protected internal const int QuotedCharToken = 6;
/// <summary>RegularExpression Id. </summary>
- public const int AND = 8;
+ protected internal const int AndToken = 8;
/// <summary>RegularExpression Id. </summary>
- public const int OR = 9;
+ protected internal const int OrToken = 9;
/// <summary>RegularExpression Id. </summary>
- public const int NOT = 10;
+ protected internal const int NotToken = 10;
/// <summary>RegularExpression Id. </summary>
- public const int PLUS = 11;
+ protected internal const int PlusToken = 11;
/// <summary>RegularExpression Id. </summary>
- public const int MINUS = 12;
+ protected internal const int MinusToken = 12;
/// <summary>RegularExpression Id. </summary>
- public const int LPAREN = 13;
+ protected internal const int LParanToken = 13;
/// <summary>RegularExpression Id. </summary>
- public const int RPAREN = 14;
+ protected internal const int RParenToken = 14;
/// <summary>RegularExpression Id. </summary>
- public const int COLON = 15;
+ protected internal const int ColonToken = 15;
/// <summary>RegularExpression Id. </summary>
- public const int STAR = 16;
+ protected internal const int StarToken = 16;
/// <summary>RegularExpression Id. </summary>
- public const int CARAT = 17;
+ protected internal const int CaratToken = 17;
/// <summary>RegularExpression Id. </summary>
- public const int QUOTED = 18;
+ protected internal const int QuotedToken = 18;
/// <summary>RegularExpression Id. </summary>
- public const int TERM = 19;
+ protected internal const int TermToken = 19;
/// <summary>RegularExpression Id. </summary>
- public const int FUZZY_SLOP = 20;
+ protected internal const int FuzzySlopToken = 20;
/// <summary>RegularExpression Id. </summary>
- public const int PREFIXTERM = 21;
+ protected internal const int PrefixTermToken = 21;
/// <summary>RegularExpression Id. </summary>
- public const int WILDTERM = 22;
+ protected internal const int WildTermToken = 22;
/// <summary>RegularExpression Id. </summary>
- public const int RANGEIN_START = 23;
+ protected internal const int RangeInStartToken = 23;
/// <summary>RegularExpression Id. </summary>
- public const int RANGEEX_START = 24;
+ protected internal const int RangeExStartToken = 24;
/// <summary>RegularExpression Id. </summary>
- public const int NUMBER = 25;
+ protected internal const int NumberToken = 25;
/// <summary>RegularExpression Id. </summary>
- public const int RANGEIN_TO = 26;
+ protected internal const int RangeInToToken = 26;
/// <summary>RegularExpression Id. </summary>
- public const int RANGEIN_END = 27;
+ protected internal const int RangeInEndToken = 27;
/// <summary>RegularExpression Id. </summary>
- public const int RANGEIN_QUOTED = 28;
+ protected internal const int RangeInQuotedToken = 28;
/// <summary>RegularExpression Id. </summary>
- public const int RANGEIN_GOOP = 29;
+ protected internal const int RangeInGoopToken = 29;
/// <summary>RegularExpression Id. </summary>
- public const int RANGEEX_TO = 30;
+ protected internal const int RangeExToToken = 30;
/// <summary>RegularExpression Id. </summary>
- public const int RANGEEX_END = 31;
+ protected internal const int RangeExEndToken = 31;
/// <summary>RegularExpression Id. </summary>
- public const int RANGEEX_QUOTED = 32;
+ protected internal const int RangeExQuotedToken = 32;
/// <summary>RegularExpression Id. </summary>
- public const int RANGEEX_GOOP = 33;
+ protected internal const int RangeExGoopToken = 33;
/// <summary>Lexical state. </summary>
- public const int Boost = 0;
+ protected internal const int BoostToken = 0;
/// <summary>Lexical state. </summary>
- public const int RangeEx = 1;
+ protected const int RangeExToken = 1;
/// <summary>Lexical state. </summary>
- public const int RangeIn = 2;
+ protected internal const int RangeInToken = 2;
/// <summary>Lexical state. </summary>
- public const int DEFAULT = 3;
+ protected internal const int DefaultToken = 3;
/// <summary>Literal token values. </summary>
- public static System.String[] tokenImage = new System.String[] {
+ protected internal static System.String[] tokenImage = new System.String[] {
"<EOF>",
"<_NUM_CHAR>",
"<_ESCAPED_CHAR>",
Modified: incubator/lucene.net/trunk/src/core/QueryParser/QueryParserTokenManager.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/QueryParser/QueryParserTokenManager.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/QueryParser/QueryParserTokenManager.cs (original)
+++ incubator/lucene.net/trunk/src/core/QueryParser/QueryParserTokenManager.cs Tue Feb 28 22:43:08 2012
@@ -17,31 +17,6 @@
/* Generated By:JavaCC: Do not edit this line. QueryParserTokenManager.java */
-using System;
-
-using Analyzer = Lucene.Net.Analysis.Analyzer;
-using CachingTokenFilter = Lucene.Net.Analysis.CachingTokenFilter;
-using TokenStream = Lucene.Net.Analysis.TokenStream;
-using PositionIncrementAttribute = Lucene.Net.Analysis.Tokenattributes.PositionIncrementAttribute;
-using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
-using DateField = Lucene.Net.Documents.DateField;
-using DateTools = Lucene.Net.Documents.DateTools;
-using Term = Lucene.Net.Index.Term;
-using Parameter = Lucene.Net.Util.Parameter;
-using BooleanClause = Lucene.Net.Search.BooleanClause;
-using BooleanQuery = Lucene.Net.Search.BooleanQuery;
-using FuzzyQuery = Lucene.Net.Search.FuzzyQuery;
-using MatchAllDocsQuery = Lucene.Net.Search.MatchAllDocsQuery;
-using MultiPhraseQuery = Lucene.Net.Search.MultiPhraseQuery;
-using MultiTermQuery = Lucene.Net.Search.MultiTermQuery;
-using PhraseQuery = Lucene.Net.Search.PhraseQuery;
-using PrefixQuery = Lucene.Net.Search.PrefixQuery;
-using Query = Lucene.Net.Search.Query;
-using TermQuery = Lucene.Net.Search.TermQuery;
-using TermRangeQuery = Lucene.Net.Search.TermRangeQuery;
-using WildcardQuery = Lucene.Net.Search.WildcardQuery;
-using Version = Lucene.Net.Util.Version;
-
namespace Lucene.Net.QueryParsers
{
Modified: incubator/lucene.net/trunk/src/core/QueryParser/Token.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/QueryParser/Token.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/QueryParser/Token.cs (original)
+++ incubator/lucene.net/trunk/src/core/QueryParser/Token.cs Tue Feb 28 22:43:08 2012
@@ -129,5 +129,5 @@ namespace Lucene.Net.QueryParsers
return NewToken(ofKind, null);
}
}
- /* JavaCC - OriginalChecksum=37b1923f964a5a434f5ea3d6952ff200 (do not edit this line) */
+ /* JavaCC - OriginalChecksum=c147cc166a7cf8812c7c39bc8c5eb868 (do not edit this line) */
}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/src/core/QueryParser/TokenMgrError.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/QueryParser/TokenMgrError.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/QueryParser/TokenMgrError.cs (original)
+++ incubator/lucene.net/trunk/src/core/QueryParser/TokenMgrError.cs Tue Feb 28 22:43:08 2012
@@ -165,5 +165,5 @@ namespace Lucene.Net.QueryParsers
{
}
}
- /* JavaCC - OriginalChecksum=55cddb2336a66b376c0bb59d916b326d (do not edit this line) */
+ /* JavaCC - OriginalChecksum=1c94e13236c7e0121e49427992341ee3 (do not edit this line) */
}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/src/core/Search/BooleanClause.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/BooleanClause.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/BooleanClause.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/BooleanClause.cs Tue Feb 28 22:43:08 2012
@@ -62,19 +62,16 @@ namespace Lucene.Net.Search
public static readonly Occur MUST_NOT = new Occur("MUST_NOT");
}
- /// <summary>The query whose matching documents are combined by the boolean query.</summary>
- private Query query;
-
private Occur occur;
/// <summary>Constructs a BooleanClause.</summary>
public BooleanClause(Query query, Occur occur)
{
- this.query = query;
+ this._query = query;
this.occur = occur;
}
-
+
public virtual Occur GetOccur()
{
return occur;
@@ -84,25 +81,48 @@ namespace Lucene.Net.Search
{
this.occur = occur;
}
-
+
+ private Query _query;
+
+ /// <summary>The query whose matching documents are combined by the boolean query.</summary>
+ public virtual Query Query
+ {
+ get { return _query; }
+ set { _query = value; }
+ }
+
+ [Obsolete("Use Query property instead")]
public virtual Query GetQuery()
{
- return query;
+ return Query;
}
-
- public virtual void SetQuery(Query query)
+
+ [Obsolete("Use Query property instead")]
+ public virtual void SetQuery(Query query)
{
- this.query = query;
+ this.Query = query;
}
+ public virtual bool Prohibited
+ {
+ get { return Occur.MUST_NOT.Equals(occur); }
+ }
+
+ [Obsolete("Use Prohibited property instead")]
public virtual bool IsProhibited()
{
- return Occur.MUST_NOT.Equals(occur);
+ return Prohibited;
}
+ public virtual bool Required
+ {
+ get { return Occur.MUST.Equals(occur); }
+ }
+
+ [Obsolete("Use Required property instead")]
public virtual bool IsRequired()
{
- return Occur.MUST.Equals(occur);
+ return Required;
}
@@ -113,19 +133,19 @@ namespace Lucene.Net.Search
if (o == null || !(o is BooleanClause))
return false;
BooleanClause other = (BooleanClause) o;
- return this.query.Equals(other.query) && this.occur.Equals(other.occur);
+ return this.Query.Equals(other.Query) && this.occur.Equals(other.occur);
}
/// <summary>Returns a hash code value for this object.</summary>
public override int GetHashCode()
{
- return query.GetHashCode() ^ (Occur.MUST.Equals(occur)?1:0) ^ (Occur.MUST_NOT.Equals(occur)?2:0);
+ return Query.GetHashCode() ^ (Occur.MUST.Equals(occur)?1:0) ^ (Occur.MUST_NOT.Equals(occur)?2:0);
}
public override System.String ToString()
{
- return occur.ToString() + query.ToString();
+ return occur.ToString() + Query.ToString();
}
}
}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/src/core/Search/BooleanQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/BooleanQuery.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/BooleanQuery.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/BooleanQuery.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,9 @@
*/
using System;
-
+using System.Collections;
+using Lucene.Net.Index;
+using Lucene.Net.Support;
using IndexReader = Lucene.Net.Index.IndexReader;
using ToStringUtils = Lucene.Net.Util.ToStringUtils;
using Occur = Lucene.Net.Search.BooleanClause.Occur;
@@ -29,7 +31,7 @@ namespace Lucene.Net.Search
/// BooleanQuerys.
/// </summary>
[Serializable]
- public class BooleanQuery:Query, System.ICloneable
+ public class BooleanQuery : Query, System.Collections.Generic.IEnumerable<BooleanClause>, System.ICloneable
{
[Serializable]
private class AnonymousClassSimilarityDelegator:SimilarityDelegator
@@ -57,7 +59,7 @@ namespace Lucene.Net.Search
}
}
- private static int maxClauseCount = 1024;
+ private static int _maxClauses = 1024;
/// <summary>Thrown when an attempt is made to add more than <see cref="GetMaxClauseCount()" />
/// clauses. This typically happens if
@@ -71,37 +73,53 @@ namespace Lucene.Net.Search
{
get
{
- return "maxClauseCount is set to " + Lucene.Net.Search.BooleanQuery.maxClauseCount;
+ return "maxClauseCount is set to " + Lucene.Net.Search.BooleanQuery._maxClauses;
}
}
- public TooManyClauses()
- {
- }
}
-
+ /// <summary>Gets or sets the maximum number of clauses permitted, 1024 by default.
+ /// <para>
+ /// Attempts to add more than the permitted number of clauses cause <see cref="TooManyClauses" />
+ /// to be thrown.
+ /// </para>
+ /// </summary>
+ public static int MaxClauses
+ {
+ get
+ {
+ return _maxClauses;
+ }
+
+ set
+ {
+ if (value < 1)
+ throw new ArgumentException("maxClauseCount must be >= 1");
+ _maxClauses = value;
+ }
+ }
+
/// <summary>Return the maximum number of clauses permitted, 1024 by default.
/// Attempts to add more than the permitted number of clauses cause <see cref="TooManyClauses" />
/// to be thrown.
/// </summary>
- /// <seealso cref="SetMaxClauseCount(int)">
- /// </seealso>
+ /// <seealso cref="SetMaxClauseCount(int)" />
+ [Obsolete("Use MaxClauseCount property")]
public static int GetMaxClauseCount()
{
- return maxClauseCount;
+ return MaxClauses;
}
/// <summary> Set the maximum number of clauses permitted per BooleanQuery.
/// Default value is 1024.
- /// </summary>
+ /// </summary>
+ [Obsolete("Use MaxClauseCount property")]
public static void SetMaxClauseCount(int maxClauseCount)
{
- if (maxClauseCount < 1)
- throw new System.ArgumentException("maxClauseCount must be >= 1");
- BooleanQuery.maxClauseCount = maxClauseCount;
+ MaxClauses = maxClauseCount;
}
- private SupportClass.EquatableList<BooleanClause> clauses = new SupportClass.EquatableList<BooleanClause>();
+ private EquatableList<BooleanClause> clauses = new EquatableList<BooleanClause>();
private bool disableCoord;
/// <summary>Constructs an empty boolean query. </summary>
@@ -146,45 +164,59 @@ namespace Lucene.Net.Search
}
return result;
}
-
- /// <summary> Specifies a minimum number of the optional BooleanClauses
- /// which must be satisfied.
- ///
- /// <p/>
- /// By default no optional clauses are necessary for a match
- /// (unless there are no required clauses). If this method is used,
- /// then the specified number of clauses is required.
- /// <p/>
- /// <p/>
- /// Use of this method is totally independent of specifying that
- /// any specific clauses are required (or prohibited). This number will
- /// only be compared against the number of matching optional clauses.
- /// <p/>
- /// <p/>
- /// EXPERT NOTE: Using this method may force collecting docs in order,
- /// regardless of whether setAllowDocsOutOfOrder(true) has been called.
- /// <p/>
- ///
- /// </summary>
- /// <param name="min">the number of optional clauses that must match
- /// </param>
- /// <seealso cref="SetAllowDocsOutOfOrder">
- /// </seealso>
- public virtual void SetMinimumNumberShouldMatch(int min)
- {
- this.minNrShouldMatch = min;
- }
- protected internal int minNrShouldMatch = 0;
-
- /// <summary> Gets the minimum number of the optional BooleanClauses
- /// which must be satisifed.
- /// </summary>
- public virtual int GetMinimumNumberShouldMatch()
- {
- return minNrShouldMatch;
- }
-
- /// <summary>Adds a clause to a boolean query.
+
+ protected internal int minNrShouldMatch = 0;
+
+ /// <summary> Specifies a minimum number of the optional BooleanClauses
+ /// which must be satisfied.
+ /// <para>
+ /// By default no optional clauses are necessary for a match
+ /// (unless there are no required clauses). If this method is used,
+ /// then the specified number of clauses is required.
+ /// </para>
+ /// <para>
+ /// Use of this method is totally independent of specifying that
+ /// any specific clauses are required (or prohibited). This number will
+ /// only be compared against the number of matching optional clauses.
+ /// </para>
+ /// </summary>
+ /// <value>the number of optional clauses that must match</value>
+ public virtual int MinimumNumberShouldMatch
+ {
+ set { this.minNrShouldMatch = value; }
+ get { return minNrShouldMatch; }
+ }
+
+ /// <summary> Specifies a minimum number of the optional BooleanClauses
+ /// which must be satisfied.
+ /// <para>
+ /// By default no optional clauses are necessary for a match
+ /// (unless there are no required clauses). If this method is used,
+ /// then the specified number of clauses is required.
+ /// </para>
+ /// <para>
+ /// Use of this method is totally independent of specifying that
+ /// any specific clauses are required (or prohibited). This number will
+ /// only be compared against the number of matching optional clauses.
+ /// </para>
+ /// </summary>
+ /// <param name="min">the number of optional clauses that must match</param>
+ [Obsolete("Use MinimumNumberShouldMatch property instead")]
+ public virtual void SetMinimumNumberShouldMatch(int min)
+ {
+ MinimumNumberShouldMatch = min;
+ }
+
+ /// <summary> Gets the minimum number of the optional BooleanClauses
+ /// which must be satisifed.
+ /// </summary>
+ [Obsolete("Use MinimumNumberShouldMatch property instead")]
+ public virtual int GetMinimumNumberShouldMatch()
+ {
+ return MinimumNumberShouldMatch;
+ }
+
+ /// <summary>Adds a clause to a boolean query.
///
/// </summary>
/// <throws> TooManyClauses if the new number of clauses exceeds the maximum clause number </throws>
@@ -201,24 +233,47 @@ namespace Lucene.Net.Search
/// </seealso>
public virtual void Add(BooleanClause clause)
{
- if (clauses.Count >= maxClauseCount)
+ if (clauses.Count >= _maxClauses)
throw new TooManyClauses();
clauses.Add(clause);
}
-
+
/// <summary>Returns the set of clauses in this query. </summary>
public virtual BooleanClause[] GetClauses()
{
- return (BooleanClause[]) clauses.ToArray();
+ return clauses.ToArray();
}
-
+
+ // TODO: Uncomment and mark GetClauses() obsolete when Clauses() method
+ // is removed
+ ///// <summary>Returns the set of clauses in this query. </summary>
+ //public virtual BooleanClause[] Clauses
+ //{
+ // get { return clauses.ToArray(); }
+ //}
+
+ /// <summary>Returns the list of clauses in this query. </summary>
+ public virtual System.Collections.Generic.List<BooleanClause> ClauseList
+ {
+ get { return clauses; }
+ }
+
/// <summary>Returns the list of clauses in this query. </summary>
- public virtual System.Collections.IList Clauses()
+ [Obsolete("Use ClauseList property instead")]
+ public virtual System.Collections.Generic.List<BooleanClause> Clauses()
{
return clauses;
}
+ /// <summary>
+ /// Returns an iterator on the clauses in this query.
+ /// </summary>
+ /// <returns></returns>
+ public System.Collections.Generic.IEnumerator<BooleanClause> GetEnumerator()
+ {
+ return clauses.GetEnumerator();
+ }
/// <summary> Expert: the Weight for BooleanQuery, used to
/// normalize, score and explain these queries.
///
@@ -243,17 +298,16 @@ namespace Lucene.Net.Search
}
/// <summary>The Similarity implementation. </summary>
protected internal Similarity similarity;
- protected internal System.Collections.ArrayList weights;
+ protected internal System.Collections.Generic.List<Weight> weights;
public BooleanWeight(BooleanQuery enclosingInstance, Searcher searcher)
{
InitBlock(enclosingInstance);
this.similarity = Enclosing_Instance.GetSimilarity(searcher);
- weights = new System.Collections.ArrayList(Enclosing_Instance.clauses.Count);
+ weights = new System.Collections.Generic.List<Weight>(Enclosing_Instance.clauses.Count);
for (int i = 0; i < Enclosing_Instance.clauses.Count; i++)
{
- BooleanClause c = (BooleanClause) Enclosing_Instance.clauses[i];
- weights.Add(c.GetQuery().CreateWeight(searcher));
+ weights.Add(Enclosing_Instance.clauses[i].Query.CreateWeight(searcher));
}
}
@@ -271,11 +325,9 @@ namespace Lucene.Net.Search
float sum = 0.0f;
for (int i = 0; i < weights.Count; i++)
{
- BooleanClause c = (BooleanClause) Enclosing_Instance.clauses[i];
- Weight w = (Weight) weights[i];
// call sumOfSquaredWeights for all clauses in case of side effects
- float s = w.SumOfSquaredWeights(); // sum sub weights
- if (!c.IsProhibited())
+ float s = weights[i].SumOfSquaredWeights(); // sum sub weights
+ if (!Enclosing_Instance.clauses[i].Prohibited)
// only add to sum for non-prohibited clauses
sum += s;
}
@@ -289,9 +341,8 @@ namespace Lucene.Net.Search
public override void Normalize(float norm)
{
norm *= Enclosing_Instance.GetBoost(); // incorporate boost
- for (System.Collections.IEnumerator iter = weights.GetEnumerator(); iter.MoveNext(); )
+ foreach (Weight w in weights)
{
- Weight w = (Weight) iter.Current;
// normalize all clauses, (even if prohibited in case of side affects)
w.Normalize(norm);
}
@@ -299,38 +350,38 @@ namespace Lucene.Net.Search
public override Explanation Explain(IndexReader reader, int doc)
{
- int minShouldMatch = Enclosing_Instance.GetMinimumNumberShouldMatch();
+ int minShouldMatch = Enclosing_Instance.MinimumNumberShouldMatch;
ComplexExplanation sumExpl = new ComplexExplanation();
- sumExpl.SetDescription("sum of:");
+ sumExpl.Description = "sum of:";
int coord = 0;
int maxCoord = 0;
float sum = 0.0f;
bool fail = false;
int shouldMatchCount = 0;
- for (System.Collections.IEnumerator wIter = weights.GetEnumerator(), cIter = Enclosing_Instance.clauses.GetEnumerator(); wIter.MoveNext(); )
+ System.Collections.Generic.IEnumerator<BooleanClause> cIter = Enclosing_Instance.clauses.GetEnumerator();
+ for (System.Collections.Generic.IEnumerator<Weight> wIter = weights.GetEnumerator(); wIter.MoveNext(); )
{
cIter.MoveNext();
-
- Weight w = (Weight)wIter.Current;
- BooleanClause c = (BooleanClause) cIter.Current;
+ Weight w = wIter.Current;
+ BooleanClause c = cIter.Current;
if (w.Scorer(reader, true, true) == null)
{
continue;
}
Explanation e = w.Explain(reader, doc);
- if (!c.IsProhibited())
+ if (!c.Prohibited)
maxCoord++;
if (e.IsMatch())
{
- if (!c.IsProhibited())
+ if (!c.Prohibited)
{
sumExpl.AddDetail(e);
- sum += e.GetValue();
+ sum += e.Value;
coord++;
}
else
{
- Explanation r = new Explanation(0.0f, "match on prohibited clause (" + c.GetQuery().ToString() + ")");
+ Explanation r = new Explanation(0.0f, "match on prohibited clause (" + c.Query.ToString() + ")");
r.AddDetail(e);
sumExpl.AddDetail(r);
fail = true;
@@ -338,9 +389,9 @@ namespace Lucene.Net.Search
if (c.GetOccur() == Occur.SHOULD)
shouldMatchCount++;
}
- else if (c.IsRequired())
+ else if (c.Required)
{
- Explanation r = new Explanation(0.0f, "no match on required clause (" + c.GetQuery().ToString() + ")");
+ Explanation r = new Explanation(0.0f, "no match on required clause (" + c.Query.ToString() + ")");
r.AddDetail(e);
sumExpl.AddDetail(r);
fail = true;
@@ -349,22 +400,22 @@ namespace Lucene.Net.Search
if (fail)
{
System.Boolean tempAux = false;
- sumExpl.SetMatch(tempAux);
- sumExpl.SetValue(0.0f);
- sumExpl.SetDescription("Failure to meet condition(s) of required/prohibited clause(s)");
+ sumExpl.Match = tempAux;
+ sumExpl.Value = 0.0f;
+ sumExpl.Description = "Failure to meet condition(s) of required/prohibited clause(s)";
return sumExpl;
}
else if (shouldMatchCount < minShouldMatch)
{
System.Boolean tempAux2 = false;
- sumExpl.SetMatch(tempAux2);
- sumExpl.SetValue(0.0f);
- sumExpl.SetDescription("Failure to match minimum number " + "of optional clauses: " + minShouldMatch);
+ sumExpl.Match = tempAux2;
+ sumExpl.Value = 0.0f;
+ sumExpl.Description = "Failure to match minimum number " + "of optional clauses: " + minShouldMatch;
return sumExpl;
}
- sumExpl.SetMatch(0 < coord?true:false);
- sumExpl.SetValue(sum);
+ sumExpl.Match = 0 < coord?true:false;
+ sumExpl.Value = sum;
float coordFactor = similarity.Coord(coord, maxCoord);
if (coordFactor == 1.0f)
@@ -382,28 +433,28 @@ namespace Lucene.Net.Search
public override Scorer Scorer(IndexReader reader, bool scoreDocsInOrder, bool topScorer)
{
- System.Collections.IList required = new System.Collections.ArrayList();
- System.Collections.IList prohibited = new System.Collections.ArrayList();
- System.Collections.IList optional = new System.Collections.ArrayList();
- for (System.Collections.IEnumerator wIter = weights.GetEnumerator(), cIter = Enclosing_Instance.clauses.GetEnumerator(); wIter.MoveNext(); )
+ var required = new System.Collections.Generic.List<Scorer>();
+ var prohibited = new System.Collections.Generic.List<Scorer>();
+ var optional = new System.Collections.Generic.List<Scorer>();
+
+ System.Collections.Generic.IEnumerator<BooleanClause> cIter = Enclosing_Instance.clauses.GetEnumerator();
+ foreach (Weight w in weights)
{
cIter.MoveNext();
-
- Weight w = (Weight) wIter.Current;
BooleanClause c = (BooleanClause) cIter.Current;
Scorer subScorer = w.Scorer(reader, true, false);
if (subScorer == null)
{
- if (c.IsRequired())
+ if (c.Required)
{
return null;
}
}
- else if (c.IsRequired())
+ else if (c.Required)
{
required.Add(subScorer);
}
- else if (c.IsProhibited())
+ else if (c.Prohibited)
{
prohibited.Add(subScorer);
}
@@ -414,7 +465,6 @@ namespace Lucene.Net.Search
}
// Check if we can return a BooleanScorer
- scoreDocsInOrder |= !Lucene.Net.Search.BooleanQuery.allowDocsOutOfOrder; // until it is removed, factor in the static setting.
if (!scoreDocsInOrder && topScorer && required.Count == 0 && prohibited.Count < 32)
{
return new BooleanScorer(similarity, Enclosing_Instance.minNrShouldMatch, optional, prohibited);
@@ -440,14 +490,13 @@ namespace Lucene.Net.Search
public override bool ScoresDocsOutOfOrder()
{
int numProhibited = 0;
- for (System.Collections.IEnumerator cIter = Enclosing_Instance.clauses.GetEnumerator(); cIter.MoveNext(); )
+ foreach (BooleanClause c in Enclosing_Instance.clauses)
{
- BooleanClause c = (BooleanClause) cIter.Current;
- if (c.IsRequired())
+ if (c.Required)
{
return false; // BS2 (in-order) will be used by scorer()
}
- else if (c.IsProhibited())
+ else if (c.Prohibited)
{
++numProhibited;
}
@@ -464,76 +513,6 @@ namespace Lucene.Net.Search
}
}
- /// <summary> Whether hit docs may be collected out of docid order.
- ///
- /// </summary>
- /// <deprecated> this will not be needed anymore, as
- /// <see cref="Weight.ScoresDocsOutOfOrder()" /> is used.
- /// </deprecated>
- [Obsolete("this will not be needed anymore, as Weight.ScoresDocsOutOfOrder() is used.")]
- private static bool allowDocsOutOfOrder = true;
-
- /// <summary> Expert: Indicates whether hit docs may be collected out of docid order.
- ///
- /// <p/>
- /// Background: although the contract of the Scorer class requires that
- /// documents be iterated in order of doc id, this was not true in early
- /// versions of Lucene. Many pieces of functionality in the current Lucene code
- /// base have undefined behavior if this contract is not upheld, but in some
- /// specific simple cases may be faster. (For example: disjunction queries with
- /// less than 32 prohibited clauses; This setting has no effect for other
- /// queries.)
- /// <p/>
- ///
- /// <p/>
- /// Specifics: By setting this option to true, docid N might be scored for a
- /// single segment before docid N-1. Across multiple segments, docs may be
- /// scored out of order regardless of this setting - it only applies to scoring
- /// a single segment.
- ///
- /// Being static, this setting is system wide.
- /// <p/>
- ///
- /// </summary>
- /// <deprecated> this is not needed anymore, as
- /// <see cref="Weight.ScoresDocsOutOfOrder()" /> is used.
- /// </deprecated>
- [Obsolete("this is not needed anymore, as Weight.ScoresDocsOutOfOrder() is used.")]
- public static void SetAllowDocsOutOfOrder(bool allow)
- {
- allowDocsOutOfOrder = allow;
- }
-
- /// <summary> Whether hit docs may be collected out of docid order.
- ///
- /// </summary>
- /// <seealso cref="SetAllowDocsOutOfOrder(bool)">
- /// </seealso>
- /// <deprecated> this is not needed anymore, as
- /// <see cref="Weight.ScoresDocsOutOfOrder()" /> is used.
- /// </deprecated>
- [Obsolete("this is not needed anymore, as Weight.ScoresDocsOutOfOrder() is used.")]
- public static bool GetAllowDocsOutOfOrder()
- {
- return allowDocsOutOfOrder;
- }
-
- /// <deprecated> Use <see cref="SetAllowDocsOutOfOrder(bool)" /> instead.
- /// </deprecated>
- [Obsolete("Use SetAllowDocsOutOfOrder(bool) instead.")]
- public static void SetUseScorer14(bool use14)
- {
- SetAllowDocsOutOfOrder(use14);
- }
-
- /// <deprecated> Use <see cref="GetAllowDocsOutOfOrder()" /> instead.
- /// </deprecated>
- [Obsolete("Use GetAllowDocsOutOfOrder() instead.")]
- public static bool GetUseScorer14()
- {
- return GetAllowDocsOutOfOrder();
- }
-
public override Weight CreateWeight(Searcher searcher)
{
return new BooleanWeight(this, searcher);
@@ -544,17 +523,17 @@ namespace Lucene.Net.Search
if (minNrShouldMatch == 0 && clauses.Count == 1)
{
// optimize 1-clause queries
- BooleanClause c = (BooleanClause) clauses[0];
- if (!c.IsProhibited())
+ BooleanClause c = clauses[0];
+ if (!c.Prohibited)
{
// just return clause
-
- Query query = c.GetQuery().Rewrite(reader); // rewrite first
+
+ Query query = c.Query.Rewrite(reader); // rewrite first
if (GetBoost() != 1.0f)
{
// incorporate boost
- if (query == c.GetQuery())
+ if (query == c.Query)
// if rewrite was no-op
query = (Query) query.Clone(); // then clone before boost
query.SetBoost(GetBoost() * query.GetBoost());
@@ -567,9 +546,9 @@ namespace Lucene.Net.Search
BooleanQuery clone = null; // recursively rewrite
for (int i = 0; i < clauses.Count; i++)
{
- BooleanClause c = (BooleanClause) clauses[i];
- Query query = c.GetQuery().Rewrite(reader);
- if (query != c.GetQuery())
+ BooleanClause c = clauses[i];
+ Query query = c.Query.Rewrite(reader);
+ if (query != c.Query)
{
// clause rewrote: must clone
if (clone == null)
@@ -586,19 +565,18 @@ namespace Lucene.Net.Search
}
// inherit javadoc
- public override void ExtractTerms(System.Collections.Hashtable terms)
+ public override void ExtractTerms(System.Collections.Generic.ISet<Term> terms)
{
- for (System.Collections.IEnumerator i = clauses.GetEnumerator(); i.MoveNext(); )
+ foreach(BooleanClause clause in clauses)
{
- BooleanClause clause = (BooleanClause) i.Current;
- clause.GetQuery().ExtractTerms(terms);
+ clause.Query.ExtractTerms(terms);
}
}
public override System.Object Clone()
{
BooleanQuery clone = (BooleanQuery) base.Clone();
- clone.clauses = (SupportClass.EquatableList<BooleanClause>) this.clauses.Clone();
+ clone.clauses = (EquatableList<BooleanClause>) this.clauses.Clone();
return clone;
}
@@ -606,7 +584,7 @@ namespace Lucene.Net.Search
public override System.String ToString(System.String field)
{
System.Text.StringBuilder buffer = new System.Text.StringBuilder();
- bool needParens = (GetBoost() != 1.0) || (GetMinimumNumberShouldMatch() > 0);
+ bool needParens = (GetBoost() != 1.0) || (MinimumNumberShouldMatch > 0);
if (needParens)
{
buffer.Append("(");
@@ -614,13 +592,13 @@ namespace Lucene.Net.Search
for (int i = 0; i < clauses.Count; i++)
{
- BooleanClause c = (BooleanClause) clauses[i];
- if (c.IsProhibited())
+ BooleanClause c = clauses[i];
+ if (c.Prohibited)
buffer.Append("-");
- else if (c.IsRequired())
+ else if (c.Required)
buffer.Append("+");
-
- Query subQuery = c.GetQuery();
+
+ Query subQuery = c.Query;
if (subQuery != null)
{
if (subQuery is BooleanQuery)
@@ -649,10 +627,10 @@ namespace Lucene.Net.Search
buffer.Append(")");
}
- if (GetMinimumNumberShouldMatch() > 0)
+ if (MinimumNumberShouldMatch > 0)
{
buffer.Append('~');
- buffer.Append(GetMinimumNumberShouldMatch());
+ buffer.Append(MinimumNumberShouldMatch);
}
if (GetBoost() != 1.0f)
@@ -671,14 +649,19 @@ namespace Lucene.Net.Search
BooleanQuery other = (BooleanQuery)o;
return (this.GetBoost() == other.GetBoost())
&& this.clauses.Equals(other.clauses)
- && this.GetMinimumNumberShouldMatch() == other.GetMinimumNumberShouldMatch()
+ && this.MinimumNumberShouldMatch == other.MinimumNumberShouldMatch
&& this.disableCoord == other.disableCoord;
}
/// <summary>Returns a hash code value for this object.</summary>
public override int GetHashCode()
{
- return BitConverter.ToInt32(BitConverter.GetBytes(GetBoost()), 0) ^ clauses.GetHashCode() + GetMinimumNumberShouldMatch() + (disableCoord ? 17 : 0);
+ return BitConverter.ToInt32(BitConverter.GetBytes(GetBoost()), 0) ^ clauses.GetHashCode() + MinimumNumberShouldMatch + (disableCoord ? 17 : 0);
}
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
}
}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/src/core/Search/BooleanScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/BooleanScorer.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/BooleanScorer.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/BooleanScorer.cs Tue Feb 28 22:43:08 2012
@@ -136,32 +136,11 @@ namespace Lucene.Net.Search
return NO_MORE_DOCS;
}
- /// <deprecated> use <see cref="DocID()" /> instead.
- /// </deprecated>
- [Obsolete("use DocID() instead.")]
- public override int Doc()
- {
- return doc;
- }
-
public override int DocID()
{
return doc;
}
- public override Explanation Explain(int doc)
- {
- return null;
- }
-
- /// <deprecated> use <see cref="NextDoc()" /> instead.
- /// </deprecated>
- [Obsolete("use NextDoc() instead. ")]
- public override bool Next()
- {
- return false;
- }
-
public override int NextDoc()
{
return NO_MORE_DOCS;
@@ -171,14 +150,6 @@ namespace Lucene.Net.Search
{
return score;
}
-
- /// <deprecated> use <see cref="Advance(int)" /> instead.
- /// </deprecated>
- [Obsolete("use Advance(int) instead. ")]
- public override bool SkipTo(int target)
- {
- return false;
- }
}
internal sealed class Bucket
@@ -253,16 +224,17 @@ namespace Lucene.Net.Search
private Bucket current;
private int doc = - 1;
- public /*internal*/ BooleanScorer(Similarity similarity, int minNrShouldMatch, System.Collections.IList optionalScorers, System.Collections.IList prohibitedScorers):base(similarity)
+ public /*internal*/ BooleanScorer(Similarity similarity, int minNrShouldMatch,
+ System.Collections.Generic.List<Scorer> optionalScorers, System.Collections.Generic.List<Scorer> prohibitedScorers)
+ : base(similarity)
{
InitBlock();
this.minNrShouldMatch = minNrShouldMatch;
if (optionalScorers != null && optionalScorers.Count > 0)
{
- for (System.Collections.IEnumerator si = optionalScorers.GetEnumerator(); si.MoveNext(); )
+ foreach (Scorer scorer in optionalScorers)
{
- Scorer scorer = (Scorer) si.Current;
maxCoord++;
if (scorer.NextDoc() != NO_MORE_DOCS)
{
@@ -273,9 +245,8 @@ namespace Lucene.Net.Search
if (prohibitedScorers != null && prohibitedScorers.Count > 0)
{
- for (System.Collections.IEnumerator si = prohibitedScorers.GetEnumerator(); si.MoveNext(); )
+ foreach(Scorer scorer in prohibitedScorers)
{
- Scorer scorer = (Scorer) si.Current;
int mask = nextMask;
nextMask = nextMask << 1;
prohibitedMask |= mask; // update prohibited mask
@@ -359,45 +330,16 @@ namespace Lucene.Net.Search
return false;
}
- /// <deprecated> use <see cref="Score(Collector, int, int)" /> instead.
- /// </deprecated>
- [Obsolete("use Score(Collector, int, int) instead.")]
- protected internal override bool Score(HitCollector hc, int max)
- {
- return Score(new HitCollectorWrapper(hc), max, DocID());
- }
-
public override int Advance(int target)
{
throw new System.NotSupportedException();
}
- /// <deprecated> use <see cref="DocID()" /> instead.
- /// </deprecated>
- [Obsolete("use DocID() instead. ")]
- public override int Doc()
- {
- return current.doc;
- }
-
public override int DocID()
{
return doc;
}
-
- public override Explanation Explain(int doc)
- {
- throw new System.NotSupportedException();
- }
-
- /// <deprecated> use <see cref="NextDoc()" /> instead.
- /// </deprecated>
- [Obsolete("use NextDoc() instead. ")]
- public override bool Next()
- {
- return NextDoc() != NO_MORE_DOCS;
- }
-
+
public override int NextDoc()
{
bool more;
@@ -447,22 +389,6 @@ namespace Lucene.Net.Search
Score(collector, System.Int32.MaxValue, NextDoc());
}
- /// <deprecated> use <see cref="Score(Collector)" /> instead.
- /// </deprecated>
- [Obsolete("use Score(Collector) instead. ")]
- public override void Score(HitCollector hc)
- {
- Score(new HitCollectorWrapper(hc));
- }
-
- /// <deprecated> use <see cref="Advance(int)" /> instead.
- /// </deprecated>
- [Obsolete("use Advance(int) instead. ")]
- public override bool SkipTo(int target)
- {
- throw new System.NotSupportedException();
- }
-
public override System.String ToString()
{
System.Text.StringBuilder buffer = new System.Text.StringBuilder();