18 using System.Collections.Generic;
20 namespace Lucene.Net.Analysis
31 private LinkedList<char> buffer;
32 private System.String replacement;
33 private int charPointer;
34 private int nextCharCounter;
40 this.normMap = normMap;
47 this.normMap = normMap;
50 public override int Read()
54 if (replacement != null && charPointer < replacement.Length)
56 return replacement[charPointer++];
59 int firstChar = NextChar();
63 ? normMap.submap[(char) firstChar]
70 replacement = result.normStr;
74 int prevCumulativeDiff = LastCumulativeDiff;
77 for (
int i = 0; i < - result.diff; i++)
78 AddOffCorrectMap(nextCharCounter + i - prevCumulativeDiff, prevCumulativeDiff - 1 - i);
82 AddOffCorrectMap(nextCharCounter - result.diff - prevCumulativeDiff, prevCumulativeDiff + result.diff);
88 private int NextChar()
91 if (buffer != null && buffer.Count != 0)
93 char tempObject = buffer.First.Value;
100 private void PushChar(
int c)
105 buffer =
new LinkedList<char>();
107 buffer.AddFirst((
char)c);
110 private void PushLastChar(
int c)
114 buffer =
new LinkedList<char>();
116 buffer.AddLast((
char)c);
119 private NormalizeCharMap Match(NormalizeCharMap map)
121 NormalizeCharMap result = null;
122 if (map.submap != null)
124 int chr = NextChar();
127 NormalizeCharMap subMap = map.submap[(char)chr];
130 result = Match(subMap);
138 if (result == null && map.normStr != null)
145 public override int Read(System.Char[] cbuf,
int off,
int len)
147 var tmp =
new char[len];
148 int l = input.Read(tmp, 0, len);
151 for (
int i = 0; i < l; i++)
152 PushLastChar(tmp[i]);
155 for (
int i = off; i < off + len; i++)