Top Description Inners Fields Constructors Methods
com.ibm.icu.lang

public final Class UScriptRun

extends Object
Class Inheritance
Annotations
@Deprecated
Imports
com.ibm.icu.text.UTF16

Deprecated

This API is ICU internal only.

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 preceding 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 separate 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 + ".");
    }
 }
ICU Status
Internal ICU component.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private char[]
private int
private static int
private static int
private static int[]
private static int
private int
private static UScriptRun.ParenStackEntry[]
private int
private int
private int
private int
private char[]
private int
private int
private int

Constructor Summary

AccessConstructor and Description
public
UScriptRun()

Deprecated This API is ICU internal only.
Construct an empty UScriptRun object.
public
UScriptRun(String
the string of characters over which to iterate.
text
)

Deprecated This API is ICU internal only.
Construct a UScriptRun object which iterates over the characters in the given string.
public
UScriptRun(String
the string of characters over which to iterate.
text
,
int
the index of the first character over which to iterate
start
,
int
the number of characters over which to iterate
count
)

Deprecated This API is ICU internal only.
Construct a UScriptRun object which iterates over a subrange of the characters in the given string.
public
UScriptRun(char[]
the array of characters over which to iterate.
chars
)

Deprecated This API is ICU internal only.
Construct a UScriptRun object which iterates over the given characters.
public
UScriptRun(char[]
the array of characters over which to iterate.
chars
,
int
the index of the first character over which to iterate
start
,
int
the number of characters over which to iterate
count
)

Deprecated This API is ICU internal only.
Construct a UScriptRun object which iterates over a subrange of the given characters.

Method Summary

Modifier and TypeMethod and Description
private static final int
dec(int sp, int count)

private static final int
dec(int sp)

private final void
fixup(int scrptCode)

private static int

Returns:

the index of the character in the table, or -1 if it's not there.
getPairIndex
(int
the character for which to search.
ch
)

Search the pairedChars array for the given character.

public final int

Returns:

the script code for the script of the current script run.
getScriptCode
()

Deprecated This API is ICU internal only.
Get the script code for the script of the current script run.
public final int

Returns:

the index of the first character after the current script run.
getScriptLimit
()

Deprecated This API is ICU internal only.
Get the index of the first character after the current script run.
public final int

Returns:

the index of the first character in the current script run.
getScriptStart
()

Deprecated This API is ICU internal only.
Get the starting index of the current script run.
private static final byte

Returns:

the bit number (counting from the low order bit) of the highest bit.
highBit
(int
the word in which to find the highest bit that's set.
n
)

Find the highest bit that's set in a word.

private static final int
inc(int sp, int count)

private static final int
inc(int sp)

private static final int
limitInc(int count)

private static final int
mod(int sp)

public final boolean

Returns:

false if there isn't another run, true if there is.
next
()

Deprecated This API is ICU internal only.
Find the next script run.
private final void
pop()

private final void
push(int pairIndex, int scrptCode)

public final void
reset()

Deprecated This API is ICU internal only.
Reset the iterator to the start of the text.
public final void
reset(int
the index of the new first character over which to iterate
start
,
int
the new number of characters over which to iterate.
count
)

Deprecated This API is ICU internal only.
Reset the iterator to iterate over the given range of the text.
public final void
reset(char[]
the new array of characters over which to iterate.
chars
,
int
the index of the first character over which to iterate.
start
,
int
the number of characters over which to iterate.
count
)

Deprecated This API is ICU internal only.
Reset the iterator to iterate over count characters in chars starting at start.
public final void
reset(char[]
the new array of characters over which to iterate.
chars
)

Deprecated This API is ICU internal only.
Reset the iterator to iterate over the characters in chars.
public final void
reset(String
the new string of characters over which to iterate.
str
,
int
the index of the first character over which to iterate.
start
,
int
the nuber of characters over which to iterate.
count
)

Deprecated This API is ICU internal only.
Reset the iterator to iterate over count characters in text starting at start.
public final void
reset(String
the new string of characters over which to iterate.
str
)

