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

pack-priv Class StringReplacer

extends Object
implements UnicodeReplacer
Class Inheritance
All Implemented Interfaces
com.ibm.icu.text.UnicodeReplacer
Imports
com.ibm.icu.impl.Utility

A replacer that produces static text as its output. The text may contain transliterator stand-in characters that represent nested UnicodeReplacer objects, making it possible to encode a tree of replacers in a StringReplacer. A StringReplacer that contains such stand-ins is called a complex StringReplacer. A complex StringReplacer has a slower processing loop than a non-complex one.
Author
Alan Liu

Field Summary

Modifier and TypeField and Description
private int
cursorPos

Cursor position.

private final RuleBasedTransliterator.Data
data

Object that translates stand-in characters in 'output' to UnicodeReplacer objects.

private boolean
hasCursor

True if this object outputs a cursor position.

private boolean
isComplex

A complex object contains nested replacers and requires more complex processing.

private String
output

Output text, possibly containing stand-in characters that represent nested UnicodeReplacers.

Constructor Summary

AccessConstructor and Description
public
StringReplacer(String
text that will replace input text when the replace() method is called. May contain stand-in characters that represent nested replacers.
theOutput
,
int
cursor position that will be returned by the replace() method
theCursorPos
,
RuleBasedTransliterator.Data
transliterator context object that translates stand-in characters to UnicodeReplacer objects
theData
)

Construct a StringReplacer that sets the emits the given output text and sets the cursor to the given position.

public
StringReplacer(String
text that will replace input text when the replace() method is called. May contain stand-in characters that represent nested replacers.
theOutput
,
RuleBasedTransliterator.Data
transliterator context object that translates stand-in characters to UnicodeReplacer objects
theData
)

Construct a StringReplacer that sets the emits the given output text and does not modify the cursor.

Method Summary

Modifier and TypeMethod and Description
public void
addReplacementSetTo(UnicodeSet
the set into which to union the output characters
toUnionTo
)

Implements com.ibm.icu.text.UnicodeReplacer.addReplacementSetTo.

Union the set of all characters that may output by this object into the given set.
public int
replace(Replaceable
the text to be matched
text
,
int
inclusive start index of text to be replaced
start
,
int
exclusive end index of text to be replaced; must be greater than or equal to start
limit
,
int[]
output parameter for the cursor position. Not all replacer objects will update this, but in a complete tree of replacer objects, representing the entire output side of a transliteration rule, at least one must update it.
cursor
)

Implements com.ibm.icu.text.UnicodeReplacer.replace.

UnicodeReplacer API
public String
toReplacerPattern(boolean
if true then convert unprintable character to their hex escape representations, \\uxxxx or \\Uxxxxxxxx. Unprintable characters are defined by Utility.isUnprintable().
escapeUnprintable
)

Implements com.ibm.icu.text.UnicodeReplacer.toReplacerPattern.

UnicodeReplacer API
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cursorPosback to summary
private int cursorPos

Cursor position. Value is ignored if hasCursor is false.

databack to summary
private final RuleBasedTransliterator.Data data

Object that translates stand-in characters in 'output' to UnicodeReplacer objects.

hasCursorback to summary
private boolean hasCursor

True if this object outputs a cursor position.

isComplexback to summary
private boolean isComplex

A complex object contains nested replacers and requires more complex processing. StringReplacers are initially assumed to be complex. If no nested replacers are seen during processing, then isComplex is set to false, and future replacements are short circuited for better performance.

outputback to summary
private String output

Output text, possibly containing stand-in characters that represent nested UnicodeReplacers.

Constructor Detail

StringReplacerback to summary
public StringReplacer(String theOutput, int theCursorPos, RuleBasedTransliterator.Data theData)

Construct a StringReplacer that sets the emits the given output text and sets the cursor to the given position.

Parameters
theOutput:String

text that will replace input text when the replace() method is called. May contain stand-in characters that represent nested replacers.

theCursorPos:int

cursor position that will be returned by the replace() method

theData:RuleBasedTransliterator.Data

transliterator context object that translates stand-in characters to UnicodeReplacer objects

StringReplacerback to summary
public StringReplacer(String theOutput, RuleBasedTransliterator.Data theData)

Construct a StringReplacer that sets the emits the given output text and does not modify the cursor.

Parameters
theOutput:String

text that will replace input text when the replace() method is called. May contain stand-in characters that represent nested replacers.

theData:RuleBasedTransliterator.Data

transliterator context object that translates stand-in characters to UnicodeReplacer objects

Method Detail

addReplacementSetToback to summary
public void addReplacementSetTo(UnicodeSet toUnionTo)

Implements com.ibm.icu.text.UnicodeReplacer.addReplacementSetTo.

Union the set of all characters that may output by this object into the given set.

Parameters
toUnionTo:UnicodeSet

the set into which to union the output characters

Annotations
@Override
replaceback to summary
public int replace(Replaceable text, int start, int limit, int[] cursor)

Implements com.ibm.icu.text.UnicodeReplacer.replace.

UnicodeReplacer API

Parameters
text:Replaceable

Doc from com.ibm.icu.text.UnicodeReplacer.replace.

the text to be matched

start:int

Doc from com.ibm.icu.text.UnicodeReplacer.replace.

inclusive start index of text to be replaced

limit:int

Doc from com.ibm.icu.text.UnicodeReplacer.replace.

exclusive end index of text to be replaced; must be greater than or equal to start

cursor:int[]

Doc from com.ibm.icu.text.UnicodeReplacer.replace.

output parameter for the cursor position. Not all replacer objects will update this, but in a complete tree of replacer objects, representing the entire output side of a transliteration rule, at least one must update it.

Returns:int

Doc from com.ibm.icu.text.UnicodeReplacer.replace.

the number of 16-bit code units in the text replacing the characters at offsets start..(limit-1) in text

Annotations
@Override
toReplacerPatternback to summary
public String toReplacerPattern(boolean escapeUnprintable)

Implements com.ibm.icu.text.UnicodeReplacer.toReplacerPattern.

UnicodeReplacer API

Parameters
escapeUnprintable:boolean

Doc from com.ibm.icu.text.UnicodeReplacer.toReplacerPattern.

if true then convert unprintable character to their hex escape representations, \\uxxxx or \\Uxxxxxxxx. Unprintable characters are defined by Utility.isUnprintable().

Annotations
@Override