0N/A/*
3081N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.lang;
0N/A
0N/A/** The CharacterData class encapsulates the large tables once found in
0N/A * java.lang.Character.
0N/A */
0N/A
0N/Aclass CharacterData01 extends CharacterData {
0N/A /* The character properties are currently encoded into 32 bits in the following manner:
0N/A 1 bit mirrored property
0N/A 4 bits directionality property
0N/A 9 bits signed offset used for converting case
0N/A 1 bit if 1, adding the signed offset converts the character to lowercase
0N/A 1 bit if 1, subtracting the signed offset converts the character to uppercase
0N/A 1 bit if 1, this character has a titlecase equivalent (possibly itself)
0N/A 3 bits 0 may not be part of an identifier
0N/A 1 ignorable control; may continue a Unicode identifier or Java identifier
0N/A 2 may continue a Java identifier but not a Unicode identifier (unused)
0N/A 3 may continue a Unicode identifier or Java identifier
0N/A 4 is a Java whitespace character
0N/A 5 may start or continue a Java identifier;
0N/A may continue but not start a Unicode identifier (underscores)
0N/A 6 may start or continue a Java identifier but not a Unicode identifier ($)
0N/A 7 may start or continue a Unicode identifier or Java identifier
0N/A Thus:
0N/A 5, 6, 7 may start a Java identifier
0N/A 1, 2, 3, 5, 6, 7 may continue a Java identifier
0N/A 7 may start a Unicode identifier
0N/A 1, 3, 5, 7 may continue a Unicode identifier
0N/A 1 is ignorable within an identifier
0N/A 4 is Java whitespace
0N/A 2 bits 0 this character has no numeric property
0N/A 1 adding the digit offset to the character code and then
0N/A masking with 0x1F will produce the desired numeric value
0N/A 2 this character has a "strange" numeric value
0N/A 3 a Java supradecimal digit: adding the digit offset to the
0N/A character code, then masking with 0x1F, then adding 10
0N/A will produce the desired numeric value
0N/A 5 bits digit offset
0N/A 5 bits character type
0N/A
0N/A The encoding of character properties is subject to change at any time.
0N/A */
0N/A
0N/A int getProperties(int ch) {
0N/A char offset = (char)ch;
0N/A int props = $$Lookup(offset);
0N/A return props;
0N/A }
0N/A
4138N/A int getPropertiesEx(int ch) {
4138N/A char offset = (char)ch;
4138N/A int props = $$LookupEx(offset);
4138N/A return props;
4138N/A }
4138N/A
0N/A int getType(int ch) {
0N/A int props = getProperties(ch);
0N/A return (props & $$maskType);
0N/A }
0N/A
4138N/A boolean isOtherLowercase(int ch) {
4138N/A int props = getPropertiesEx(ch);
4138N/A return (props & $$maskOtherLowercase) != 0;
4138N/A }
4138N/A
4138N/A boolean isOtherUppercase(int ch) {
4138N/A int props = getPropertiesEx(ch);
4138N/A return (props & $$maskOtherUppercase) != 0;
4138N/A }
4138N/A
4138N/A boolean isOtherAlphabetic(int ch) {
4138N/A int props = getPropertiesEx(ch);
4138N/A return (props & $$maskOtherAlphabetic) != 0;
4138N/A }
4138N/A
4138N/A boolean isIdeographic(int ch) {
4138N/A int props = getPropertiesEx(ch);
4138N/A return (props & $$maskIdeographic) != 0;
4138N/A }
4138N/A
0N/A boolean isJavaIdentifierStart(int ch) {
0N/A int props = getProperties(ch);
0N/A return ((props & $$maskIdentifierInfo) >= $$lowJavaStart);
0N/A }
0N/A
0N/A boolean isJavaIdentifierPart(int ch) {
0N/A int props = getProperties(ch);
0N/A return ((props & $$nonzeroJavaPart) != 0);
0N/A }
0N/A
0N/A boolean isUnicodeIdentifierStart(int ch) {
0N/A int props = getProperties(ch);
0N/A return ((props & $$maskIdentifierInfo) == $$valueUnicodeStart);
0N/A }
0N/A
0N/A boolean isUnicodeIdentifierPart(int ch) {
0N/A int props = getProperties(ch);
0N/A return ((props & $$maskUnicodePart) != 0);
0N/A }
0N/A
0N/A boolean isIdentifierIgnorable(int ch) {
0N/A int props = getProperties(ch);
0N/A return ((props & $$maskIdentifierInfo) == $$valueIgnorable);
0N/A }
0N/A
0N/A int toLowerCase(int ch) {
0N/A int mapChar = ch;
0N/A int val = getProperties(ch);
0N/A
0N/A if ((val & $$maskLowerCase) != 0) {
0N/A int offset = val << $$shiftCaseOffsetSign >> ($$shiftCaseOffsetSign+$$shiftCaseOffset);
0N/A mapChar = ch + offset;
0N/A }
0N/A return mapChar;
0N/A }
0N/A
0N/A int toUpperCase(int ch) {
0N/A int mapChar = ch;
0N/A int val = getProperties(ch);
0N/A
0N/A if ((val & $$maskUpperCase) != 0) {
0N/A int offset = val << $$shiftCaseOffsetSign >> ($$shiftCaseOffsetSign+$$shiftCaseOffset);
0N/A mapChar = ch - offset;
0N/A }
0N/A return mapChar;
0N/A }
0N/A
0N/A int toTitleCase(int ch) {
0N/A int mapChar = ch;
0N/A int val = getProperties(ch);
0N/A
0N/A if ((val & $$maskTitleCase) != 0) {
0N/A // There is a titlecase equivalent. Perform further checks:
0N/A if ((val & $$maskUpperCase) == 0) {
0N/A // The character does not have an uppercase equivalent, so it must
0N/A // already be uppercase; so add 1 to get the titlecase form.
0N/A mapChar = ch + 1;
0N/A }
0N/A else if ((val & $$maskLowerCase) == 0) {
0N/A // The character does not have a lowercase equivalent, so it must
0N/A // already be lowercase; so subtract 1 to get the titlecase form.
0N/A mapChar = ch - 1;
0N/A }
0N/A // else {
0N/A // The character has both an uppercase equivalent and a lowercase
0N/A // equivalent, so it must itself be a titlecase form; return it.
0N/A // return ch;
0N/A //}
0N/A }
0N/A else if ((val & $$maskUpperCase) != 0) {
0N/A // This character has no titlecase equivalent but it does have an
0N/A // uppercase equivalent, so use that (subtract the signed case offset).
0N/A mapChar = toUpperCase(ch);
0N/A }
0N/A return mapChar;
0N/A }
0N/A
0N/A int digit(int ch, int radix) {
0N/A int value = -1;
0N/A if (radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX) {
0N/A int val = getProperties(ch);
0N/A int kind = val & $$maskType;
0N/A if (kind == Character.DECIMAL_DIGIT_NUMBER) {
0N/A value = ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit;
0N/A }
0N/A else if ((val & $$maskNumericType) == $$valueJavaSupradecimal) {
0N/A // Java supradecimal digit
0N/A value = (ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit) + 10;
0N/A }
0N/A }
0N/A return (value < radix) ? value : -1;
0N/A }
0N/A
0N/A int getNumericValue(int ch) {
0N/A int val = getProperties(ch);
0N/A int retval = -1;
0N/A
0N/A switch (val & $$maskNumericType) {
0N/A default: // cannot occur
0N/A case ($$valueNotNumeric): // not numeric
0N/A retval = -1;
0N/A break;
0N/A case ($$valueDigit): // simple numeric
0N/A retval = ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit;
0N/A break;
0N/A case ($$valueStrangeNumeric) : // "strange" numeric
0N/A switch(ch) {
0N/A case 0x10113: retval = 40; break; // AEGEAN NUMBER FORTY
0N/A case 0x10114: retval = 50; break; // AEGEAN NUMBER FIFTY
0N/A case 0x10115: retval = 60; break; // AEGEAN NUMBER SIXTY
0N/A case 0x10116: retval = 70; break; // AEGEAN NUMBER SEVENTY
0N/A case 0x10117: retval = 80; break; // AEGEAN NUMBER EIGHTY
0N/A case 0x10118: retval = 90; break; // AEGEAN NUMBER NINETY
0N/A case 0x10119: retval = 100; break; // AEGEAN NUMBER ONE HUNDRED
0N/A case 0x1011A: retval = 200; break; // AEGEAN NUMBER TWO HUNDRED
0N/A case 0x1011B: retval = 300; break; // AEGEAN NUMBER THREE HUNDRED
0N/A case 0x1011C: retval = 400; break; // AEGEAN NUMBER FOUR HUNDRED
0N/A case 0x1011D: retval = 500; break; // AEGEAN NUMBER FIVE HUNDRED
0N/A case 0x1011E: retval = 600; break; // AEGEAN NUMBER SIX HUNDRED
0N/A case 0x1011F: retval = 700; break; // AEGEAN NUMBER SEVEN HUNDRED
0N/A case 0x10120: retval = 800; break; // AEGEAN NUMBER EIGHT HUNDRED
0N/A case 0x10121: retval = 900; break; // AEGEAN NUMBER NINE HUNDRED
0N/A case 0x10122: retval = 1000; break; // AEGEAN NUMBER ONE THOUSAND
0N/A case 0x10123: retval = 2000; break; // AEGEAN NUMBER TWO THOUSAND
0N/A case 0x10124: retval = 3000; break; // AEGEAN NUMBER THREE THOUSAND
0N/A case 0x10125: retval = 4000; break; // AEGEAN NUMBER FOUR THOUSAND
0N/A case 0x10126: retval = 5000; break; // AEGEAN NUMBER FIVE THOUSAND
0N/A case 0x10127: retval = 6000; break; // AEGEAN NUMBER SIX THOUSAND
0N/A case 0x10128: retval = 7000; break; // AEGEAN NUMBER SEVEN THOUSAND
0N/A case 0x10129: retval = 8000; break; // AEGEAN NUMBER EIGHT THOUSAND
0N/A case 0x1012A: retval = 9000; break; // AEGEAN NUMBER NINE THOUSAND
0N/A case 0x1012B: retval = 10000; break; // AEGEAN NUMBER TEN THOUSAND
0N/A case 0x1012C: retval = 20000; break; // AEGEAN NUMBER TWENTY THOUSAND
0N/A case 0x1012D: retval = 30000; break; // AEGEAN NUMBER THIRTY THOUSAND
0N/A case 0x1012E: retval = 40000; break; // AEGEAN NUMBER FORTY THOUSAND
0N/A case 0x1012F: retval = 50000; break; // AEGEAN NUMBER FIFTY THOUSAND
0N/A case 0x10130: retval = 60000; break; // AEGEAN NUMBER SIXTY THOUSAND
0N/A case 0x10131: retval = 70000; break; // AEGEAN NUMBER SEVENTY THOUSAND
0N/A case 0x10132: retval = 80000; break; // AEGEAN NUMBER EIGHTY THOUSAND
0N/A case 0x10133: retval = 90000; break; // AEGEAN NUMBER NINETY THOUSAND
0N/A case 0x10323: retval = 50; break; // OLD ITALIC NUMERAL FIFTY
1091N/A
1091N/A case 0x010144: retval = 50; break; // ACROPHONIC ATTIC FIFTY
1091N/A case 0x010145: retval = 500; break; // ACROPHONIC ATTIC FIVE HUNDRED
1091N/A case 0x010146: retval = 5000; break; // ACROPHONIC ATTIC FIVE THOUSAND
1091N/A case 0x010147: retval = 50000; break; // ACROPHONIC ATTIC FIFTY THOUSAND
1091N/A case 0x01014A: retval = 50; break; // ACROPHONIC ATTIC FIFTY TALENTS
1091N/A case 0x01014B: retval = 100; break; // ACROPHONIC ATTIC ONE HUNDRED TALENTS
1091N/A case 0x01014C: retval = 500; break; // ACROPHONIC ATTIC FIVE HUNDRED TALENTS
1091N/A case 0x01014D: retval = 1000; break; // ACROPHONIC ATTIC ONE THOUSAND TALENTS
1091N/A case 0x01014E: retval = 5000; break; // ACROPHONIC ATTIC FIVE THOUSAND TALENTS
1091N/A case 0x010151: retval = 50; break; // ACROPHONIC ATTIC FIFTY STATERS
1091N/A case 0x010152: retval = 100; break; // ACROPHONIC ATTIC ONE HUNDRED STATERS
1091N/A case 0x010153: retval = 500; break; // ACROPHONIC ATTIC FIVE HUNDRED STATERS
1091N/A case 0x010154: retval = 1000; break; // ACROPHONIC ATTIC ONE THOUSAND STATERS
1091N/A case 0x010155: retval = 10000; break; // ACROPHONIC ATTIC TEN THOUSAND STATERS
1091N/A case 0x010156: retval = 50000; break; // ACROPHONIC ATTIC FIFTY THOUSAND STATERS
1091N/A case 0x010166: retval = 50; break; // ACROPHONIC TROEZENIAN FIFTY
1091N/A case 0x010167: retval = 50; break; // ACROPHONIC TROEZENIAN FIFTY ALTERNATE FORM
1091N/A case 0x010168: retval = 50; break; // ACROPHONIC HERMIONIAN FIFTY
1091N/A case 0x010169: retval = 50; break; // ACROPHONIC THESPIAN FIFTY
1091N/A case 0x01016A: retval = 100; break; // ACROPHONIC THESPIAN ONE HUNDRED
1091N/A case 0x01016B: retval = 300; break; // ACROPHONIC THESPIAN THREE HUNDRED
1091N/A case 0x01016C: retval = 500; break; // ACROPHONIC EPIDAUREAN FIVE HUNDRED
1091N/A case 0x01016D: retval = 500; break; // ACROPHONIC TROEZENIAN FIVE HUNDRED
1091N/A case 0x01016E: retval = 500; break; // ACROPHONIC THESPIAN FIVE HUNDRED
1091N/A case 0x01016F: retval = 500; break; // ACROPHONIC CARYSTIAN FIVE HUNDRED
1091N/A case 0x010170: retval = 500; break; // ACROPHONIC NAXIAN FIVE HUNDRED
1091N/A case 0x010171: retval = 1000; break; // ACROPHONIC THESPIAN ONE THOUSAND
1091N/A case 0x010172: retval = 5000; break; // ACROPHONIC THESPIAN FIVE THOUSAND
1091N/A case 0x010174: retval = 50; break; // ACROPHONIC STRATIAN FIFTY MNAS
1091N/A case 0x010341: retval = 90; break; // GOTHIC LETTER NINETY
1091N/A case 0x01034A: retval = 900; break; // GOTHIC LETTER NINE HUNDRED
1091N/A case 0x0103D5: retval = 100; break; // OLD PERSIAN NUMBER HUNDRED
3081N/A case 0x01085D: retval = 100; break; // IMPERIAL ARAMAIC NUMBER ONE HUNDRED
3081N/A case 0x01085E: retval = 1000; break; // IMPERIAL ARAMAIC NUMBER ONE THOUSAND
3081N/A case 0x01085F: retval = 10000; break; // IMPERIAL ARAMAIC NUMBER TEN THOUSAND
1091N/A case 0x010919: retval = 100; break; // PHOENICIAN NUMBER ONE HUNDRED
1091N/A case 0x010A46: retval = 100; break; // KHAROSHTHI NUMBER ONE HUNDRED
1091N/A case 0x010A47: retval = 1000; break; // KHAROSHTHI NUMBER ONE THOUSAND
3081N/A case 0x010A7E: retval = 50; break; // OLD SOUTH ARABIAN NUMBER FIFTY
3081N/A case 0x010B5E: retval = 100; break; // INSCRIPTIONAL PARTHIAN NUMBER ONE HUNDRED
3081N/A case 0x010B5F: retval = 1000; break; // INSCRIPTIONAL PARTHIAN NUMBER ONE THOUSAND
3081N/A case 0x010B7E: retval = 100; break; // INSCRIPTIONAL PAHLAVI NUMBER ONE HUNDRED
3081N/A case 0x010B7F: retval = 1000; break; // INSCRIPTIONAL PAHLAVI NUMBER ONE THOUSAND
3081N/A case 0x010E6C: retval = 40; break; // RUMI NUMBER FORTY
3081N/A case 0x010E6D: retval = 50; break; // RUMI NUMBER FIFTY
3081N/A case 0x010E6E: retval = 60; break; // RUMI NUMBER SIXTY
3081N/A case 0x010E6F: retval = 70; break; // RUMI NUMBER SEVENTY
3081N/A case 0x010E70: retval = 80; break; // RUMI NUMBER EIGHTY
3081N/A case 0x010E71: retval = 90; break; // RUMI NUMBER NINETY
3081N/A case 0x010E72: retval = 100; break; // RUMI NUMBER ONE HUNDRED
3081N/A case 0x010E73: retval = 200; break; // RUMI NUMBER TWO HUNDRED
3081N/A case 0x010E74: retval = 300; break; // RUMI NUMBER THREE HUNDRED
3081N/A case 0x010E75: retval = 400; break; // RUMI NUMBER FOUR HUNDRED
3081N/A case 0x010E76: retval = 500; break; // RUMI NUMBER FIVE HUNDRED
3081N/A case 0x010E77: retval = 600; break; // RUMI NUMBER SIX HUNDRED
3081N/A case 0x010E78: retval = 700; break; // RUMI NUMBER SEVEN HUNDRED
3081N/A case 0x010E79: retval = 800; break; // RUMI NUMBER EIGHT HUNDRED
3081N/A case 0x010E7A: retval = 900; break; // RUMI NUMBER NINE HUNDRED
3081N/A case 0x01105E: retval = 40; break; // BRAHMI NUMBER FORTY
3081N/A case 0x01105F: retval = 50; break; // BRAHMI NUMBER FIFTY
3081N/A case 0x011060: retval = 60; break; // BRAHMI NUMBER SIXTY
3081N/A case 0x011061: retval = 70; break; // BRAHMI NUMBER SEVENTY
3081N/A case 0x011062: retval = 80; break; // BRAHMI NUMBER EIGHTY
3081N/A case 0x011063: retval = 90; break; // BRAHMI NUMBER NINETY
3081N/A case 0x011064: retval = 100; break; // BRAHMI NUMBER ONE HUNDRED
3081N/A case 0x011065: retval = 1000; break; // BRAHMI NUMBER ONE THOUSAND
1091N/A case 0x01D36C: retval = 40; break; // COUNTING ROD TENS DIGIT FOUR
1091N/A case 0x01D36D: retval = 50; break; // COUNTING ROD TENS DIGIT FIVE
1091N/A case 0x01D36E: retval = 60; break; // COUNTING ROD TENS DIGIT SIX
1091N/A case 0x01D36F: retval = 70; break; // COUNTING ROD TENS DIGIT SEVEN
1091N/A case 0x01D370: retval = 80; break; // COUNTING ROD TENS DIGIT EIGHT
1091N/A case 0x01D371: retval = 90; break; // COUNTING ROD TENS DIGIT NINE
0N/A default: retval = -2; break;
0N/A }
0N/A
0N/A break;
0N/A case ($$valueJavaSupradecimal): // Java supradecimal
0N/A retval = (ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit) + 10;
0N/A break;
0N/A }
0N/A return retval;
0N/A }
0N/A
0N/A boolean isWhitespace(int ch) {
0N/A int props = getProperties(ch);
0N/A return ((props & $$maskIdentifierInfo) == $$valueJavaWhitespace);
0N/A }
0N/A
0N/A byte getDirectionality(int ch) {
0N/A int val = getProperties(ch);
0N/A byte directionality = (byte)((val & $$maskBidi) >> $$shiftBidi);
0N/A if (directionality == 0xF ) {
0N/A directionality = Character.DIRECTIONALITY_UNDEFINED;
0N/A }
0N/A return directionality;
0N/A }
0N/A
0N/A boolean isMirrored(int ch) {
0N/A int props = getProperties(ch);
0N/A return ((props & $$maskMirrored) != 0);
0N/A }
0N/A
0N/A static final CharacterData instance = new CharacterData01();
0N/A private CharacterData01() {};
0N/A
0N/A $$Tables
0N/A
0N/A static {
0N/A $$Initializers
0N/A }
0N/A}