Class PhoneticEngine.RulesApplication
java.lang.Object
org.apache.commons.codec.language.bm.PhoneticEngine.RulesApplication
- Enclosing class:
- PhoneticEngine
A function closure capturing the application of a list of rules to an input sequence at a particular offset.
After invocation, the values
i
and found
are updated. i
points to the
index of the next char in input
that must be processed next (the input up to that index having been
processed already), and found
indicates if a matching rule was found or not. In the case where a
matching rule was found, phonemeBuilder
is 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
FieldsModifier and TypeFieldDescriptionprivate boolean
private int
private final CharSequence
private final int
private final PhoneticEngine.PhonemeBuilder
-
Constructor Summary
ConstructorsConstructorDescriptionRulesApplication
(Map<String, List<Rule>> finalRules, CharSequence input, PhoneticEngine.PhonemeBuilder phonemeBuilder, int i, int maxPhonemes) -
Method Summary
-
Field Details
-
finalRules
-
input
-
phonemeBuilder
-
i
private int i -
maxPhonemes
private final int maxPhonemes -
found
private boolean found
-
-
Constructor Details
-
RulesApplication
public RulesApplication(Map<String, List<Rule>> finalRules, CharSequence input, PhoneticEngine.PhonemeBuilder phonemeBuilder, int i, int maxPhonemes)
-
-
Method Details
-
getI
public int getI() -
getPhonemeBuilder
-
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,i
is advanced one and the character is silently dropped from the phonetic spelling.- Returns:
this
-
isFound
public boolean isFound()
-