Deprecated This API is ICU internal only.
Reset the iterator to iterate over the characters in text.
private static boolean

Returns:

true if the two scripts are the same.
sameScript
(int
one of the script codes.
scriptOne
,
int
the other script code.
scriptTwo
)

Compare two script codes to see if they are in the same script.

private final boolean
private final boolean
private final void
private final UScriptRun.ParenStackEntry
top()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

emptyCharArrayback to summary
private char[] emptyCharArray
fixupCountback to summary
private int fixupCount
pairedCharExtraback to summary
private static int pairedCharExtra
pairedCharPowerback to summary
private static int pairedCharPower
pairedCharsback to summary
private static int[] pairedChars
PAREN_STACK_DEPTHback to summary
private static int PAREN_STACK_DEPTH
parenSPback to summary
private int parenSP
parenStackback to summary
private static UScriptRun.ParenStackEntry[] parenStack
pushCountback to summary
private int pushCount
scriptCodeback to summary
private int scriptCode
scriptLimitback to summary
private int scriptLimit
scriptStartback to summary
private int scriptStart
textback to summary
private char[] text
textIndexback to summary
private int textIndex
textLimitback to summary
private int textLimit
textStartback to summary
private int textStart

Constructor Detail

UScriptRunback to summary
public UScriptRun()

Deprecated

This API is ICU internal only.

Construct an empty UScriptRun object. The next() method will return false the first time it is called.

Annotations
@Deprecated
ICU Status
Internal ICU component.
UScriptRunback to summary
public UScriptRun(String text)

Deprecated

This API is ICU internal only.

Construct a UScriptRun object which iterates over the characters in the given string.

Parameters
text:String

the string of characters over which to iterate.

Annotations
@Deprecated
ICU Status
Internal ICU component.
UScriptRunback to summary
public UScriptRun(String text, int start, int count)

Deprecated

This API is ICU internal only.

Construct a UScriptRun object which iterates over a subrange of the characters in the given string.

Parameters
text:String

the string of characters over which to iterate.

start:int

the index of the first character over which to iterate

count:int

the number of characters over which to iterate

Annotations
@Deprecated
ICU Status
Internal ICU component.
UScriptRunback to summary
public UScriptRun(char[] chars)

Deprecated

This API is ICU internal only.

Construct a UScriptRun object which iterates over the given characters.

Parameters
chars:char[]

the array of characters over which to iterate.

Annotations
@Deprecated
ICU Status
Internal ICU component.
UScriptRunback to summary
public UScriptRun(char[] chars, int start, int count)

Deprecated

This API is ICU internal only.

Construct a UScriptRun object which iterates over a subrange of the given characters.

Parameters
chars:char[]

the array of characters over which to iterate.

start:int

the index of the first character over which to iterate

count:int

the number of characters over which to iterate

Annotations
@Deprecated
ICU Status
Internal ICU component.

Method Detail

decback to summary
private static final int dec(int sp, int count)
decback to summary
private static final int dec(int sp)
fixupback to summary
private final void fixup(int scrptCode)
getPairIndexback to summary
private static int getPairIndex(int ch)

Search the pairedChars array for the given character.

Parameters
ch:int

the character for which to search.

Returns:int

the index of the character in the table, or -1 if it's not there.

getScriptCodeback to summary
public final int getScriptCode()

Deprecated

This API is ICU internal only.

Get the script code for the script of the current script run.

Returns:int

the script code for the script of the current script run.

Annotations
@Deprecated
ICU Status
Internal ICU component.
See Also
com.ibm.icu.lang.UScript
getScriptLimitback to summary
public final int getScriptLimit()

Deprecated

This API is ICU internal only.

Get the index of the first character after the current script run.

Returns:int

the index of the first character after the current script run.

Annotations
@Deprecated
ICU Status
Internal ICU component.
getScriptStartback to summary
public final int getScriptStart()

Deprecated

This API is ICU internal only.

Get the starting index of the current script run.

Returns:int

the index of the first character in the current script run.

