com.ibm.icu.lang
Class UScriptRun
public final class UScriptRun
UScriptRun is used to find runs of characters in
the same script, as defined in the
UScript class.
It implements a simple iterator over an array of characters.
The iterator will assign
COMMON and
INHERITED
characters to the same script as the preceeding characters. If the
COMMON and INHERITED characters are first, they will be assigned to
the same script as the following characters.
The iterator will try to match paired punctuation. If it sees an
opening punctuation character, it will remember the script that
was assigned to that character, and assign the same script to the
matching closing punctuation.
No attempt is made to combine related scripts into a single run. In
particular, Hiragana, Katakana, and Han characters will appear in seperate
runs.
Here is an example of how to iterate over script runs:
void printScriptRuns(char[] text)
{
UScriptRun scriptRun = new UScriptRun(text);
while (scriptRun.next()) {
int start = scriptRun.getScriptStart();
int limit = scriptRun.getScriptLimit();
int script = scriptRun.getScriptCode();
System.out.println("Script \"" + UScript.getName(script) + "\" from " +
start + " to " + limit + ".");
}
}
UScriptRun()- Construct an empty
UScriptRun object.
|
UScriptRun(String text)- Construct a
UScriptRun object which iterates over the
characters in the given string.
|
UScriptRun(String text, int start, int count)- Construct a
UScriptRun object which iterates over a subrange
of the characetrs in the given string.
|
UScriptRun(char[] chars)- Construct a
UScriptRun object which iterates over the given
characetrs.
|
UScriptRun(char[] chars, int start, int count)- Construct a
UScriptRun object which iterates over a subrange
of the given characetrs.
|
int | getScriptCode()- Get the script code for the script of the current script run.
|
int | getScriptLimit()- Get the index of the first character after the current script run.
|
int | getScriptStart()- Get the starting index of the current script run.
|
boolean | next()- Find the next script run.
|
void | reset()- Reset the iterator to the start of the text.
|
void | reset(String text)- Reset the iterator to iterate over the characters
in
text.
|
void | reset(String text, int start, int count)- Reset the iterator to iterate over
count characters
in text starting at start.
|
void | reset(char[] chars)- Reset the iterator to iterate over the characters
in
chars.
|
void | reset(char[] chars, int start, int count)- Reset the iterator to iterate over
count characters
in chars starting at start.
|
void | reset(int start, int count)- Reset the iterator to iterate over the given range of the text.
|
UScriptRun
public UScriptRun()
Construct an empty UScriptRun object. The next()
method will return false the first time it is called.
UScriptRun
public UScriptRun(String text)
Construct a UScriptRun object which iterates over the
characters in the given string.
text - the string of characters over which to iterate.
UScriptRun
public UScriptRun(String text,
int start,
int count) Construct a UScriptRun object which iterates over a subrange
of the characetrs in the given string.
text - the string of characters over which to iterate.start - the index of the first character over which to iteratecount - the number of characters over which to iterate
UScriptRun
public UScriptRun(char[] chars)
Construct a UScriptRun object which iterates over the given
characetrs.
chars - the array of characters over which to iterate.
UScriptRun
public UScriptRun(char[] chars,
int start,
int count) Construct a UScriptRun object which iterates over a subrange
of the given characetrs.
chars - the array of characters over which to iterate.start - the index of the first character over which to iteratecount - the number of characters over which to iterate
getScriptCode
public final int getScriptCode()
Get the script code for the script of the current script run.
- the script code for the script of the current script run.
getScriptLimit
public final int getScriptLimit()
Get the index of the first character after the current script run.
- the index of the first character after the current script run.
getScriptStart
public final int getScriptStart()
Get the starting index of the current script run.
- the index of the first character in the current script run.
next
public final boolean next()
Find the next script run. Returns false if there
isn't another run, returns true if there is.
false if there isn't another run, true if there is.
reset
public final void reset()
Reset the iterator to the start of the text.
reset
public final void reset(String text)
Reset the iterator to iterate over the characters
in text. This allows clients to reuse an iterator.
text - the new string of characters over which to iterate.
reset
public final void reset(String text,
int start,
int count) Reset the iterator to iterate over count characters
in text starting at start. This allows
clients to reuse an iterator.
text - the new string of characters over which to iterate.start - the index of the first character over which to iterate.count - the nuber of characters over which to iterate.
reset
public final void reset(char[] chars)
Reset the iterator to iterate over the characters
in chars. This allows clients to reuse an iterator.
chars - the new array of characters over which to iterate.
reset
public final void reset(char[] chars,
int start,
int count) Reset the iterator to iterate over count characters
in chars starting at start. This allows
clients to reuse an iterator.
chars - the new array of characters over which to iterate.start - the index of the first character over which to iterate.count - the number of characters over which to iterate.
reset
public final void reset(int start,
int count)
throws IllegalArgumentException Reset the iterator to iterate over the given range of the text. Throws
IllegalArgumentException if the range is outside of the bounds of the
character array.
start - the index of the new first character over which to iteratecount - the new number of characters over which to iterate.
Copyright (c) 2006 IBM Corporation and others.