21 using Term = Lucene.Net.Index.Term;
24 namespace Lucene.Net.Search
38 private System.Globalization.CompareInfo collator = null;
39 private bool endEnum =
false;
40 private System.String field;
41 private System.String upperTermText;
42 private System.String lowerTermText;
43 private bool includeLower;
44 private bool includeUpper;
73 public TermRangeTermEnum(
IndexReader reader, System.String field, System.String lowerTermText, System.String upperTermText,
bool includeLower,
bool includeUpper, System.Globalization.CompareInfo collator)
75 this.collator = collator;
76 this.upperTermText = upperTermText;
77 this.lowerTermText = lowerTermText;
78 this.includeLower = includeLower;
79 this.includeUpper = includeUpper;
84 if (this.lowerTermText == null)
86 this.lowerTermText =
"";
87 this.includeLower =
true;
90 if (this.upperTermText == null)
92 this.includeUpper =
true;
95 System.String startTermText = collator == null?this.lowerTermText:
"";
96 SetEnum(reader.Terms(
new Term(this.field, startTermText)));
99 public override float Difference()
104 public override bool EndEnum()
109 protected internal override bool TermCompare(
Term term)
111 if (collator == null)
114 bool checkLower = !includeLower;
115 if (term != null && (System.Object) term.Field == (System.Object) field)
118 if (!checkLower || null == lowerTermText || String.CompareOrdinal(term.Text, lowerTermText) > 0)
121 if (upperTermText != null)
123 int compare = String.CompareOrdinal(upperTermText, term.Text);
128 if ((compare < 0) || (!includeUpper && compare == 0))
147 if (term != null && (System.Object) term.Field == (System.Object) field)
150 if ((lowerTermText == null || (includeLower?collator.Compare(term.Text.ToString(), lowerTermText.ToString()) >= 0:collator.Compare(term.Text.ToString(), lowerTermText.ToString()) > 0)) && (upperTermText == null || (includeUpper?collator.Compare(term.Text.ToString(), upperTermText.ToString()) <= 0:collator.Compare(term.Text.ToString(), upperTermText.ToString()) < 0)))