1 | /*
|
---|
2 | * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
|
---|
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
---|
4 | *
|
---|
5 | * This code is free software; you can redistribute it and/or modify it
|
---|
6 | * under the terms of the GNU General Public License version 2 only, as
|
---|
7 | * published by the Free Software Foundation. Oracle designates this
|
---|
8 | * particular file as subject to the "Classpath" exception as provided
|
---|
9 | * by Oracle in the LICENSE file that accompanied this code.
|
---|
10 | *
|
---|
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
|
---|
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
---|
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
---|
14 | * version 2 for more details (a copy is included in the LICENSE file that
|
---|
15 | * accompanied this code).
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License version
|
---|
18 | * 2 along with this work; if not, write to the Free Software Foundation,
|
---|
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
---|
20 | *
|
---|
21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
---|
22 | * or visit www.oracle.com if you need additional information or have any
|
---|
23 | * questions.
|
---|
24 | */
|
---|
25 |
|
---|
26 | package java.lang;
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * The CharacterData00 class encapsulates the large tables once found in
|
---|
30 | * java.lang.Character
|
---|
31 | */
|
---|
32 |
|
---|
33 | class CharacterData00 extends CharacterData {
|
---|
34 | /* The character properties are currently encoded into 32 bits in the following manner:
|
---|
35 | 1 bit mirrored property
|
---|
36 | 4 bits directionality property
|
---|
37 | 9 bits signed offset used for converting case
|
---|
38 | 1 bit if 1, adding the signed offset converts the character to lowercase
|
---|
39 | 1 bit if 1, subtracting the signed offset converts the character to uppercase
|
---|
40 | 1 bit if 1, this character has a titlecase equivalent (possibly itself)
|
---|
41 | 3 bits 0 may not be part of an identifier
|
---|
42 | 1 ignorable control; may continue a Unicode identifier or Java identifier
|
---|
43 | 2 may continue a Java identifier but not a Unicode identifier (unused)
|
---|
44 | 3 may continue a Unicode identifier or Java identifier
|
---|
45 | 4 is a Java whitespace character
|
---|
46 | 5 may start or continue a Java identifier;
|
---|
47 | may continue but not start a Unicode identifier (underscores)
|
---|
48 | 6 may start or continue a Java identifier but not a Unicode identifier ($)
|
---|
49 | 7 may start or continue a Unicode identifier or Java identifier
|
---|
50 | Thus:
|
---|
51 | 5, 6, 7 may start a Java identifier
|
---|
52 | 1, 2, 3, 5, 6, 7 may continue a Java identifier
|
---|
53 | 7 may start a Unicode identifier
|
---|
54 | 1, 3, 5, 7 may continue a Unicode identifier
|
---|
55 | 1 is ignorable within an identifier
|
---|
56 | 4 is Java whitespace
|
---|
57 | 2 bits 0 this character has no numeric property
|
---|
58 | 1 adding the digit offset to the character code and then
|
---|
59 | masking with 0x1F will produce the desired numeric value
|
---|
60 | 2 this character has a "strange" numeric value
|
---|
61 | 3 a Java supradecimal digit: adding the digit offset to the
|
---|
62 | character code, then masking with 0x1F, then adding 10
|
---|
63 | will produce the desired numeric value
|
---|
64 | 5 bits digit offset
|
---|
65 | 5 bits character type
|
---|
66 |
|
---|
67 | The encoding of character properties is subject to change at any time.
|
---|
68 | */
|
---|
69 |
|
---|
70 | int getProperties(int ch) {
|
---|
71 | char offset = (char)ch;
|
---|
72 | int props = $$Lookup(offset);
|
---|
73 | return props;
|
---|
74 | }
|
---|
75 |
|
---|
76 | int getType(int ch) {
|
---|
77 | int props = getProperties(ch);
|
---|
78 | return (props & $$maskType);
|
---|
79 | }
|
---|
80 |
|
---|
81 | boolean isJavaIdentifierStart(int ch) {
|
---|
82 | int props = getProperties(ch);
|
---|
83 | return ((props & $$maskIdentifierInfo) >= $$lowJavaStart);
|
---|
84 | }
|
---|
85 |
|
---|
86 | boolean isJavaIdentifierPart(int ch) {
|
---|
87 | int props = getProperties(ch);
|
---|
88 | return ((props & $$nonzeroJavaPart) != 0);
|
---|
89 | }
|
---|
90 |
|
---|
91 | boolean isUnicodeIdentifierStart(int ch) {
|
---|
92 | int props = getProperties(ch);
|
---|
93 | return ((props & $$maskIdentifierInfo) == $$valueUnicodeStart);
|
---|
94 | }
|
---|
95 |
|
---|
96 | boolean isUnicodeIdentifierPart(int ch) {
|
---|
97 | int props = getProperties(ch);
|
---|
98 | return ((props & $$maskUnicodePart) != 0);
|
---|
99 | }
|
---|
100 |
|
---|
101 | boolean isIdentifierIgnorable(int ch) {
|
---|
102 | int props = getProperties(ch);
|
---|
103 | return ((props & $$maskIdentifierInfo) == $$valueIgnorable);
|
---|
104 | }
|
---|
105 |
|
---|
106 | int toLowerCase(int ch) {
|
---|
107 | int mapChar = ch;
|
---|
108 | int val = getProperties(ch);
|
---|
109 |
|
---|
110 | if ((val & $$maskLowerCase) != 0) {
|
---|
111 | if ((val & $$maskCaseOffset) == $$maskCaseOffset) {
|
---|
112 | switch(ch) {
|
---|
113 | // map the offset overflow chars
|
---|
114 | case 0x0130 : mapChar = 0x0069; break;
|
---|
115 | case 0x2126 : mapChar = 0x03C9; break;
|
---|
116 | case 0x212A : mapChar = 0x006B; break;
|
---|
117 | case 0x212B : mapChar = 0x00E5; break;
|
---|
118 | // map the titlecase chars with both a 1:M uppercase map
|
---|
119 | // and a lowercase map
|
---|
120 | case 0x1F88 : mapChar = 0x1F80; break;
|
---|
121 | case 0x1F89 : mapChar = 0x1F81; break;
|
---|
122 | case 0x1F8A : mapChar = 0x1F82; break;
|
---|
123 | case 0x1F8B : mapChar = 0x1F83; break;
|
---|
124 | case 0x1F8C : mapChar = 0x1F84; break;
|
---|
125 | case 0x1F8D : mapChar = 0x1F85; break;
|
---|
126 | case 0x1F8E : mapChar = 0x1F86; break;
|
---|
127 | case 0x1F8F : mapChar = 0x1F87; break;
|
---|
128 | case 0x1F98 : mapChar = 0x1F90; break;
|
---|
129 | case 0x1F99 : mapChar = 0x1F91; break;
|
---|
130 | case 0x1F9A : mapChar = 0x1F92; break;
|
---|
131 | case 0x1F9B : mapChar = 0x1F93; break;
|
---|
132 | case 0x1F9C : mapChar = 0x1F94; break;
|
---|
133 | case 0x1F9D : mapChar = 0x1F95; break;
|
---|
134 | case 0x1F9E : mapChar = 0x1F96; break;
|
---|
135 | case 0x1F9F : mapChar = 0x1F97; break;
|
---|
136 | case 0x1FA8 : mapChar = 0x1FA0; break;
|
---|
137 | case 0x1FA9 : mapChar = 0x1FA1; break;
|
---|
138 | case 0x1FAA : mapChar = 0x1FA2; break;
|
---|
139 | case 0x1FAB : mapChar = 0x1FA3; break;
|
---|
140 | case 0x1FAC : mapChar = 0x1FA4; break;
|
---|
141 | case 0x1FAD : mapChar = 0x1FA5; break;
|
---|
142 | case 0x1FAE : mapChar = 0x1FA6; break;
|
---|
143 | case 0x1FAF : mapChar = 0x1FA7; break;
|
---|
144 | case 0x1FBC : mapChar = 0x1FB3; break;
|
---|
145 | case 0x1FCC : mapChar = 0x1FC3; break;
|
---|
146 | case 0x1FFC : mapChar = 0x1FF3; break;
|
---|
147 | // default mapChar is already set, so no
|
---|
148 | // need to redo it here.
|
---|
149 | // default : mapChar = ch;
|
---|
150 | }
|
---|
151 | }
|
---|
152 | else {
|
---|
153 | int offset = val << $$shiftCaseOffsetSign >> ($$shiftCaseOffsetSign+$$shiftCaseOffset);
|
---|
154 | mapChar = ch + offset;
|
---|
155 | }
|
---|
156 | }
|
---|
157 | return mapChar;
|
---|
158 | }
|
---|
159 |
|
---|
160 | int toUpperCase(int ch) {
|
---|
161 | int mapChar = ch;
|
---|
162 | int val = getProperties(ch);
|
---|
163 |
|
---|
164 | if ((val & $$maskUpperCase) != 0) {
|
---|
165 | if ((val & $$maskCaseOffset) == $$maskCaseOffset) {
|
---|
166 | switch(ch) {
|
---|
167 | // map chars with overflow offsets
|
---|
168 | case 0x00B5 : mapChar = 0x039C; break;
|
---|
169 | case 0x017F : mapChar = 0x0053; break;
|
---|
170 | case 0x1FBE : mapChar = 0x0399; break;
|
---|
171 | // map char that have both a 1:1 and 1:M map
|
---|
172 | case 0x1F80 : mapChar = 0x1F88; break;
|
---|
173 | case 0x1F81 : mapChar = 0x1F89; break;
|
---|
174 | case 0x1F82 : mapChar = 0x1F8A; break;
|
---|
175 | case 0x1F83 : mapChar = 0x1F8B; break;
|
---|
176 | case 0x1F84 : mapChar = 0x1F8C; break;
|
---|
177 | case 0x1F85 : mapChar = 0x1F8D; break;
|
---|
178 | case 0x1F86 : mapChar = 0x1F8E; break;
|
---|
179 | case 0x1F87 : mapChar = 0x1F8F; break;
|
---|
180 | case 0x1F90 : mapChar = 0x1F98; break;
|
---|
181 | case 0x1F91 : mapChar = 0x1F99; break;
|
---|
182 | case 0x1F92 : mapChar = 0x1F9A; break;
|
---|
183 | case 0x1F93 : mapChar = 0x1F9B; break;
|
---|
184 | case 0x1F94 : mapChar = 0x1F9C; break;
|
---|
185 | case 0x1F95 : mapChar = 0x1F9D; break;
|
---|
186 | case 0x1F96 : mapChar = 0x1F9E; break;
|
---|
187 | case 0x1F97 : mapChar = 0x1F9F; break;
|
---|
188 | case 0x1FA0 : mapChar = 0x1FA8; break;
|
---|
189 | case 0x1FA1 : mapChar = 0x1FA9; break;
|
---|
190 | case 0x1FA2 : mapChar = 0x1FAA; break;
|
---|
191 | case 0x1FA3 : mapChar = 0x1FAB; break;
|
---|
192 | case 0x1FA4 : mapChar = 0x1FAC; break;
|
---|
193 | case 0x1FA5 : mapChar = 0x1FAD; break;
|
---|
194 | case 0x1FA6 : mapChar = 0x1FAE; break;
|
---|
195 | case 0x1FA7 : mapChar = 0x1FAF; break;
|
---|
196 | case 0x1FB3 : mapChar = 0x1FBC; break;
|
---|
197 | case 0x1FC3 : mapChar = 0x1FCC; break;
|
---|
198 | case 0x1FF3 : mapChar = 0x1FFC; break;
|
---|
199 | // ch must have a 1:M case mapping, but we
|
---|
200 | // can't handle it here. Return ch.
|
---|
201 | // since mapChar is already set, no need
|
---|
202 | // to redo it here.
|
---|
203 | //default : mapChar = ch;
|
---|
204 | }
|
---|
205 | }
|
---|
206 | else {
|
---|
207 | int offset = val << $$shiftCaseOffsetSign >> ($$shiftCaseOffsetSign+$$shiftCaseOffset);
|
---|
208 | mapChar = ch - offset;
|
---|
209 | }
|
---|
210 | }
|
---|
211 | return mapChar;
|
---|
212 | }
|
---|
213 |
|
---|
214 | int toTitleCase(int ch) {
|
---|
215 | int mapChar = ch;
|
---|
216 | int val = getProperties(ch);
|
---|
217 |
|
---|
218 | if ((val & $$maskTitleCase) != 0) {
|
---|
219 | // There is a titlecase equivalent. Perform further checks:
|
---|
220 | if ((val & $$maskUpperCase) == 0) {
|
---|
221 | // The character does not have an uppercase equivalent, so it must
|
---|
222 | // already be uppercase; so add 1 to get the titlecase form.
|
---|
223 | mapChar = ch + 1;
|
---|
224 | }
|
---|
225 | else if ((val & $$maskLowerCase) == 0) {
|
---|
226 | // The character does not have a lowercase equivalent, so it must
|
---|
227 | // already be lowercase; so subtract 1 to get the titlecase form.
|
---|
228 | mapChar = ch - 1;
|
---|
229 | }
|
---|
230 | // else {
|
---|
231 | // The character has both an uppercase equivalent and a lowercase
|
---|
232 | // equivalent, so it must itself be a titlecase form; return it.
|
---|
233 | // return ch;
|
---|
234 | //}
|
---|
235 | }
|
---|
236 | else if ((val & $$maskUpperCase) != 0) {
|
---|
237 | // This character has no titlecase equivalent but it does have an
|
---|
238 | // uppercase equivalent, so use that (subtract the signed case offset).
|
---|
239 | mapChar = toUpperCase(ch);
|
---|
240 | }
|
---|
241 | return mapChar;
|
---|
242 | }
|
---|
243 |
|
---|
244 | int digit(int ch, int radix) {
|
---|
245 | int value = -1;
|
---|
246 | if (radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX) {
|
---|
247 | int val = getProperties(ch);
|
---|
248 | int kind = val & $$maskType;
|
---|
249 | if (kind == Character.DECIMAL_DIGIT_NUMBER) {
|
---|
250 | value = ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit;
|
---|
251 | }
|
---|
252 | else if ((val & $$maskNumericType) == $$valueJavaSupradecimal) {
|
---|
253 | // Java supradecimal digit
|
---|
254 | value = (ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit) + 10;
|
---|
255 | }
|
---|
256 | }
|
---|
257 | return (value < radix) ? value : -1;
|
---|
258 | }
|
---|
259 |
|
---|
260 | int getNumericValue(int ch) {
|
---|
261 | int val = getProperties(ch);
|
---|
262 | int retval = -1;
|
---|
263 |
|
---|
264 | switch (val & $$maskNumericType) {
|
---|
265 | default: // cannot occur
|
---|
266 | case ($$valueNotNumeric): // not numeric
|
---|
267 | retval = -1;
|
---|
268 | break;
|
---|
269 | case ($$valueDigit): // simple numeric
|
---|
270 | retval = ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit;
|
---|
271 | break;
|
---|
272 | case ($$valueStrangeNumeric) : // "strange" numeric
|
---|
273 | switch (ch) {
|
---|
274 | case 0x0BF1: retval = 100; break; // TAMIL NUMBER ONE HUNDRED
|
---|
275 | case 0x0BF2: retval = 1000; break; // TAMIL NUMBER ONE THOUSAND
|
---|
276 | case 0x1375: retval = 40; break; // ETHIOPIC NUMBER FORTY
|
---|
277 | case 0x1376: retval = 50; break; // ETHIOPIC NUMBER FIFTY
|
---|
278 | case 0x1377: retval = 60; break; // ETHIOPIC NUMBER SIXTY
|
---|
279 | case 0x1378: retval = 70; break; // ETHIOPIC NUMBER SEVENTY
|
---|
280 | case 0x1379: retval = 80; break; // ETHIOPIC NUMBER EIGHTY
|
---|
281 | case 0x137A: retval = 90; break; // ETHIOPIC NUMBER NINETY
|
---|
282 | case 0x137B: retval = 100; break; // ETHIOPIC NUMBER HUNDRED
|
---|
283 | case 0x137C: retval = 10000; break; // ETHIOPIC NUMBER TEN THOUSAND
|
---|
284 | case 0x215F: retval = 1; break; // FRACTION NUMERATOR ONE
|
---|
285 | case 0x216C: retval = 50; break; // ROMAN NUMERAL FIFTY
|
---|
286 | case 0x216D: retval = 100; break; // ROMAN NUMERAL ONE HUNDRED
|
---|
287 | case 0x216E: retval = 500; break; // ROMAN NUMERAL FIVE HUNDRED
|
---|
288 | case 0x216F: retval = 1000; break; // ROMAN NUMERAL ONE THOUSAND
|
---|
289 | case 0x217C: retval = 50; break; // SMALL ROMAN NUMERAL FIFTY
|
---|
290 | case 0x217D: retval = 100; break; // SMALL ROMAN NUMERAL ONE HUNDRED
|
---|
291 | case 0x217E: retval = 500; break; // SMALL ROMAN NUMERAL FIVE HUNDRED
|
---|
292 | case 0x217F: retval = 1000; break; // SMALL ROMAN NUMERAL ONE THOUSAND
|
---|
293 | case 0x2180: retval = 1000; break; // ROMAN NUMERAL ONE THOUSAND C D
|
---|
294 | case 0x2181: retval = 5000; break; // ROMAN NUMERAL FIVE THOUSAND
|
---|
295 | case 0x2182: retval = 10000; break; // ROMAN NUMERAL TEN THOUSAND
|
---|
296 |
|
---|
297 | case 0x325C: retval = 32; break;
|
---|
298 |
|
---|
299 | case 0x325D: retval = 33; break; // CIRCLED NUMBER THIRTY THREE
|
---|
300 | case 0x325E: retval = 34; break; // CIRCLED NUMBER THIRTY FOUR
|
---|
301 | case 0x325F: retval = 35; break; // CIRCLED NUMBER THIRTY FIVE
|
---|
302 | case 0x32B1: retval = 36; break; // CIRCLED NUMBER THIRTY SIX
|
---|
303 | case 0x32B2: retval = 37; break; // CIRCLED NUMBER THIRTY SEVEN
|
---|
304 | case 0x32B3: retval = 38; break; // CIRCLED NUMBER THIRTY EIGHT
|
---|
305 | case 0x32B4: retval = 39; break; // CIRCLED NUMBER THIRTY NINE
|
---|
306 | case 0x32B5: retval = 40; break; // CIRCLED NUMBER FORTY
|
---|
307 | case 0x32B6: retval = 41; break; // CIRCLED NUMBER FORTY ONE
|
---|
308 | case 0x32B7: retval = 42; break; // CIRCLED NUMBER FORTY TWO
|
---|
309 | case 0x32B8: retval = 43; break; // CIRCLED NUMBER FORTY THREE
|
---|
310 | case 0x32B9: retval = 44; break; // CIRCLED NUMBER FORTY FOUR
|
---|
311 | case 0x32BA: retval = 45; break; // CIRCLED NUMBER FORTY FIVE
|
---|
312 | case 0x32BB: retval = 46; break; // CIRCLED NUMBER FORTY SIX
|
---|
313 | case 0x32BC: retval = 47; break; // CIRCLED NUMBER FORTY SEVEN
|
---|
314 | case 0x32BD: retval = 48; break; // CIRCLED NUMBER FORTY EIGHT
|
---|
315 | case 0x32BE: retval = 49; break; // CIRCLED NUMBER FORTY NINE
|
---|
316 | case 0x32BF: retval = 50; break; // CIRCLED NUMBER FIFTY
|
---|
317 |
|
---|
318 | default: retval = -2; break;
|
---|
319 | }
|
---|
320 | break;
|
---|
321 | case ($$valueJavaSupradecimal): // Java supradecimal
|
---|
322 | retval = (ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit) + 10;
|
---|
323 | break;
|
---|
324 | }
|
---|
325 | return retval;
|
---|
326 | }
|
---|
327 |
|
---|
328 | boolean isWhitespace(int ch) {
|
---|
329 | int props = getProperties(ch);
|
---|
330 | return ((props & $$maskIdentifierInfo) == $$valueJavaWhitespace);
|
---|
331 | }
|
---|
332 |
|
---|
333 | byte getDirectionality(int ch) {
|
---|
334 | int val = getProperties(ch);
|
---|
335 | byte directionality = (byte)((val & $$maskBidi) >> $$shiftBidi);
|
---|
336 | if (directionality == 0xF ) {
|
---|
337 | switch(ch) {
|
---|
338 | case 0x202A :
|
---|
339 | // This is the only char with LRE
|
---|
340 | directionality = Character.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING;
|
---|
341 | break;
|
---|
342 | case 0x202B :
|
---|
343 | // This is the only char with RLE
|
---|
344 | directionality = Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING;
|
---|
345 | break;
|
---|
346 | case 0x202C :
|
---|
347 | // This is the only char with PDF
|
---|
348 | directionality = Character.DIRECTIONALITY_POP_DIRECTIONAL_FORMAT;
|
---|
349 | break;
|
---|
350 | case 0x202D :
|
---|
351 | // This is the only char with LRO
|
---|
352 | directionality = Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE;
|
---|
353 | break;
|
---|
354 | case 0x202E :
|
---|
355 | // This is the only char with RLO
|
---|
356 | directionality = Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE;
|
---|
357 | break;
|
---|
358 | default :
|
---|
359 | directionality = Character.DIRECTIONALITY_UNDEFINED;
|
---|
360 | break;
|
---|
361 | }
|
---|
362 | }
|
---|
363 | return directionality;
|
---|
364 | }
|
---|
365 |
|
---|
366 | boolean isMirrored(int ch) {
|
---|
367 | int props = getProperties(ch);
|
---|
368 | return ((props & $$maskMirrored) != 0);
|
---|
369 | }
|
---|
370 |
|
---|
371 | int toUpperCaseEx(int ch) {
|
---|
372 | int mapChar = ch;
|
---|
373 | int val = getProperties(ch);
|
---|
374 |
|
---|
375 | if ((val & $$maskUpperCase) != 0) {
|
---|
376 | if ((val & $$maskCaseOffset) != $$maskCaseOffset) {
|
---|
377 | int offset = val << $$shiftCaseOffsetSign >> ($$shiftCaseOffsetSign+$$shiftCaseOffset);
|
---|
378 | mapChar = ch - offset;
|
---|
379 | }
|
---|
380 | else {
|
---|
381 | switch(ch) {
|
---|
382 | // map overflow characters
|
---|
383 | case 0x00B5 : mapChar = 0x039C; break;
|
---|
384 | case 0x017F : mapChar = 0x0053; break;
|
---|
385 | case 0x1FBE : mapChar = 0x0399; break;
|
---|
386 | default : mapChar = Character.ERROR; break;
|
---|
387 | }
|
---|
388 | }
|
---|
389 | }
|
---|
390 | return mapChar;
|
---|
391 | }
|
---|
392 |
|
---|
393 | char[] toUpperCaseCharArray(int ch) {
|
---|
394 | char[] upperMap = {(char)ch};
|
---|
395 | int location = findInCharMap(ch);
|
---|
396 | if (location != -1) {
|
---|
397 | upperMap = charMap[location][1];
|
---|
398 | }
|
---|
399 | return upperMap;
|
---|
400 | }
|
---|
401 |
|
---|
402 |
|
---|
403 | /**
|
---|
404 | * Finds the character in the uppercase mapping table.
|
---|
405 | *
|
---|
406 | * @param ch the <code>char</code> to search
|
---|
407 | * @return the index location ch in the table or -1 if not found
|
---|
408 | * @since 1.4
|
---|
409 | */
|
---|
410 | int findInCharMap(int ch) {
|
---|
411 | if (charMap == null || charMap.length == 0) {
|
---|
412 | return -1;
|
---|
413 | }
|
---|
414 | int top, bottom, current;
|
---|
415 | bottom = 0;
|
---|
416 | top = charMap.length;
|
---|
417 | current = top/2;
|
---|
418 | // invariant: top > current >= bottom && ch >= CharacterData.charMap[bottom][0]
|
---|
419 | while (top - bottom > 1) {
|
---|
420 | if (ch >= charMap[current][0][0]) {
|
---|
421 | bottom = current;
|
---|
422 | } else {
|
---|
423 | top = current;
|
---|
424 | }
|
---|
425 | current = (top + bottom) / 2;
|
---|
426 | }
|
---|
427 | if (ch == charMap[current][0][0]) return current;
|
---|
428 | else return -1;
|
---|
429 | }
|
---|
430 |
|
---|
431 | static final CharacterData00 instance = new CharacterData00();
|
---|
432 | private CharacterData00() {};
|
---|
433 |
|
---|
434 | $$Tables
|
---|
435 |
|
---|
436 | static {
|
---|
437 | $$Initializers
|
---|
438 | }
|
---|
439 | }
|
---|