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

pack-priv Class StringMatcher

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

An object that matches a fixed input string, implementing the UnicodeMatcher API. This object also implements the UnicodeReplacer API, allowing it to emit the matched text as output. Since the match text may contain flexible match elements, such as UnicodeSets, the emitted text is not the match pattern, but instead a substring of the actual matched text. Following convention, the output text is the leftmost match seen up to this point. A StringMatcher may represent a segment, in which case it has a positive segment number. This affects how the matcher converts itself to a pattern but does not otherwise affect its function. A StringMatcher that is not a segment should not be used as a UnicodeReplacer.

Field Summary

Modifier and TypeField and Description
private final RuleBasedTransliterator.Data
data

Context object that maps stand-ins to matcher and replacer objects.

private int
matchLimit

Limit offset, in the match text, of the rightmost match.

private int
matchStart

Start offset, in the match text, of the rightmost match.

private String
pattern

The text to be matched.

private int
segmentNumber

The segment number, 1-based, or 0 if not a segment.

Constructor Summary

AccessConstructor and Description
public
StringMatcher(String
the pattern to be matched, possibly containing stand-ins that represent nested UnicodeMatcher objects.
theString
,
int
the segment number from 1..n, or 0 if this is not a segment.
segmentNum
,
RuleBasedTransliterator.Data
context object mapping stand-ins to UnicodeMatcher objects.
theData
)

Construct a matcher that matches the given pattern string.

public
StringMatcher(String
the pattern to be matched, possibly containing stand-ins that represent nested UnicodeMatcher objects.
theString
,
int
first character of theString to be matched
start
,
int
index after the last character of theString to be matched.
limit
,
int
the segment number from 1..n, or 0 if this is not a segment.
segmentNum
,
RuleBasedTransliterator.Data
context object mapping stand-ins to UnicodeMatcher objects.
theData
)

Construct a matcher that matches a substring of the given pattern string.

Method Summary

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

Implements com.ibm.icu.text.UnicodeMatcher.addMatchSetTo.

Implementation of UnicodeMatcher API.
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
matches(Replaceable
the text to be matched
text
,
int[]
on input, the index into text at which to begin matching. On output, the limit of the matched text. The number of matched characters is the output value of offset minus the input value. Offset should always point to the HIGH SURROGATE (leading code unit) of a pair of surrogates, both on entry and upon return.
offset
,
int
the limit index of text to be matched. Greater than offset for a forward direction match, less than offset for a backward direction match. The last character to be considered for matching will be text.charAt(limit-1) in the forward direction or text.charAt(limit+1) in the backward direction.
limit
,
boolean
if true, then assume further characters may be inserted at limit and check for partial matching. Otherwise assume the text as given is complete.
incremental
)

Implements com.ibm.icu.text.UnicodeMatcher.matches.

Implement UnicodeMatcher
public boolean
matchesIndexValue(int v)

Implements com.ibm.icu.text.UnicodeMatcher.matchesIndexValue.

Implement UnicodeMatcher
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 void
resetMatch()

Remove any match data.

public String
toPattern(boolean
if true then convert unprintable character to their hex escape representations, \\uxxxx or \\Uxxxxxxxx. Unprintable characters are those other than U+000A, U+0020..U+007E.
escapeUnprintable
)

Implements com.ibm.icu.text.UnicodeMatcher.toPattern.

Implement UnicodeMatcher
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

databack to summary
private final RuleBasedTransliterator.Data data

Context object that maps stand-ins to matcher and replacer objects.

matchLimitback to summary
private int matchLimit

Limit offset, in the match text, of the rightmost match.

matchStartback to summary
private int matchStart

Start offset, in the match text, of the rightmost match.

patternback to summary
private String pattern

The text to be matched.

segmentNumberback to summary
private int segmentNumber

The segment number, 1-based, or 0 if not a segment.

Constructor Detail

StringMatcherback to summary
public StringMatcher(String theString, int segmentNum, RuleBasedTransliterator.Data theData)

Construct a matcher that matches the given pattern string.

Parameters
theString:String

the pattern to be matched, possibly containing stand-ins that represent nested UnicodeMatcher objects.

segmentNum:int

the segment number from 1..n, or 0 if this is not a segment.

theData:RuleBasedTransliterator.Data

context object mapping stand-ins to UnicodeMatcher objects.

StringMatcherback to summary
public StringMatcher(String theString, int start, int limit, int segmentNum, RuleBasedTransliterator.Data theData)

Construct a matcher that matches a substring of the given pattern string.

Parameters
theString:String

the pattern to be matched, possibly containing stand-ins that represent nested UnicodeMatcher objects.

start:int

first character of theString to be matched

limit:int

index after the last character of theString to be matched.

segmentNum:int

the segment number from 1..n, or 0 if this is not a segment.

theData:RuleBasedTransliterator.Data

context object mapping stand-ins to UnicodeMatcher objects.

Method Detail

addMatchSetToback to summary
public void addMatchSetTo(UnicodeSet toUnionTo)

Implements com.ibm.icu.text.UnicodeMatcher.addMatchSetTo.

Implementation of UnicodeMatcher API. Union the set of all characters that may be matched by this object into the given set.

Parameters
toUnionTo:UnicodeSet

the set into which to union the source characters

Annotations
@Override
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
matchesback to summary
public int matches(Replaceable text, int[] offset, int limit, boolean incremental)

Implements com.ibm.icu.text.UnicodeMatcher.matches.

Implement UnicodeMatcher

Parameters
text:Replaceable

Doc from com.ibm.icu.text.UnicodeMatcher.matches.

the text to be matched

offset:int[]

Doc from com.ibm.icu.text.UnicodeMatcher.matches.

on input, the index into text at which to begin matching. On output, the limit of the matched text. The number of matched characters is the output value of offset minus the input value. Offset should always point to the HIGH SURROGATE (leading code unit) of a pair of surrogates, both on entry and upon return.

limit:int

Doc from com.ibm.icu.text.UnicodeMatcher.matches.

the limit index of text to be matched. Greater than offset for a forward direction match, less than offset for a backward direction match. The last character to be considered for matching will be text.charAt(limit-1) in the forward direction or text.charAt(limit+1) in the backward direction.

incremental:boolean

Doc from com.ibm.icu.text.UnicodeMatcher.matches.

if true, then assume further characters may be inserted at limit and check for partial matching. Otherwise assume the text as given is complete.

Returns:int

Doc from com.ibm.icu.text.UnicodeMatcher.matches.

a match degree value indicating a full match, a partial match, or a mismatch. If incremental is false then U_PARTIAL_MATCH should never be returned.

Annotations
@Override
matchesIndexValueback to summary
public boolean matchesIndexValue(int v)

Implements com.ibm.icu.text.UnicodeMatcher.matchesIndexValue.

Implement UnicodeMatcher

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
resetMatchback to summary
public void resetMatch()

Remove any match data. This must be called before performing a set of matches with this segment.

toPatternback to summary
public String toPattern(boolean escapeUnprintable)

Implements com.ibm.icu.text.UnicodeMatcher.toPattern.

Implement UnicodeMatcher

Parameters
escapeUnprintable:boolean

Doc from com.ibm.icu.text.UnicodeMatcher.toPattern.

if true then convert unprintable character to their hex escape representations, \\uxxxx or \\Uxxxxxxxx. Unprintable characters are those other than U+000A, U+0020..U+007E.

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