18 using System.Collections.Generic;
19 using Lucene.Net.Support;
21 namespace Lucene.Net.Analysis
45 private readonly
Analyzer defaultAnalyzer;
46 private readonly IDictionary<string, Analyzer> analyzerMap =
new HashMap<string, Analyzer>();
56 : this(defaultAnalyzer, null)
72 this.defaultAnalyzer = defaultAnalyzer;
73 if (fieldAnalyzers != null)
75 foreach(var entry
in fieldAnalyzers)
76 analyzerMap[entry.Key] = entry.Value;
78 SetOverridesTokenStreamMethod<PerFieldAnalyzerWrapper>();
89 public virtual void AddAnalyzer(System.String fieldName,
Analyzer analyzer)
91 analyzerMap[fieldName] = analyzer;
96 var analyzer = analyzerMap[fieldName] ?? defaultAnalyzer;
98 return analyzer.TokenStream(fieldName, reader);
101 public override TokenStream ReusableTokenStream(
string fieldName, System.IO.TextReader reader)
103 if (overridesTokenStreamMethod)
110 var analyzer = analyzerMap[fieldName] ?? defaultAnalyzer;
112 return analyzer.ReusableTokenStream(fieldName, reader);
116 public override int GetPositionIncrementGap(
string fieldName)
118 var analyzer = analyzerMap[fieldName] ?? defaultAnalyzer;
119 return analyzer.GetPositionIncrementGap(fieldName);
123 public override int GetOffsetGap(
Documents.IFieldable field)
125 Analyzer analyzer = analyzerMap[field.Name] ?? defaultAnalyzer;
129 public override System.String ToString()
132 return "PerFieldAnalyzerWrapper(" + analyzerMap +
", default=" + defaultAnalyzer +
")";