CharacterData00.java.template 26.6 KB
Newer Older
D
duke 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
/*
 * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Sun designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Sun in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 * CA 95054 USA or visit www.sun.com if you need additional information or
 * have any questions.
 */

package java.lang;

/** 
 * The CharacterData00 class encapsulates the large tables once found in
 * java.lang.Character
*/

class CharacterData00 extends CharacterData {
    /* The character properties are currently encoded into 32 bits in the following manner:
        1 bit   mirrored property
        4 bits  directionality property
        9 bits  signed offset used for converting case
        1 bit   if 1, adding the signed offset converts the character to lowercase
        1 bit   if 1, subtracting the signed offset converts the character to uppercase
        1 bit   if 1, this character has a titlecase equivalent (possibly itself)
        3 bits  0  may not be part of an identifier
                1  ignorable control; may continue a Unicode identifier or Java identifier
                2  may continue a Java identifier but not a Unicode identifier (unused)
                3  may continue a Unicode identifier or Java identifier
                4  is a Java whitespace character
                5  may start or continue a Java identifier;
                   may continue but not start a Unicode identifier (underscores)
                6  may start or continue a Java identifier but not a Unicode identifier ($)
                7  may start or continue a Unicode identifier or Java identifier
                Thus:
                   5, 6, 7 may start a Java identifier
                   1, 2, 3, 5, 6, 7 may continue a Java identifier
                   7 may start a Unicode identifier
                   1, 3, 5, 7 may continue a Unicode identifier
                   1 is ignorable within an identifier
                   4 is Java whitespace
        2 bits  0  this character has no numeric property
                1  adding the digit offset to the character code and then
                   masking with 0x1F will produce the desired numeric value
                2  this character has a "strange" numeric value
                3  a Java supradecimal digit: adding the digit offset to the
                   character code, then masking with 0x1F, then adding 10
                   will produce the desired numeric value
        5 bits  digit offset
        5 bits  character type

        The encoding of character properties is subject to change at any time.
     */

    int getProperties(int ch) {
        char offset = (char)ch;
        int props = $$Lookup(offset);
        return props;
    }

    int getType(int ch) {
        int props = getProperties(ch);
        return (props & $$maskType);
    }

    boolean isJavaIdentifierStart(int ch) {
        int props = getProperties(ch);
        return ((props & $$maskIdentifierInfo) >= $$lowJavaStart);
    }

    boolean isJavaIdentifierPart(int ch) {
        int props = getProperties(ch);
        return ((props & $$nonzeroJavaPart) != 0);
    }

    boolean isUnicodeIdentifierStart(int ch) {
        int props = getProperties(ch);
        return ((props & $$maskIdentifierInfo) == $$valueUnicodeStart);
    }

    boolean isUnicodeIdentifierPart(int ch) {
        int props = getProperties(ch);
        return ((props & $$maskUnicodePart) != 0);
    }

    boolean isIdentifierIgnorable(int ch) {
        int props = getProperties(ch);
        return ((props & $$maskIdentifierInfo) == $$valueIgnorable);
    }