Annotations
@Deprecated
ICU Status
Internal ICU component.
highBitback to summary
private static final byte highBit(int n)

Find the highest bit that's set in a word. Uses a binary search through the bits.

Parameters
n:int

the word in which to find the highest bit that's set.

Returns:byte

the bit number (counting from the low order bit) of the highest bit.

incback to summary
private static final int inc(int sp, int count)
incback to summary
private static final int inc(int sp)
limitIncback to summary
private static final int limitInc(int count)
modback to summary
private static final int mod(int sp)
nextback to summary
public final boolean next()

Deprecated

This API is ICU internal only.

Find the next script run. Returns false if there isn't another run, returns true if there is.

Returns:boolean

false if there isn't another run, true if there is.

Annotations
@Deprecated
ICU Status
Internal ICU component.
popback to summary
private final void pop()
pushback to summary
private final void push(int pairIndex, int scrptCode)
resetback to summary
public final void reset()

Deprecated

This API is ICU internal only.

Reset the iterator to the start of the text.

Annotations
@Deprecated
ICU Status
Internal ICU component.
resetback to summary
public final void reset(int start, int count) throws IllegalArgumentException

Deprecated

This API is ICU internal only.

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.

Parameters
start:int

the index of the new first character over which to iterate

count:int

the new number of characters over which to iterate.

Annotations
@Deprecated
Exceptions
IllegalArgumentException:
If invalid arguments are passed.
ICU Status
Internal ICU component.
resetback to summary
public final void reset(char[] chars, int start, int count)

Deprecated

This API is ICU internal only.

Reset the iterator to iterate over count characters in chars starting at start. This allows clients to reuse an iterator.

Parameters
chars:char[]

the new array of characters over which to iterate.

start:int

the index of the first character over which to iterate.

count:int

the number of characters over which to iterate.

Annotations
@Deprecated
ICU Status
Internal ICU component.
resetback to summary
public final void reset(char[] chars)

Deprecated

This API is ICU internal only.

Reset the iterator to iterate over the characters in chars. This allows clients to reuse an iterator.

Parameters
chars:char[]

the new array of characters over which to iterate.

Annotations
@Deprecated
ICU Status
Internal ICU component.
resetback to summary
public final void reset(String str, int start, int count)

Deprecated

This API is ICU internal only.

Reset the iterator to iterate over count characters in text starting at start. This allows clients to reuse an iterator.

Parameters
str:String

the new string of characters over which to iterate.

start:int

the index of the first character over which to iterate.

count:int

the nuber of characters over which to iterate.

Annotations
@Deprecated
ICU Status
Internal ICU component.
resetback to summary
public final void reset(String str)

Deprecated

This API is ICU internal only.

Reset the iterator to iterate over the characters in text. This allows clients to reuse an iterator.

Parameters
str:String

the new string of characters over which to iterate.

Annotations
@Deprecated
ICU Status
Internal ICU component.
sameScriptback to summary
private static boolean sameScript(int scriptOne, int scriptTwo)

Compare two script codes to see if they are in the same script. If one script is a strong script, and the other is INHERITED or COMMON, it will compare equal.

Parameters
scriptOne:int

one of the script codes.

scriptTwo:int

the other script code.

Returns:boolean

true if the two scripts are the same.

See Also
com.ibm.icu.lang.UScript
stackIsEmptyback to summary
private final boolean stackIsEmpty()
stackIsNotEmptyback to summary
private final boolean stackIsNotEmpty()
syncFixupback to summary
private final void syncFixup()
topback to summary
private final UScriptRun.ParenStackEntry top()
com.ibm.icu.lang back to summary

private final Class UScriptRun.ParenStackEntry

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv int

Constructor Summary

AccessConstructor and Description
public
ParenStackEntry(int thePairIndex, int theScriptCode)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

pairIndexback to summary
pack-priv int pairIndex
scriptCodeback to summary
pack-priv int scriptCode

Constructor Detail

ParenStackEntryback to summary
public ParenStackEntry(int thePairIndex, int theScriptCode)