21 using Term = Lucene.Net.Index.Term;
24 namespace Lucene.Net.Search
44 private readonly
bool _termContainsWildcard;
45 private readonly
bool _termIsPrefix;
46 protected internal Term internalTerm;
50 this.internalTerm = term;
51 string text = term.Text;
52 _termContainsWildcard = (term.Text.IndexOf(
'*') != -1)
53 || (term.Text.IndexOf(
'?') != -1);
54 _termIsPrefix = _termContainsWildcard
55 && (text.IndexOf(
'?') == -1)
56 && (text.IndexOf(
'*') == text.Length - 1);
61 if (_termContainsWildcard)
67 return new SingleTermEnum(reader,
Term);
74 get {
return internalTerm; }
82 new PrefixQuery(internalTerm.CreateTerm(internalTerm.Text.Substring(0, internalTerm.Text.IndexOf(
'*'))));
83 rewritten.
Boost = Boost;
94 public override System.String ToString(System.String field)
96 System.Text.StringBuilder buffer =
new System.Text.StringBuilder();
97 if (!internalTerm.Field.Equals(field))
99 buffer.Append(internalTerm.Field);
102 buffer.Append(internalTerm.Text);
108 public override int GetHashCode()
111 int result = base.GetHashCode();
112 result = prime * result + ((internalTerm == null)?0:internalTerm.GetHashCode());
117 public override bool Equals(System.Object obj)
121 if (!base.Equals(obj))
123 if (GetType() != obj.GetType())
126 if (internalTerm == null)
128 if (other.internalTerm != null)
131 else if (!internalTerm.Equals(other.internalTerm))