121 *
122 * @return the index of the first character in the current script run.
123 */
124 public int getScriptStart() {
125 return scriptStart;
126 }
127
128 /**
129 * Get the index of the first character after the current script run.
130 *
131 * @return the index of the first character after the current script run.
132 */
133 public int getScriptLimit() {
134 return scriptLimit;
135 }
136
137 /**
138 * Get the script code for the script of the current script run.
139 *
140 * @return the script code for the script of the current script run.
141 * @see #Script
142 */
143 public int getScriptCode() {
144 return scriptCode;
145 }
146
147 /**
148 * Find the next script run. Returns <code>false</code> if there
149 * isn't another run, returns <code>true</code> if there is.
150 *
151 * @return <code>false</code> if there isn't another run, <code>true</code> if there is.
152 */
153 public boolean next() {
154 int startSP = parenSP; // used to find the first new open character
155
156 // if we've fallen off the end of the text, we're done
157 if (scriptLimit >= textLimit) {
158 return false;
159 }
160
161 scriptCode = Script.COMMON;
257 return ch;
258 }
259
260 private void pushback(int ch) {
261 if (ch >= 0) {
262 if (ch >= 0x10000) {
263 scriptLimit -= 2;
264 } else {
265 scriptLimit -= 1;
266 }
267 }
268 }
269
270 /**
271 * Compare two script codes to see if they are in the same script. If one script is
272 * a strong script, and the other is INHERITED or COMMON, it will compare equal.
273 *
274 * @param scriptOne one of the script codes.
275 * @param scriptTwo the other script code.
276 * @return <code>true</code> if the two scripts are the same.
277 * @see com.ibm.icu.lang.Script
278 */
279 private static boolean sameScript(int scriptOne, int scriptTwo) {
280 return scriptOne == scriptTwo || scriptOne <= Script.INHERITED || scriptTwo <= Script.INHERITED;
281 }
282
283 /**
284 * Find the highest bit that's set in a word. Uses a binary search through
285 * the bits.
286 *
287 * @param n the word in which to find the highest bit that's set.
288 * @return the bit number (counting from the low order bit) of the highest bit.
289 */
290 private static byte highBit(int n)
291 {
292 if (n <= 0) {
293 return -32;
294 }
295
296 byte bit = 0;
297
|
121 *
122 * @return the index of the first character in the current script run.
123 */
124 public int getScriptStart() {
125 return scriptStart;
126 }
127
128 /**
129 * Get the index of the first character after the current script run.
130 *
131 * @return the index of the first character after the current script run.
132 */
133 public int getScriptLimit() {
134 return scriptLimit;
135 }
136
137 /**
138 * Get the script code for the script of the current script run.
139 *
140 * @return the script code for the script of the current script run.
141 * @see Script
142 */
143 public int getScriptCode() {
144 return scriptCode;
145 }
146
147 /**
148 * Find the next script run. Returns <code>false</code> if there
149 * isn't another run, returns <code>true</code> if there is.
150 *
151 * @return <code>false</code> if there isn't another run, <code>true</code> if there is.
152 */
153 public boolean next() {
154 int startSP = parenSP; // used to find the first new open character
155
156 // if we've fallen off the end of the text, we're done
157 if (scriptLimit >= textLimit) {
158 return false;
159 }
160
161 scriptCode = Script.COMMON;
257 return ch;
258 }
259
260 private void pushback(int ch) {
261 if (ch >= 0) {
262 if (ch >= 0x10000) {
263 scriptLimit -= 2;
264 } else {
265 scriptLimit -= 1;
266 }
267 }
268 }
269
270 /**
271 * Compare two script codes to see if they are in the same script. If one script is
272 * a strong script, and the other is INHERITED or COMMON, it will compare equal.
273 *
274 * @param scriptOne one of the script codes.
275 * @param scriptTwo the other script code.
276 * @return <code>true</code> if the two scripts are the same.
277 * @see Script
278 */
279 private static boolean sameScript(int scriptOne, int scriptTwo) {
280 return scriptOne == scriptTwo || scriptOne <= Script.INHERITED || scriptTwo <= Script.INHERITED;
281 }
282
283 /**
284 * Find the highest bit that's set in a word. Uses a binary search through
285 * the bits.
286 *
287 * @param n the word in which to find the highest bit that's set.
288 * @return the bit number (counting from the low order bit) of the highest bit.
289 */
290 private static byte highBit(int n)
291 {
292 if (n <= 0) {
293 return -32;
294 }
295
296 byte bit = 0;
297
|