19 using System.Globalization;
23 namespace Lucene.Net.Search
42 private System.String lowerTerm;
43 private System.String upperTerm;
44 private System.Globalization.CompareInfo collator;
45 private System.String field;
46 private bool includeLower;
47 private bool includeUpper;
72 public TermRangeQuery(System.String field, System.String lowerTerm, System.String upperTerm,
bool includeLower,
bool includeUpper):this(field, lowerTerm, upperTerm, includeLower, includeUpper, null)
110 public TermRangeQuery(System.String field, System.String lowerTerm, System.String upperTerm,
bool includeLower,
bool includeUpper, System.Globalization.CompareInfo collator)
113 this.lowerTerm = lowerTerm;
114 this.upperTerm = upperTerm;
115 this.includeLower = includeLower;
116 this.includeUpper = includeUpper;
117 this.collator = collator;
121 public virtual string Field
123 get {
return field; }
127 public virtual string LowerTerm
129 get {
return lowerTerm; }
133 public virtual string UpperTerm
135 get {
return upperTerm; }
139 public virtual bool IncludesLower
141 get {
return includeLower; }
145 public virtual bool IncludesUpper
147 get {
return includeUpper; }
151 public virtual CompareInfo Collator
153 get {
return collator; }
158 return new TermRangeTermEnum(reader, field, lowerTerm, upperTerm, includeLower, includeUpper, collator);
162 public override System.String ToString(System.String field)
164 System.Text.StringBuilder buffer =
new System.Text.StringBuilder();
165 if (!
Field.Equals(field))
167 buffer.Append(
Field);
170 buffer.Append(includeLower?
'[':
'{');
171 buffer.Append(lowerTerm != null?lowerTerm:
"*");
172 buffer.Append(
" TO ");
173 buffer.Append(upperTerm != null?upperTerm:
"*");
174 buffer.Append(includeUpper?
']':
'}');
176 return buffer.ToString();
180 public override int GetHashCode()
183 int result = base.GetHashCode();
184 result = prime * result + ((collator == null)?0:collator.GetHashCode());
185 result = prime * result + ((field == null)?0:field.GetHashCode());
186 result = prime * result + (includeLower?1231:1237);
187 result = prime * result + (includeUpper?1231:1237);
188 result = prime * result + ((lowerTerm == null)?0:lowerTerm.GetHashCode());
189 result = prime * result + ((upperTerm == null)?0:upperTerm.GetHashCode());
194 public override bool Equals(System.Object obj)
198 if (!base.Equals(obj))
200 if (GetType() != obj.GetType())
203 if (collator == null)
205 if (other.collator != null)
208 else if (!collator.Equals(other.collator))
212 if (other.field != null)
215 else if (!field.Equals(other.field))
217 if (includeLower != other.includeLower)
219 if (includeUpper != other.includeUpper)
221 if (lowerTerm == null)
223 if (other.lowerTerm != null)
226 else if (!lowerTerm.Equals(other.lowerTerm))
228 if (upperTerm == null)
230 if (other.upperTerm != null)
233 else if (!upperTerm.Equals(other.upperTerm))