Class PhoneticEngine.RulesApplication
- java.lang.Object
-
- org.apache.commons.codec.language.bm.PhoneticEngine.RulesApplication
-
- Enclosing class:
- PhoneticEngine
private static final class PhoneticEngine.RulesApplication extends java.lang.ObjectA function closure capturing the application of a list of rules to an input sequence at a particular offset. After invocation, the valuesiandfoundare updated.ipoints to the index of the next char ininputthat must be processed next (the input up to that index having been processed already), andfoundindicates if a matching rule was found or not. In the case where a matching rule was found,phonemeBuilderis replaced with a new builder containing the phonemes updated by the matching rule. Although this class is not thread-safe (it has mutable unprotected fields), it is not shared between threads as it is constructed as needed by the calling methods.- Since:
- 1.6
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.util.List<Rule>>finalRulesprivate booleanfoundprivate intiprivate java.lang.CharSequenceinputprivate intmaxPhonemesprivate PhoneticEngine.PhonemeBuilderphonemeBuilder
-
Constructor Summary
Constructors Constructor Description RulesApplication(java.util.Map<java.lang.String,java.util.List<Rule>> finalRules, java.lang.CharSequence input, PhoneticEngine.PhonemeBuilder phonemeBuilder, int i, int maxPhonemes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetI()PhoneticEngine.PhonemeBuildergetPhonemeBuilder()PhoneticEngine.RulesApplicationinvoke()Invokes the rules.booleanisFound()
-
-
-
Field Detail
-
finalRules
private final java.util.Map<java.lang.String,java.util.List<Rule>> finalRules
-
input
private final java.lang.CharSequence input
-
phonemeBuilder
private final PhoneticEngine.PhonemeBuilder phonemeBuilder
-
i
private int i
-
maxPhonemes
private final int maxPhonemes
-
found
private boolean found
-
-
Constructor Detail
-
RulesApplication
public RulesApplication(java.util.Map<java.lang.String,java.util.List<Rule>> finalRules, java.lang.CharSequence input, PhoneticEngine.PhonemeBuilder phonemeBuilder, int i, int maxPhonemes)
-
-
Method Detail
-
getI
public int getI()
-
getPhonemeBuilder
public PhoneticEngine.PhonemeBuilder getPhonemeBuilder()
-
invoke
public PhoneticEngine.RulesApplication invoke()
Invokes the rules. Loops over the rules list, stopping at the first one that has a matching context and pattern. Then applies this rule to the phoneme builder to produce updated phonemes. If there was no match,iis advanced one and the character is silently dropped from the phonetic spelling.- Returns:
this
-
isFound
public boolean isFound()
-
-