    int toLowerCase(int ch) {
        int mapChar = ch;
        int val = getProperties(ch);

        if ((val & $$maskLowerCase) != 0) {
          if ((val & $$maskCaseOffset) == $$maskCaseOffset) {
            switch(ch) {
              // map the offset overflow chars
			case 0x0130 : mapChar = 0x0069; break;
            case 0x2126 : mapChar = 0x03C9; break;
            case 0x212A : mapChar = 0x006B; break;
            case 0x212B : mapChar = 0x00E5; break;
              // map the titlecase chars with both a 1:M uppercase map
              // and a lowercase map
            case 0x1F88 : mapChar = 0x1F80; break;
            case 0x1F89 : mapChar = 0x1F81; break;
            case 0x1F8A : mapChar = 0x1F82; break;
            case 0x1F8B : mapChar = 0x1F83; break;
            case 0x1F8C : mapChar = 0x1F84; break;
            case 0x1F8D : mapChar = 0x1F85; break;
            case 0x1F8E : mapChar = 0x1F86; break;
            case 0x1F8F : mapChar = 0x1F87; break;
            case 0x1F98 : mapChar = 0x1F90; break;
            case 0x1F99 : mapChar = 0x1F91; break;
            case 0x1F9A : mapChar = 0x1F92; break;
            case 0x1F9B : mapChar = 0x1F93; break;
            case 0x1F9C : mapChar = 0x1F94; break;
            case 0x1F9D : mapChar = 0x1F95; break;
            case 0x1F9E : mapChar = 0x1F96; break;
            case 0x1F9F : mapChar = 0x1F97; break;
            case 0x1FA8 : mapChar = 0x1FA0; break;
            case 0x1FA9 : mapChar = 0x1FA1; break;
            case 0x1FAA : mapChar = 0x1FA2; break;
            case 0x1FAB : mapChar = 0x1FA3; break;
            case 0x1FAC : mapChar = 0x1FA4; break;
            case 0x1FAD : mapChar = 0x1FA5; break;
            case 0x1FAE : mapChar = 0x1FA6; break;
            case 0x1FAF : mapChar = 0x1FA7; break;
            case 0x1FBC : mapChar = 0x1FB3; break;
            case 0x1FCC : mapChar = 0x1FC3; break;
            case 0x1FFC : mapChar = 0x1FF3; break;
P
peytoia 已提交
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195

            case 0x023A : mapChar = 0x2C65; break;
            case 0x023E : mapChar = 0x2C66; break;
            case 0x10A0 : mapChar = 0x2D00; break;
            case 0x10A1 : mapChar = 0x2D01; break;
            case 0x10A2 : mapChar = 0x2D02; break;
            case 0x10A3 : mapChar = 0x2D03; break;
            case 0x10A4 : mapChar = 0x2D04; break;
            case 0x10A5 : mapChar = 0x2D05; break;
            case 0x10A6 : mapChar = 0x2D06; break;
            case 0x10A7 : mapChar = 0x2D07; break;
            case 0x10A8 : mapChar = 0x2D08; break;
            case 0x10A9 : mapChar = 0x2D09; break;
            case 0x10AA : mapChar = 0x2D0A; break;
            case 0x10AB : mapChar = 0x2D0B; break;
            case 0x10AC : mapChar = 0x2D0C; break;
            case 0x10AD : mapChar = 0x2D0D; break;
            case 0x10AE : mapChar = 0x2D0E; break;
            case 0x10AF : mapChar = 0x2D0F; break;
            case 0x10B0 : mapChar = 0x2D10; break;
            case 0x10B1 : mapChar = 0x2D11; break;
            case 0x10B2 : mapChar = 0x2D12; break;
            case 0x10B3 : mapChar = 0x2D13; break;
            case 0x10B4 : mapChar = 0x2D14; break;
            case 0x10B5 : mapChar = 0x2D15; break;
            case 0x10B6 : mapChar = 0x2D16; break;
            case 0x10B7 : mapChar = 0x2D17; break;
            case 0x10B8 : mapChar = 0x2D18; break;
            case 0x10B9 : mapChar = 0x2D19; break;
            case 0x10BA : mapChar = 0x2D1A; break;
            case 0x10BB : mapChar = 0x2D1B; break;
            case 0x10BC : mapChar = 0x2D1C; break;
            case 0x10BD : mapChar = 0x2D1D; break;
            case 0x10BE : mapChar = 0x2D1E; break;
            case 0x10BF : mapChar = 0x2D1F; break;
            case 0x10C0 : mapChar = 0x2D20; break;
            case 0x10C1 : mapChar = 0x2D21; break;
            case 0x10C2 : mapChar = 0x2D22; break;
            case 0x10C3 : mapChar = 0x2D23; break;
            case 0x10C4 : mapChar = 0x2D24; break;
            case 0x10C5 : mapChar = 0x2D25; break;
            case 0x1E9E : mapChar = 0x00DF; break;
            case 0x2C62 : mapChar = 0x026B; break;
            case 0x2C63 : mapChar = 0x1D7D; break;
            case 0x2C64 : mapChar = 0x027D; break;
            case 0x2C6D : mapChar = 0x0251; break;
            case 0x2C6E : mapChar = 0x0271; break;
            case 0x2C6F : mapChar = 0x0250; break;
            case 0xA77D : mapChar = 0x1D79; break;
D
duke 已提交
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
              // default mapChar is already set, so no
              // need to redo it here.
              // default       : mapChar = ch;
            }
          }
          else {
            int offset = val << $$shiftCaseOffsetSign >> ($$shiftCaseOffsetSign+$$shiftCaseOffset);
            mapChar = ch + offset;
          }
        }
        return mapChar;
    }

