Package com.ibm.icu.text
Class TransliterationRuleSet
- java.lang.Object
-
- com.ibm.icu.text.TransliterationRuleSet
-
class TransliterationRuleSet extends java.lang.Object
A set of rules for aRuleBasedTransliterator
. This set encodes the transliteration in one direction from one set of characters or short strings to another. ARuleBasedTransliterator
consists of up to two such sets, one for the forward direction, and one for the reverse.A
TransliterationRuleSet
has one important operation, that of finding a matching rule at a given point in the text. This is accomplished by thefindMatch()
method.Copyright © IBM Corporation 1999. All rights reserved.
-
-
Field Summary
Fields Modifier and Type Field Description private int[]
index
Index table.private int
maxContextLength
Length of the longest preceding contextprivate TransliterationRule[]
rules
Sorted and indexed table of rules.private java.util.List<TransliterationRule>
ruleVector
Vector of rules, in the order added.
-
Constructor Summary
Constructors Constructor Description TransliterationRuleSet()
Construct a new empty rule set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRule(TransliterationRule rule)
Add a rule to this set.(package private) void
addSourceTargetSet(UnicodeSet filter, UnicodeSet sourceSet, UnicodeSet targetSet)
void
freeze()
Close this rule set to further additions, check it for masked rules, and index it to optimize performance.int
getMaximumContextLength()
Return the maximum context length.(package private) java.lang.String
toRules(boolean escapeUnprintable)
Create rule strings that represents this rule set.boolean
transliterate(Replaceable text, Transliterator.Position pos, boolean incremental)
Transliterate the given text with the given UTransPosition indices.
-
-
-
Field Detail
-
ruleVector
private java.util.List<TransliterationRule> ruleVector
Vector of rules, in the order added.
-
maxContextLength
private int maxContextLength
Length of the longest preceding context
-
rules
private TransliterationRule[] rules
Sorted and indexed table of rules. This is created by freeze() from the rules in ruleVector. rules.length >= ruleVector.size(), and the references in rules[] are aliases of the references in ruleVector. A single rule in ruleVector is listed one or more times in rules[].
-
index
private int[] index
Index table. For text having a first character c, compute x = c&0xFF. Now use rules[index[x]..index[x+1]-1]. This index table is created by freeze().
-
-
Method Detail
-
getMaximumContextLength
public int getMaximumContextLength()
Return the maximum context length.- Returns:
- the length of the longest preceding context.
-
addRule
public void addRule(TransliterationRule rule)
Add a rule to this set. Rules are added in order, and order is significant.- Parameters:
rule
- the rule to add
-
freeze
public void freeze()
Close this rule set to further additions, check it for masked rules, and index it to optimize performance.- Throws:
java.lang.IllegalArgumentException
- if some rules are masked
-
transliterate
public boolean transliterate(Replaceable text, Transliterator.Position pos, boolean incremental)
Transliterate the given text with the given UTransPosition indices. Return true if the transliteration should continue or false if it should halt (because of a U_PARTIAL_MATCH match). Note that false is only ever returned if isIncremental is true.- Parameters:
text
- the text to be transliteratedpos
- the position indices, which will be updatedincremental
- if true, assume new text may be inserted at index.limit, and return false if there is a partial match.- Returns:
- true unless a U_PARTIAL_MATCH has been obtained, indicating that transliteration should stop until more text arrives.
-
toRules
java.lang.String toRules(boolean escapeUnprintable)
Create rule strings that represents this rule set.
-
addSourceTargetSet
void addSourceTargetSet(UnicodeSet filter, UnicodeSet sourceSet, UnicodeSet targetSet)
-
-