Path: blob/master/src/java.base/share/classes/java/lang/CharacterData.java
41152 views
/*1* Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.lang;2627abstract class CharacterData {28abstract int getProperties(int ch);29abstract int getType(int ch);30abstract boolean isDigit(int ch);31abstract boolean isLowerCase(int ch);32abstract boolean isUpperCase(int ch);33abstract boolean isWhitespace(int ch);34abstract boolean isMirrored(int ch);35abstract boolean isJavaIdentifierStart(int ch);36abstract boolean isJavaIdentifierPart(int ch);37abstract boolean isUnicodeIdentifierStart(int ch);38abstract boolean isUnicodeIdentifierPart(int ch);39abstract boolean isIdentifierIgnorable(int ch);40abstract int toLowerCase(int ch);41abstract int toUpperCase(int ch);42abstract int toTitleCase(int ch);43abstract int digit(int ch, int radix);44abstract int getNumericValue(int ch);45abstract byte getDirectionality(int ch);4647//need to implement for JSR20448int toUpperCaseEx(int ch) {49return toUpperCase(ch);50}5152char[] toUpperCaseCharArray(int ch) {53return null;54}5556boolean isOtherAlphabetic(int ch) {57return false;58}5960boolean isIdeographic(int ch) {61return false;62}6364// Character <= 0xff (basic latin) is handled by internal fast-path65// to avoid initializing large tables.66// Note: performance of this "fast-path" code may be sub-optimal67// in negative cases for some accessors due to complicated ranges.68// Should revisit after optimization of table initialization.6970static final CharacterData of(int ch) {71if (ch >>> 8 == 0) { // fast-path72return CharacterDataLatin1.instance;73} else {74switch(ch >>> 16) { //plane 00-1675case(0):76return CharacterData00.instance;77case(1):78return CharacterData01.instance;79case(2):80return CharacterData02.instance;81case(3):82return CharacterData03.instance;83case(14):84return CharacterData0E.instance;85case(15): // Private Use86case(16): // Private Use87return CharacterDataPrivateUse.instance;88default:89return CharacterDataUndefined.instance;90}91}92}93}949596