19 using System.Collections;
20 using System.Collections.Generic;
24 using Lucene.Net.Analysis;
25 using Lucene.Net.Analysis.Tokenattributes;
26 using Lucene.Net.Util;
29 namespace Lucene.Net.Analysis.Ext
55 t =
new SingleCharTokenizer(t);
68 char[] _buffer = null;
71 int _offsetInStream = -1;
73 public SingleCharTokenizer(
TokenStream input): base(input)
76 _termAttribute = AddAttribute<ITermAttribute>();
77 _offsetAttribute = AddAttribute<IOffsetAttribute>();
78 _positionIncrementAttribute = AddAttribute<IPositionIncrementAttribute>();
81 public override bool IncrementToken()
83 int positionIncrement = 0;
84 if (_buffer == null || _offset >= _length)
86 if (!_input.IncrementToken())
return false;
89 _buffer = _termAttribute.TermBuffer();
90 _length = _termAttribute.TermLength();
95 _offsetAttribute.SetOffset(_offsetInStream, _offsetInStream + 1);
99 _positionIncrementAttribute.PositionIncrement = positionIncrement;
101 _termAttribute.SetTermLength(1);
102 _termAttribute.SetTermBuffer(_buffer[_offset++].ToString());
107 public override void Reset()
112 _offsetInStream = -1;
117 protected override void Dispose(
bool disposing)
120 base.Dispose(disposing);
161 protected override bool IsTokenChar(
char c)
163 return char.IsLetterOrDigit(c);