    int toUpperCase(int ch) {
        int mapChar = ch;
        int val = getProperties(ch);

        if ((val & $$maskUpperCase) != 0) {
          if ((val & $$maskCaseOffset) == $$maskCaseOffset) {
            switch(ch) {
              // map chars with overflow offsets
            case 0x00B5 : mapChar = 0x039C; break;
            case 0x017F : mapChar = 0x0053; break;
            case 0x1FBE : mapChar = 0x0399; break;
              // map char that have both a 1:1 and 1:M map
            case 0x1F80 : mapChar = 0x1F88; break;
            case 0x1F81 : mapChar = 0x1F89; break;
            case 0x1F82 : mapChar = 0x1F8A; break;
            case 0x1F83 : mapChar = 0x1F8B; break;
            case 0x1F84 : mapChar = 0x1F8C; break;
            case 0x1F85 : mapChar = 0x1F8D; break;
            case 0x1F86 : mapChar = 0x1F8E; break;
            case 0x1F87 : mapChar = 0x1F8F; break;
            case 0x1F90 : mapChar = 0x1F98; break;
            case 0x1F91 : mapChar = 0x1F99; break;
            case 0x1F92 : mapChar = 0x1F9A; break;
            case 0x1F93 : mapChar = 0x1F9B; break;
            case 0x1F94 : mapChar = 0x1F9C; break;
            case 0x1F95 : mapChar = 0x1F9D; break;
            case 0x1F96 : mapChar = 0x1F9E; break;
            case 0x1F97 : mapChar = 0x1F9F; break;
            case 0x1FA0 : mapChar = 0x1FA8; break;
            case 0x1FA1 : mapChar = 0x1FA9; break;
            case 0x1FA2 : mapChar = 0x1FAA; break;
            case 0x1FA3 : mapChar = 0x1FAB; break;
            case 0x1FA4 : mapChar = 0x1FAC; break;
            case 0x1FA5 : mapChar = 0x1FAD; break;
            case 0x1FA6 : mapChar = 0x1FAE; break;
            case 0x1FA7 : mapChar = 0x1FAF; break;
            case 0x1FB3 : mapChar = 0x1FBC; break;
            case 0x1FC3 : mapChar = 0x1FCC; break;
            case 0x1FF3 : mapChar = 0x1FFC; break;
P
peytoia 已提交
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295

            case 0x0250 : mapChar = 0x2C6F; break;
            case 0x0251 : mapChar = 0x2C6D; break;
            case 0x026B : mapChar = 0x2C62; break;
            case 0x0271 : mapChar = 0x2C6E; break;
            case 0x027D : mapChar = 0x2C64; break;
            case 0x1D79 : mapChar = 0xA77D; break;
            case 0x1D7D : mapChar = 0x2C63; break;
            case 0x2C65 : mapChar = 0x023A; break;
            case 0x2C66 : mapChar = 0x023E; break;
            case 0x2D00 : mapChar = 0x10A0; break;
            case 0x2D01 : mapChar = 0x10A1; break;
            case 0x2D02 : mapChar = 0x10A2; break;
            case 0x2D03 : mapChar = 0x10A3; break;
            case 0x2D04 : mapChar = 0x10A4; break;
            case 0x2D05 : mapChar = 0x10A5; break;
            case 0x2D06 : mapChar = 0x10A6; break;
            case 0x2D07 : mapChar = 0x10A7; break;
            case 0x2D08 : mapChar = 0x10A8; break;
            case 0x2D09 : mapChar = 0x10A9; break;
            case 0x2D0A : mapChar = 0x10AA; break;
            case 0x2D0B : mapChar = 0x10AB; break;
            case 0x2D0C : mapChar = 0x10AC; break;
            case 0x2D0D : mapChar = 0x10AD; break;
            case 0x2D0E : mapChar = 0x10AE; break;
            case 0x2D0F : mapChar = 0x10AF; break;
            case 0x2D10 : mapChar = 0x10B0; break;
            case 0x2D11 : mapChar = 0x10B1; break;
            case 0x2D12 : mapChar = 0x10B2; break;
            case 0x2D13 : mapChar = 0x10B3; break;
            case 0x2D14 : mapChar = 0x10B4; break;
            case 0x2D15 : mapChar = 0x10B5; break;
            case 0x2D16 : mapChar = 0x10B6; break;
            case 0x2D17 : mapChar = 0x10B7; break;
            case 0x2D18 : mapChar = 0x10B8; break;
            case 0x2D19 : mapChar = 0x10B9; break;
            case 0x2D1A : mapChar = 0x10BA; break;
            case 0x2D1B : mapChar = 0x10BB; break;
            case 0x2D1C : mapChar = 0x10BC; break;
            case 0x2D1D : mapChar = 0x10BD; break;
            case 0x2D1E : mapChar = 0x10BE; break;
            case 0x2D1F : mapChar = 0x10BF; break;
            case 0x2D20 : mapChar = 0x10C0; break;
            case 0x2D21 : mapChar = 0x10C1; break;
            case 0x2D22 : mapChar = 0x10C2; break;
            case 0x2D23 : mapChar = 0x10C3; break;
            case 0x2D24 : mapChar = 0x10C4; break;
            case 0x2D25 : mapChar = 0x10C5; break;
D
duke 已提交
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
              // ch must have a 1:M case mapping, but we
              // can't handle it here. Return ch.
              // since mapChar is already set, no need
              // to redo it here.
              //default       : mapChar = ch;
            }
          }
          else {
            int offset = val  << $$shiftCaseOffsetSign >> ($$shiftCaseOffsetSign+$$shiftCaseOffset);
            mapChar =  ch - offset;
          }
        }
        return mapChar;
    }

