0N/A/*
2362N/A * Copyright (c) 2003, 2006, 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 found in
0N/A Java.lang.Character. */
0N/A
0N/Aclass CharacterData0E 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) {
4138N/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
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 int getType(int ch) {
0N/A int props = getProperties(ch);
0N/A return (props & $$maskType);
0N/A }
0N/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 retval = -2;
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 CharacterData0E();
0N/A private CharacterData0E() {};
0N/A
0N/A $$Tables
0N/A
0N/A static {
0N/A $$Initializers
0N/A }
0N/A}