18 using Lucene.Net.Analysis.Tokenattributes;
19 using Lucene.Net.Index;
21 namespace Lucene.Net.Analysis.Miscellaneous
46 private readonly
Token _previousPrefixToken =
new Token();
47 private readonly
Token _reusableToken =
new Token();
51 private bool _prefixExhausted;
57 _prefixExhausted =
false;
60 _termAtt = AddAttribute<ITermAttribute>();
61 _posIncrAtt = AddAttribute<IPositionIncrementAttribute>();
62 _payloadAtt = AddAttribute<IPayloadAttribute>();
63 _offsetAtt = AddAttribute<IOffsetAttribute>();
64 _typeAtt = AddAttribute<ITypeAttribute>();
65 _flagsAtt = AddAttribute<IFlagsAttribute>();
80 public override sealed
bool IncrementToken()
82 if (!_prefixExhausted)
84 Token nextToken = GetNextPrefixInputToken(_reusableToken);
85 if (nextToken == null)
87 _prefixExhausted =
true;
91 _previousPrefixToken.Reinit(nextToken);
98 SetCurrentToken(nextToken);
103 Token nextSuffixToken = GetNextSuffixInputToken(_reusableToken);
104 if (nextSuffixToken == null)
109 nextSuffixToken = UpdateSuffixToken(nextSuffixToken, _previousPrefixToken);
110 SetCurrentToken(nextSuffixToken);
114 private void SetCurrentToken(
Token token)
116 if (token == null)
return;
120 _flagsAtt.Flags =token.
Flags;
122 _typeAtt.Type = token.
Type;
123 _payloadAtt.Payload = token.
Payload;
126 private Token GetNextPrefixInputToken(
Token token)
128 if (!Prefix.IncrementToken())
return null;
129 token.
SetTermBuffer(_pTermAtt.TermBuffer(), 0, _pTermAtt.TermLength());
131 token.
Flags = _pFlagsAtt.Flags;
132 token.
SetOffset(_pOffsetAtt.StartOffset, _pOffsetAtt.EndOffset);
133 token.
Type = _pTypeAtt.Type;
138 private Token GetNextSuffixInputToken(
Token token)
140 if (!Suffix.IncrementToken())
return null;
141 token.
SetTermBuffer(_termAtt.TermBuffer(), 0, _termAtt.TermLength());
142 token.PositionIncrement = _posIncrAtt.PositionIncrement;
143 token.Flags = _flagsAtt.Flags;
144 token.SetOffset(_offsetAtt.StartOffset, _offsetAtt.EndOffset);
145 token.Type = _typeAtt.Type;
146 token.Payload = _payloadAtt.Payload;
163 protected override void Dispose(
bool disposing)
169 public override void Reset()
175 _prefixExhausted =
false;