2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 namespace Mono.Lucene.Net.Analysis
23 /// <summary> Holds a map of String input to String output, to be used
24 /// with {@link MappingCharFilter}.
26 public class NormalizeCharMap
29 //Map<Character, NormalizeMap> submap;
30 internal System.Collections.IDictionary submap;
31 internal System.String normStr;
34 /// <summary>Records a replacement to be applied to the inputs
35 /// stream. Whenever <code>singleMatch</code> occurs in
36 /// the input, it will be replaced with
37 /// <code>replacement</code>.
40 /// <param name="singleMatch">input String to be replaced
42 /// <param name="replacement">output String
44 public virtual void Add(System.String singleMatch, System.String replacement)
46 NormalizeCharMap currMap = this;
47 for (int i = 0; i < singleMatch.Length; i++)
49 char c = singleMatch[i];
50 if (currMap.submap == null)
52 currMap.submap = new System.Collections.Hashtable(1);
54 NormalizeCharMap map = (NormalizeCharMap) currMap.submap[CharacterCache.ValueOf(c)];
57 map = new NormalizeCharMap();
58 currMap.submap[c] = map;
62 if (currMap.normStr != null)
64 throw new System.SystemException("MappingCharFilter: there is already a mapping for " + singleMatch);
66 currMap.normStr = replacement;
67 currMap.diff = singleMatch.Length - replacement.Length;