    int toTitleCase(int ch) {
        int mapChar = ch;
        int val = getProperties(ch);

        if ((val & $$maskTitleCase) != 0) {
            // There is a titlecase equivalent.  Perform further checks:
            if ((val & $$maskUpperCase) == 0) {
                // The character does not have an uppercase equivalent, so it must
                // already be uppercase; so add 1 to get the titlecase form.
                mapChar = ch + 1;
            }
            else if ((val & $$maskLowerCase) == 0) {
                // The character does not have a lowercase equivalent, so it must
                // already be lowercase; so subtract 1 to get the titlecase form.
                mapChar = ch - 1;
            }
            // else {
            // The character has both an uppercase equivalent and a lowercase
            // equivalent, so it must itself be a titlecase form; return it.
            // return ch;
            //}
        }
        else if ((val & $$maskUpperCase) != 0) {
            // This character has no titlecase equivalent but it does have an
            // uppercase equivalent, so use that (subtract the signed case offset).
            mapChar = toUpperCase(ch);
        }
        return mapChar;
    }

    int digit(int ch, int radix) {
        int value = -1;
        if (radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX) {
            int val = getProperties(ch);
            int kind = val & $$maskType;
            if (kind == Character.DECIMAL_DIGIT_NUMBER) {
                value = ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit;
            }
            else if ((val & $$maskNumericType) == $$valueJavaSupradecimal) {
                // Java supradecimal digit
                value = (ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit) + 10;
            }
        }
        return (value < radix) ? value : -1;
    }

