public final class

ScriptRun

extends Object
java.lang.Object
   ↳ sun.font.ScriptRun

Class Overview

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 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)
 {
     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 + ".");
     }
  }
 

Summary

Public Constructors
ScriptRun()
ScriptRun(char[] chars, int start, int count)
Construct a ScriptRun object which iterates over a subrange of the given characetrs.
Public Methods
final int getScriptCode()
Get the script code for the script of the current script run.
final int getScriptLimit()
Get the index of the first character after the current script run.
final int getScriptStart()
Get the starting index of the current script run.
void init(char[] chars, int start, int count)
final boolean next()
Find the next script run.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ScriptRun ()

public ScriptRun (char[] chars, int start, int count)

Construct a ScriptRun object which iterates over a subrange of the given characetrs.

Parameters
chars the 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

Public Methods

public final int getScriptCode ()

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

Returns
  • the script code for the script of the current script run.
See Also
  • #Script

public final int getScriptLimit ()

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

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

public final int getScriptStart ()

Get the starting index of the current script run.

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

public void init (char[] chars, int start, int count)

public final boolean next ()

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

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