Top Description Fields Constructors Methods
com.ibm.icu.text

pack-priv Class TransliterationRuleSet

extends Object
Class Inheritance
Imports
java.util.ArrayList, .List, com.ibm.icu.impl.UtilityExtensions

A set of rules for a RuleBasedTransliterator. This set encodes the transliteration in one direction from one set of characters or short strings to another. A RuleBasedTransliterator 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 the findMatch() method.

Copyright © IBM Corporation 1999. All rights reserved.

Author
Alan Liu

Field Summary

Modifier and TypeField and Description
private int[]
index

Index table.

private int
maxContextLength

Length of the longest preceding context

private TransliterationRule[]
rules

Sorted and indexed table of rules.

private List<TransliterationRule>
ruleVector

Vector of rules, in the order added.

Constructor Summary

AccessConstructor and Description
public
TransliterationRuleSet()

Construct a new empty rule set.

Method Summary

Modifier and TypeMethod and Description
public void
addRule(TransliterationRule
the rule to add
rule
)

Add a rule to this set.

pack-priv void
addSourceTargetSet(UnicodeSet filter, UnicodeSet sourceSet, UnicodeSet targetSet)

public void
freeze()

Close this rule set to further additions, check it for masked rules, and index it to optimize performance.

public int

Returns:

the length of the longest preceding context.
getMaximumContextLength
()

Return the maximum context length.

pack-priv String
toRules(boolean escapeUnprintable)

Create rule strings that represents this rule set.

public boolean

Returns:

true unless a U_PARTIAL_MATCH has been obtained, indicating that transliteration should stop until more text arrives.
transliterate
(Replaceable
the text to be transliterated
text
,
Transliterator.Position
the position indices, which will be updated
pos
,
boolean
if true, assume new text may be inserted at index.limit, and return false if there is a partial match.
incremental
)

Transliterate the given text with the given UTransPosition indices.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

indexback to summary
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().

maxContextLengthback to summary
private int maxContextLength

Length of the longest preceding context

rulesback to summary
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[].

ruleVectorback to summary
private List<TransliterationRule> ruleVector

Vector of rules, in the order added.

Constructor Detail

TransliterationRuleSetback to summary
public TransliterationRuleSet()

Construct a new empty rule set.

Method Detail

addRuleback to summary
public void addRule(TransliterationRule rule)

Add a rule to this set. Rules are added in order, and order is significant.

Parameters
rule:TransliterationRule

the rule to add

addSourceTargetSetback to summary
pack-priv void addSourceTargetSet(UnicodeSet filter, UnicodeSet sourceSet, UnicodeSet targetSet)
freezeback to summary
public void freeze()

Close this rule set to further additions, check it for masked rules, and index it to optimize performance.

Exceptions
IllegalArgumentException:
if some rules are masked
getMaximumContextLengthback to summary
public int getMaximumContextLength()

Return the maximum context length.

Returns:int

the length of the longest preceding context.

toRulesback to summary
pack-priv String toRules(boolean escapeUnprintable)

Create rule strings that represents this rule set.

transliterateback to summary
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:Replaceable

the text to be transliterated

pos:Transliterator.Position

the position indices, which will be updated

incremental:boolean

if true, assume new text may be inserted at index.limit, and return false if there is a partial match.

Returns:boolean

true unless a U_PARTIAL_MATCH has been obtained, indicating that transliteration should stop until more text arrives.