    int getNumericValue(int ch) {
        int val = getProperties(ch);
        int retval = -1;

        switch (val & $$maskNumericType) {
        default: // cannot occur
        case ($$valueNotNumeric):         // not numeric
            retval = -1;
            break;
        case ($$valueDigit):              // simple numeric
            retval = ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit;
            break;
        case ($$valueStrangeNumeric)      :       // "strange" numeric
            switch (ch) {
                case 0x0BF1: retval = 100; break;         // TAMIL NUMBER ONE HUNDRED
                case 0x0BF2: retval = 1000; break;        // TAMIL NUMBER ONE THOUSAND
                case 0x1375: retval = 40; break;          // ETHIOPIC NUMBER FORTY
                case 0x1376: retval = 50; break;          // ETHIOPIC NUMBER FIFTY
                case 0x1377: retval = 60; break;          // ETHIOPIC NUMBER SIXTY
                case 0x1378: retval = 70; break;          // ETHIOPIC NUMBER SEVENTY
                case 0x1379: retval = 80; break;          // ETHIOPIC NUMBER EIGHTY
                case 0x137A: retval = 90; break;          // ETHIOPIC NUMBER NINETY
                case 0x137B: retval = 100; break;         // ETHIOPIC NUMBER HUNDRED
                case 0x137C: retval = 10000; break;       // ETHIOPIC NUMBER TEN THOUSAND
                case 0x215F: retval = 1; break;           // FRACTION NUMERATOR ONE
                case 0x216C: retval = 50; break;          // ROMAN NUMERAL FIFTY
                case 0x216D: retval = 100; break;         // ROMAN NUMERAL ONE HUNDRED
                case 0x216E: retval = 500; break;         // ROMAN NUMERAL FIVE HUNDRED
                case 0x216F: retval = 1000; break;        // ROMAN NUMERAL ONE THOUSAND
                case 0x217C: retval = 50; break;          // SMALL ROMAN NUMERAL FIFTY
                case 0x217D: retval = 100; break;         // SMALL ROMAN NUMERAL ONE HUNDRED
                case 0x217E: retval = 500; break;         // SMALL ROMAN NUMERAL FIVE HUNDRED
                case 0x217F: retval = 1000; break;        // SMALL ROMAN NUMERAL ONE THOUSAND
                case 0x2180: retval = 1000; break;        // ROMAN NUMERAL ONE THOUSAND C D
                case 0x2181: retval = 5000; break;        // ROMAN NUMERAL FIVE THOUSAND
                case 0x2182: retval = 10000; break;       // ROMAN NUMERAL TEN THOUSAND

                case 0x325C: retval = 32; break;

                case 0x325D: retval = 33; break;          // CIRCLED NUMBER THIRTY THREE
                case 0x325E: retval = 34; break;          // CIRCLED NUMBER THIRTY FOUR
                case 0x325F: retval = 35; break;          // CIRCLED NUMBER THIRTY FIVE
                case 0x32B1: retval = 36; break;          // CIRCLED NUMBER THIRTY SIX
                case 0x32B2: retval = 37; break;          // CIRCLED NUMBER THIRTY SEVEN
                case 0x32B3: retval = 38; break;          // CIRCLED NUMBER THIRTY EIGHT
                case 0x32B4: retval = 39; break;          // CIRCLED NUMBER THIRTY NINE
                case 0x32B5: retval = 40; break;          // CIRCLED NUMBER FORTY
                case 0x32B6: retval = 41; break;          // CIRCLED NUMBER FORTY ONE
                case 0x32B7: retval = 42; break;          // CIRCLED NUMBER FORTY TWO
                case 0x32B8: retval = 43; break;          // CIRCLED NUMBER FORTY THREE
                case 0x32B9: retval = 44; break;          // CIRCLED NUMBER FORTY FOUR
                case 0x32BA: retval = 45; break;          // CIRCLED NUMBER FORTY FIVE
                case 0x32BB: retval = 46; break;          // CIRCLED NUMBER FORTY SIX
                case 0x32BC: retval = 47; break;          // CIRCLED NUMBER FORTY SEVEN
                case 0x32BD: retval = 48; break;          // CIRCLED NUMBER FORTY EIGHT
                case 0x32BE: retval = 49; break;          // CIRCLED NUMBER FORTY NINE
                case 0x32BF: retval = 50; break;          // CIRCLED NUMBER FIFTY

P
peytoia 已提交
415 416 417 418 419 420
                case 0x0D71: retval = 100; break;         // MALAYALAM NUMBER ONE HUNDRED
                case 0x0D72: retval = 1000; break;        // MALAYALAM NUMBER ONE THOUSAND
                case 0x2186: retval = 50; break;          // ROMAN NUMERAL FIFTY EARLY FORM
                case 0x2187: retval = 50000; break;       // ROMAN NUMERAL FIFTY THOUSAND
                case 0x2188: retval = 100000; break;      // ROMAN NUMERAL ONE HUNDRED THOUSAND

D
duke 已提交
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488
                default:       retval = -2; break;
            }
            break;
        case ($$valueJavaSupradecimal):           // Java supradecimal
            retval = (ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit) + 10;
            break;
        }
        return retval;
    }

