ScriptRun is used to find runs of characters in
the same script, as defined in the Script 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)
{
ScriptRun scriptRun = new ScriptRun(text, 0, text.length);
while (scriptRun.next()) {
int start = scriptRun.getScriptStart();
int limit = scriptRun.getScriptLimit();
int script = scriptRun.getScriptCode();
System.out.println("Script \"" + Script.getName(script) + "\" from " +
start + " to " + limit + ".");
}
}
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| private static final int | |
| private static final int | |
| private static int[] | |
| private int | |
| private int | |
| private int | |
| private int | |
| private int[] | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| private char[] | |
| private int | |
| private int |
| Access | Constructor and Description |
|---|---|
| public | |
| public | ScriptRun(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)Construct a |
| Modifier and Type | Method and Description |
|---|---|
| private static int | Returns: the index of the character in the table, or -1 if it's not there.the character for which to search. ch)Search the pairedChars array for the given character. |
| public int | Returns: the script code for the script of the current script run.Get the script code for the script of the current script run. |
| public int | Returns: the index of the first character after the current script run.Get the index of the first character after the current script run. |
| public int | Returns: the index of the first character in the current script run.Get the starting index of the current script run. |
| private static byte | Returns: the bit number (counting from the low order bit) of the highest bit.the word in which to find the highest bit that's set. n)Find the highest bit that's set in a word. |
| public void | |
| public boolean | |
| private int | |
| private void | |
| private static boolean | Returns: true if the two scripts are the same.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. |
| DONE | back to summary |
|---|---|
| pack-priv static final int DONE | |
| LEAD_LIMIT | back to summary |
|---|---|
| pack-priv static final int LEAD_LIMIT | |
| LEAD_START | back to summary |
|---|---|
| pack-priv static final int LEAD_START | |
| LEAD_SURROGATE_SHIFT | back to summary |
|---|---|
| pack-priv static final int LEAD_SURROGATE_SHIFT | |
| pairedCharExtra | back to summary |
|---|---|
| private static final int pairedCharExtra | |
| pairedCharPower | back to summary |
|---|---|
| private static final int pairedCharPower | |
| pairedChars | back to summary |
|---|---|
| private static int[] pairedChars | |
| parenSP | back to summary |
|---|---|
| private int parenSP | |
| scriptCode | back to summary |
|---|---|
| private int scriptCode | |
| scriptLimit | back to summary |
|---|---|
| private int scriptLimit | |
| scriptStart | back to summary |
|---|---|
| private int scriptStart | |
| stack | back to summary |
|---|---|
| private int[] stack | |
| SURROGATE_OFFSET | back to summary |
|---|---|
| pack-priv static final int SURROGATE_OFFSET | |
| SURROGATE_START | back to summary |
|---|---|
| pack-priv static final int SURROGATE_START | |
| TAIL_LIMIT | back to summary |
|---|---|
| pack-priv static final int TAIL_LIMIT | |
| TAIL_START | back to summary |
|---|---|
| pack-priv static final int TAIL_START | |
| text | back to summary |
|---|---|
| private char[] text | |
| textLimit | back to summary |
|---|---|
| private int textLimit | |
| textStart | back to summary |
|---|---|
| private int textStart | |
| ScriptRun | back to summary |
|---|---|
| public ScriptRun() | |
| ScriptRun | back to summary |
|---|---|
| public ScriptRun(char[] chars, int start, int count) Construct a
| |
| getPairIndex | back to summary |
|---|---|
| private static int getPairIndex(int ch) Search the pairedChars array for the given character.
| |
| getScriptCode | back to summary |
|---|---|
| public int getScriptCode() Get the script code for the script of the current script run.
| |
| getScriptLimit | back to summary |
|---|---|
| public int getScriptLimit() Get the index of the first character after the current script run.
| |
| getScriptStart | back to summary |
|---|---|
| public int getScriptStart() Get the starting index of the current script run.
| |
| highBit | back to summary |
|---|---|
| private static byte highBit(int n) Find the highest bit that's set in a word. Uses a binary search through the bits.
| |
| init | back to summary |
|---|---|
| public void init(char[] chars, int start, int count) | |
| next | back to summary |
|---|---|
| public boolean next() Find the next script run. Returns
| |
| nextCodePoint | back to summary |
|---|---|
| private int nextCodePoint() | |
| pushback | back to summary |
|---|---|
| private void pushback(int ch) | |
| sameScript | back 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.
| |