    boolean isWhitespace(int ch) {
        int props = getProperties(ch);
        return ((props & $$maskIdentifierInfo) == $$valueJavaWhitespace);
    }

    byte getDirectionality(int ch) {
        int val = getProperties(ch);
        byte directionality = (byte)((val & $$maskBidi) >> $$shiftBidi);
        if (directionality == 0xF ) {
            switch(ch) {
                case 0x202A :
                    // This is the only char with LRE
                    directionality = Character.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING;
                    break;
                case 0x202B :
                    // This is the only char with RLE
                    directionality = Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING;
                    break;
                case 0x202C :
                    // This is the only char with PDF
                    directionality = Character.DIRECTIONALITY_POP_DIRECTIONAL_FORMAT;
                    break;
                case 0x202D :
                    // This is the only char with LRO
                    directionality = Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE;
                    break;
                case 0x202E :
                    // This is the only char with RLO
                    directionality = Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE;
                    break;
                default :
                    directionality = Character.DIRECTIONALITY_UNDEFINED;
                    break;
            }
        }
        return directionality;
    }

    boolean isMirrored(int ch) {
        int props = getProperties(ch);
        return ((props & $$maskMirrored) != 0);
    }

    int toUpperCaseEx(int ch) {
        int mapChar = ch;
        int val = getProperties(ch);

        if ((val & $$maskUpperCase) != 0) {
            if ((val & $$maskCaseOffset) != $$maskCaseOffset) {
                int offset = val  << $$shiftCaseOffsetSign >> ($$shiftCaseOffsetSign+$$shiftCaseOffset);
                mapChar =  ch - offset;
            }
            else {
                switch(ch) {
                    // map overflow characters
                    case 0x00B5 : mapChar = 0x039C; break;
                    case 0x017F : mapChar = 0x0053; break;
                    case 0x1FBE : mapChar = 0x0399; break;
P
peytoia 已提交
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536

                    case 0x0250 : mapChar = 0x2C6F; break;
                    case 0x0251 : mapChar = 0x2C6D; break;
                    case 0x026B : mapChar = 0x2C62; break;
                    case 0x0271 : mapChar = 0x2C6E; break;
                    case 0x027D : mapChar = 0x2C64; break;
                    case 0x1D79 : mapChar = 0xA77D; break;
                    case 0x1D7D : mapChar = 0x2C63; break;
                    case 0x2C65 : mapChar = 0x023A; break;
                    case 0x2C66 : mapChar = 0x023E; break;
                    case 0x2D00 : mapChar = 0x10A0; break;
                    case 0x2D01 : mapChar = 0x10A1; break;
                    case 0x2D02 : mapChar = 0x10A2; break;
                    case 0x2D03 : mapChar = 0x10A3; break;
                    case 0x2D04 : mapChar = 0x10A4; break;
                    case 0x2D05 : mapChar = 0x10A5; break;
                    case 0x2D06 : mapChar = 0x10A6; break;
                    case 0x2D07 : mapChar = 0x10A7; break;
                    case 0x2D08 : mapChar = 0x10A8; break;
                    case 0x2D09 : mapChar = 0x10A9; break;
                    case 0x2D0A : mapChar = 0x10AA; break;
                    case 0x2D0B : mapChar = 0x10AB; break;
                    case 0x2D0C : mapChar = 0x10AC; break;
                    case 0x2D0D : mapChar = 0x10AD; break;
                    case 0x2D0E : mapChar = 0x10AE; break;
                    case 0x2D0F : mapChar = 0x10AF; break;
                    case 0x2D10 : mapChar = 0x10B0; break;
                    case 0x2D11 : mapChar = 0x10B1; break;
                    case 0x2D12 : mapChar = 0x10B2; break;
                    case 0x2D13 : mapChar = 0x10B3; break;
                    case 0x2D14 : mapChar = 0x10B4; break;
                    case 0x2D15 : mapChar = 0x10B5; break;
                    case 0x2D16 : mapChar = 0x10B6; break;
                    case 0x2D17 : mapChar = 0x10B7; break;
                    case 0x2D18 : mapChar = 0x10B8; break;
                    case 0x2D19 : mapChar = 0x10B9; break;
                    case 0x2D1A : mapChar = 0x10BA; break;
                    case 0x2D1B : mapChar = 0x10BB; break;
                    case 0x2D1C : mapChar = 0x10BC; break;
                    case 0x2D1D : mapChar = 0x10BD; break;
                    case 0x2D1E : mapChar = 0x10BE; break;
                    case 0x2D1F : mapChar = 0x10BF; break;
                    case 0x2D20 : mapChar = 0x10C0; break;
                    case 0x2D21 : mapChar = 0x10C1; break;
                    case 0x2D22 : mapChar = 0x10C2; break;
                    case 0x2D23 : mapChar = 0x10C3; break;
                    case 0x2D24 : mapChar = 0x10C4; break;
                    case 0x2D25 : mapChar = 0x10C5; break;
D
duke 已提交
537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590
                    default       : mapChar = Character.ERROR; break;
                }
            }
        }
        return mapChar;
    }

    char[] toUpperCaseCharArray(int ch) {
        char[] upperMap = {(char)ch};
        int location = findInCharMap(ch);
        if (location != -1) {
            upperMap = charMap[location][1];
        }
        return upperMap;
    }


    /**
     * Finds the character in the uppercase mapping table.
     *
     * @param ch the <code>char</code> to search
     * @return the index location ch in the table or -1 if not found
     * @since 1.4
     */
     int findInCharMap(int ch) {
        if (charMap == null || charMap.length == 0) {
            return -1;
        }
        int top, bottom, current;
        bottom = 0;
        top = charMap.length;
        current = top/2;
        // invariant: top > current >= bottom && ch >= CharacterData.charMap[bottom][0]
        while (top - bottom > 1) {
            if (ch >= charMap[current][0][0]) {
                bottom = current;
            } else {
                top = current;
            }
            current = (top + bottom) / 2;
        }
        if (ch == charMap[current][0][0]) return current;
        else return -1;
    }

    static final CharacterData00 instance = new CharacterData00();
    private CharacterData00() {};

    $$Tables

    static {
        $$Initializers
    }        
}