1 7 8 package java.lang; 9 import java.util.Map ; 10 import java.util.HashMap ; 11 import java.util.Locale ; 12 13 101 public final 102 class Character extends Object implements java.io.Serializable , Comparable <Character > { 103 116 public static final int MIN_RADIX = 2; 117 118 131 public static final int MAX_RADIX = 36; 132 133 139 public static final char MIN_VALUE = '\u0000'; 140 141 147 public static final char MAX_VALUE = '\uffff'; 148 149 155 public static final Class <Character > TYPE = Class.getPrimitiveClass("char"); 156 157 160 161 164 165 169 public static final byte 170 UNASSIGNED = 0; 171 172 176 public static final byte 177 UPPERCASE_LETTER = 1; 178 179 183 public static final byte 184 LOWERCASE_LETTER = 2; 185 186 190 public static final byte 191 TITLECASE_LETTER = 3; 192 193 197 public static final byte 198 MODIFIER_LETTER = 4; 199 200 204 public static final byte 205 OTHER_LETTER = 5; 206 207 211 public static final byte 212 NON_SPACING_MARK = 6; 213 214 218 public static final byte 219 ENCLOSING_MARK = 7; 220 221 225 public static final byte 226 COMBINING_SPACING_MARK = 8; 227 228 232 public static final byte 233 DECIMAL_DIGIT_NUMBER = 9; 234 235 239 public static final byte 240 LETTER_NUMBER = 10; 241 242 246 public static final byte 247 OTHER_NUMBER = 11; 248 249 253 public static final byte 254 SPACE_SEPARATOR = 12; 255 256 260 public static final byte 261 LINE_SEPARATOR = 13; 262 263 267 public static final byte 268 PARAGRAPH_SEPARATOR = 14; 269 270 274 public static final byte 275 CONTROL = 15; 276 277 281 public static final byte 282 FORMAT = 16; 283 284 288 public static final byte 289 PRIVATE_USE = 18; 290 291 295 public static final byte 296 SURROGATE = 19; 297 298 302 public static final byte 303 DASH_PUNCTUATION = 20; 304 305 309 public static final byte 310 START_PUNCTUATION = 21; 311 312 316 public static final byte 317 END_PUNCTUATION = 22; 318 319 323 public static final byte 324 CONNECTOR_PUNCTUATION = 23; 325 326 330 public static final byte 331 OTHER_PUNCTUATION = 24; 332 333 337 public static final byte 338 MATH_SYMBOL = 25; 339 340 344 public static final byte 345 CURRENCY_SYMBOL = 26; 346 347 351 public static final byte 352 MODIFIER_SYMBOL = 27; 353 354 358 public static final byte 359 OTHER_SYMBOL = 28; 360 361 365 public static final byte 366 INITIAL_QUOTE_PUNCTUATION = 29; 367 368 372 public static final byte 373 FINAL_QUOTE_PUNCTUATION = 30; 374 375 378 static final int ERROR = 0xFFFFFFFF; 379 380 381 386 public static final byte DIRECTIONALITY_UNDEFINED = -1; 387 388 392 public static final byte DIRECTIONALITY_LEFT_TO_RIGHT = 0; 393 394 398 public static final byte DIRECTIONALITY_RIGHT_TO_LEFT = 1; 399 400 404 public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = 2; 405 406 410 public static final byte DIRECTIONALITY_EUROPEAN_NUMBER = 3; 411 412 416 public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = 4; 417 418 422 public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR = 5; 423 424 428 public static final byte DIRECTIONALITY_ARABIC_NUMBER = 6; 429 430 434 public static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR = 7; 435 436 440 public static final byte DIRECTIONALITY_NONSPACING_MARK = 8; 441 442 446 public static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL = 9; 447 448 452 public static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR = 10; 453 454 458 public static final byte DIRECTIONALITY_SEGMENT_SEPARATOR = 11; 459 460 464 public static final byte DIRECTIONALITY_WHITESPACE = 12; 465 466 470 public static final byte DIRECTIONALITY_OTHER_NEUTRALS = 13; 471 472 476 public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING = 14; 477 478 482 public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE = 15; 483 484 488 public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING = 16; 489 490 494 public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE = 17; 495 496 500 public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT = 18; 501 502 509 public static final char MIN_HIGH_SURROGATE = '\uD800'; 510 511 518 public static final char MAX_HIGH_SURROGATE = '\uDBFF'; 519 520 527 public static final char MIN_LOW_SURROGATE = '\uDC00'; 528 529 536 public static final char MAX_LOW_SURROGATE = '\uDFFF'; 537 538 543 public static final char MIN_SURROGATE = MIN_HIGH_SURROGATE; 544 545 550 public static final char MAX_SURROGATE = MAX_LOW_SURROGATE; 551 552 557 public static final int MIN_SUPPLEMENTARY_CODE_POINT = 0x010000; 558 559 564 public static final int MIN_CODE_POINT = 0x000000; 565 566 571 public static final int MAX_CODE_POINT = 0x10ffff; 572 573 574 583 public static class Subset { 584 585 private String name; 586 587 593 protected Subset(String name) { 594 if (name == null) { 595 throw new NullPointerException ("name"); 596 } 597 this.name = name; 598 } 599 600 607 public final boolean equals(Object obj) { 608 return (this == obj); 609 } 610 611 618 public final int hashCode() { 619 return super.hashCode(); 620 } 621 622 625 public final String toString() { 626 return name; 627 } 628 } 629 630 638 public static final class UnicodeBlock extends Subset { 639 640 private static Map map = new HashMap (); 641 642 646 private UnicodeBlock(String idName) { 647 super(idName); 648 map.put(idName.toUpperCase(Locale.US), this); 649 } 650 651 655 private UnicodeBlock(String idName, String alias) { 656 this(idName); 657 map.put(alias.toUpperCase(Locale.US), this); 658 } 659 660 664 private UnicodeBlock(String idName, String [] aliasName) { 665 this(idName); 666 if (aliasName != null) { 667 for(int x=0; x<aliasName.length; ++x) { 668 map.put(aliasName[x].toUpperCase(Locale.US), this); 669 } 670 } 671 } 672 673 677 public static final UnicodeBlock BASIC_LATIN = 678 new UnicodeBlock("BASIC_LATIN", new String [] {"Basic Latin", "BasicLatin" }); 679 680 684 public static final UnicodeBlock LATIN_1_SUPPLEMENT = 685 new UnicodeBlock("LATIN_1_SUPPLEMENT", new String []{ "Latin-1 Supplement", "Latin-1Supplement"}); 686 687 691 public static final UnicodeBlock LATIN_EXTENDED_A = 692 new UnicodeBlock("LATIN_EXTENDED_A", new String []{ "Latin Extended-A", "LatinExtended-A"}); 693 694 698 public static final UnicodeBlock LATIN_EXTENDED_B = 699 new UnicodeBlock("LATIN_EXTENDED_B", new String [] {"Latin Extended-B", "LatinExtended-B"}); 700 701 705 public static final UnicodeBlock IPA_EXTENSIONS = 706 new UnicodeBlock("IPA_EXTENSIONS", new String [] {"IPA Extensions", "IPAExtensions"}); 707 708 712 public static final UnicodeBlock SPACING_MODIFIER_LETTERS = 713 new UnicodeBlock("SPACING_MODIFIER_LETTERS", new String [] { "Spacing Modifier Letters", 714 "SpacingModifierLetters"}); 715 716 720 public static final UnicodeBlock COMBINING_DIACRITICAL_MARKS = 721 new UnicodeBlock("COMBINING_DIACRITICAL_MARKS", new String [] {"Combining Diacritical Marks", 722 "CombiningDiacriticalMarks" }); 723 724 731 public static final UnicodeBlock GREEK 732 = new UnicodeBlock("GREEK", new String [] {"Greek and Coptic", "GreekandCoptic"}); 733 734 738 public static final UnicodeBlock CYRILLIC = 739 new UnicodeBlock("CYRILLIC"); 740 741 745 public static final UnicodeBlock ARMENIAN = 746 new UnicodeBlock("ARMENIAN"); 747 748 752 public static final UnicodeBlock HEBREW = 753 new UnicodeBlock("HEBREW"); 754 755 759 public static final UnicodeBlock ARABIC = 760 new UnicodeBlock("ARABIC"); 761 762 766 public static final UnicodeBlock DEVANAGARI = 767 new UnicodeBlock("DEVANAGARI"); 768 769 773 public static final UnicodeBlock BENGALI = 774 new UnicodeBlock("BENGALI"); 775 776 780 public static final UnicodeBlock GURMUKHI = 781 new UnicodeBlock("GURMUKHI"); 782 783 787 public static final UnicodeBlock GUJARATI = 788 new UnicodeBlock("GUJARATI"); 789 790 794 public static final UnicodeBlock ORIYA = 795 new UnicodeBlock("ORIYA"); 796 797 801 public static final UnicodeBlock TAMIL = 802 new UnicodeBlock("TAMIL"); 803 804 808 public static final UnicodeBlock TELUGU = 809 new UnicodeBlock("TELUGU"); 810 811 815 public static final UnicodeBlock KANNADA = 816 new UnicodeBlock("KANNADA"); 817 818 822 public static final UnicodeBlock MALAYALAM = 823 new UnicodeBlock("MALAYALAM"); 824 825 829 public static final UnicodeBlock THAI = 830 new UnicodeBlock("THAI"); 831 832 836 public static final UnicodeBlock LAO = 837 new UnicodeBlock("LAO"); 838 839 843 public static final UnicodeBlock TIBETAN = 844 new UnicodeBlock("TIBETAN"); 845 846 850 public static final UnicodeBlock GEORGIAN = 851 new UnicodeBlock("GEORGIAN"); 852 853 857 public static final UnicodeBlock HANGUL_JAMO = 858 new UnicodeBlock("HANGUL_JAMO", new String [] {"Hangul Jamo", "HangulJamo"}); 859 860 864 public static final UnicodeBlock LATIN_EXTENDED_ADDITIONAL = 865 new UnicodeBlock("LATIN_EXTENDED_ADDITIONAL", new String [] {"Latin Extended Additional", 866 "LatinExtendedAdditional"}); 867 868 872 public static final UnicodeBlock GREEK_EXTENDED = 873 new UnicodeBlock("GREEK_EXTENDED", new String [] {"Greek Extended", "GreekExtended"}); 874 875 879 public static final UnicodeBlock GENERAL_PUNCTUATION = 880 new UnicodeBlock("GENERAL_PUNCTUATION", new String [] {"General Punctuation", "GeneralPunctuation"}); 881 882 886 public static final UnicodeBlock SUPERSCRIPTS_AND_SUBSCRIPTS = 887 new UnicodeBlock("SUPERSCRIPTS_AND_SUBSCRIPTS", new String [] {"Superscripts and Subscripts", 888 "SuperscriptsandSubscripts" }); 889 890 894 public static final UnicodeBlock CURRENCY_SYMBOLS = 895 new UnicodeBlock("CURRENCY_SYMBOLS", new String [] { "Currency Symbols", "CurrencySymbols"}); 896 897 903 public static final UnicodeBlock COMBINING_MARKS_FOR_SYMBOLS = 904 new UnicodeBlock("COMBINING_MARKS_FOR_SYMBOLS", new String [] {"Combining Diacritical Marks for Symbols", 905 "CombiningDiacriticalMarksforSymbols", 906 "Combining Marks for Symbols", 907 "CombiningMarksforSymbols" }); 908 909 913 public static final UnicodeBlock LETTERLIKE_SYMBOLS = 914 new UnicodeBlock("LETTERLIKE_SYMBOLS", new String [] { "Letterlike Symbols", "LetterlikeSymbols"}); 915 916 920 public static final UnicodeBlock NUMBER_FORMS = 921 new UnicodeBlock("NUMBER_FORMS", new String [] {"Number Forms", "NumberForms"}); 922 923 927 public static final UnicodeBlock ARROWS = 928 new UnicodeBlock("ARROWS"); 929 930 934 public static final UnicodeBlock MATHEMATICAL_OPERATORS = 935 new UnicodeBlock("MATHEMATICAL_OPERATORS", new String [] {"Mathematical Operators", 936 "MathematicalOperators"}); 937 938 942 public static final UnicodeBlock MISCELLANEOUS_TECHNICAL = 943 new UnicodeBlock("MISCELLANEOUS_TECHNICAL", new String [] {"Miscellaneous Technical", 944 "MiscellaneousTechnical"}); 945 946 950 public static final UnicodeBlock CONTROL_PICTURES = 951 new UnicodeBlock("CONTROL_PICTURES", new String [] {"Control Pictures", "ControlPictures"}); 952 953 957 public static final UnicodeBlock OPTICAL_CHARACTER_RECOGNITION = 958 new UnicodeBlock("OPTICAL_CHARACTER_RECOGNITION", new String [] {"Optical Character Recognition", 959 "OpticalCharacterRecognition"}); 960 961 965 public static final UnicodeBlock ENCLOSED_ALPHANUMERICS = 966 new UnicodeBlock("ENCLOSED_ALPHANUMERICS", new String [] {"Enclosed Alphanumerics", 967 "EnclosedAlphanumerics"}); 968 969 973 public static final UnicodeBlock BOX_DRAWING = 974 new UnicodeBlock("BOX_DRAWING", new String [] {"Box Drawing", "BoxDrawing"}); 975 976 980 public static final UnicodeBlock BLOCK_ELEMENTS = 981 new UnicodeBlock("BLOCK_ELEMENTS", new String [] {"Block Elements", "BlockElements"}); 982 983 987 public static final UnicodeBlock GEOMETRIC_SHAPES = 988 new UnicodeBlock("GEOMETRIC_SHAPES", new String [] {"Geometric Shapes", "GeometricShapes"}); 989 990 994 public static final UnicodeBlock MISCELLANEOUS_SYMBOLS = 995 new UnicodeBlock("MISCELLANEOUS_SYMBOLS", new String [] {"Miscellaneous Symbols", 996 "MiscellaneousSymbols"}); 997 998 1002 public static final UnicodeBlock DINGBATS = 1003 new UnicodeBlock("DINGBATS"); 1004 1005 1009 public static final UnicodeBlock CJK_SYMBOLS_AND_PUNCTUATION = 1010 new UnicodeBlock("CJK_SYMBOLS_AND_PUNCTUATION", new String [] {"CJK Symbols and Punctuation", 1011 "CJKSymbolsandPunctuation"}); 1012 1013 1017 public static final UnicodeBlock HIRAGANA = 1018 new UnicodeBlock("HIRAGANA"); 1019 1020 1024 public static final UnicodeBlock KATAKANA = 1025 new UnicodeBlock("KATAKANA"); 1026 1027 1031 public static final UnicodeBlock BOPOMOFO = 1032 new UnicodeBlock("BOPOMOFO"); 1033 1034 1038 public static final UnicodeBlock HANGUL_COMPATIBILITY_JAMO = 1039 new UnicodeBlock("HANGUL_COMPATIBILITY_JAMO", new String [] {"Hangul Compatibility Jamo", 1040 "HangulCompatibilityJamo"}); 1041 1042 1046 public static final UnicodeBlock KANBUN = 1047 new UnicodeBlock("KANBUN"); 1048 1049 1053 public static final UnicodeBlock ENCLOSED_CJK_LETTERS_AND_MONTHS = 1054 new UnicodeBlock("ENCLOSED_CJK_LETTERS_AND_MONTHS", new String [] {"Enclosed CJK Letters and Months", 1055 "EnclosedCJKLettersandMonths"}); 1056 1057 1061 public static final UnicodeBlock CJK_COMPATIBILITY = 1062 new UnicodeBlock("CJK_COMPATIBILITY", new String [] {"CJK Compatibility", "CJKCompatibility"}); 1063 1064 1068 public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS = 1069 new UnicodeBlock("CJK_UNIFIED_IDEOGRAPHS", new String [] {"CJK Unified Ideographs", 1070 "CJKUnifiedIdeographs"}); 1071 1072 1076 public static final UnicodeBlock HANGUL_SYLLABLES = 1077 new UnicodeBlock("HANGUL_SYLLABLES", new String [] {"Hangul Syllables", "HangulSyllables"}); 1078 1079 1083 public static final UnicodeBlock PRIVATE_USE_AREA = 1084 new UnicodeBlock("PRIVATE_USE_AREA", new String [] {"Private Use Area", "PrivateUseArea"}); 1085 1086 1090 public static final UnicodeBlock CJK_COMPATIBILITY_IDEOGRAPHS = 1091 new UnicodeBlock("CJK_COMPATIBILITY_IDEOGRAPHS", 1092 new String [] {"CJK Compatibility Ideographs", 1093 "CJKCompatibilityIdeographs"}); 1094 1095 1099 public static final UnicodeBlock ALPHABETIC_PRESENTATION_FORMS = 1100 new UnicodeBlock("ALPHABETIC_PRESENTATION_FORMS", new String [] {"Alphabetic Presentation Forms", 1101 "AlphabeticPresentationForms"}); 1102 1103 1107 public static final UnicodeBlock ARABIC_PRESENTATION_FORMS_A = 1108 new UnicodeBlock("ARABIC_PRESENTATION_FORMS_A", new String [] {"Arabic Presentation Forms-A", 1109 "ArabicPresentationForms-A"}); 1110 1111 1115 public static final UnicodeBlock COMBINING_HALF_MARKS = 1116 new UnicodeBlock("COMBINING_HALF_MARKS", new String [] {"Combining Half Marks", 1117 "CombiningHalfMarks"}); 1118 1119 1123 public static final UnicodeBlock CJK_COMPATIBILITY_FORMS = 1124 new UnicodeBlock("CJK_COMPATIBILITY_FORMS", new String [] {"CJK Compatibility Forms", 1125 "CJKCompatibilityForms"}); 1126 1127 1131 public static final UnicodeBlock SMALL_FORM_VARIANTS = 1132 new UnicodeBlock("SMALL_FORM_VARIANTS", new String [] {"Small Form Variants", 1133 "SmallFormVariants"}); 1134 1135 1139 public static final UnicodeBlock ARABIC_PRESENTATION_FORMS_B = 1140 new UnicodeBlock("ARABIC_PRESENTATION_FORMS_B", new String [] {"Arabic Presentation Forms-B", 1141 "ArabicPresentationForms-B"}); 1142 1143 1147 public static final UnicodeBlock HALFWIDTH_AND_FULLWIDTH_FORMS = 1148 new UnicodeBlock("HALFWIDTH_AND_FULLWIDTH_FORMS", 1149 new String [] {"Halfwidth and Fullwidth Forms", 1150 "HalfwidthandFullwidthForms"}); 1151 1152 1156 public static final UnicodeBlock SPECIALS = 1157 new UnicodeBlock("SPECIALS"); 1158 1159 1167 @Deprecated 1168 public static final UnicodeBlock SURROGATES_AREA = 1169 new UnicodeBlock("SURROGATES_AREA"); 1170 1171 1175 public static final UnicodeBlock SYRIAC = 1176 new UnicodeBlock("SYRIAC"); 1177 1178 1182 public static final UnicodeBlock THAANA = 1183 new UnicodeBlock("THAANA"); 1184 1185 1189 public static final UnicodeBlock SINHALA = 1190 new UnicodeBlock("SINHALA"); 1191 1192 1196 public static final UnicodeBlock MYANMAR = 1197 new UnicodeBlock("MYANMAR"); 1198 1199 1203 public static final UnicodeBlock ETHIOPIC = 1204 new UnicodeBlock("ETHIOPIC"); 1205 1206 1210 public static final UnicodeBlock CHEROKEE = 1211 new UnicodeBlock("CHEROKEE"); 1212 1213 1217 public static final UnicodeBlock UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS = 1218 new UnicodeBlock("UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS", 1219 new String [] {"Unified Canadian Aboriginal Syllabics", 1220 "UnifiedCanadianAboriginalSyllabics"}); 1221 1222 1226 public static final UnicodeBlock OGHAM = 1227 new UnicodeBlock("OGHAM"); 1228 1229 1233 public static final UnicodeBlock RUNIC = 1234 new UnicodeBlock("RUNIC"); 1235 1236 1240 public static final UnicodeBlock KHMER = 1241 new UnicodeBlock("KHMER"); 1242 1243 1247 public static final UnicodeBlock MONGOLIAN = 1248 new UnicodeBlock("MONGOLIAN"); 1249 1250 1254 public static final UnicodeBlock BRAILLE_PATTERNS = 1255 new UnicodeBlock("BRAILLE_PATTERNS", new String [] {"Braille Patterns", 1256 "BraillePatterns"}); 1257 1258 1262 public static final UnicodeBlock CJK_RADICALS_SUPPLEMENT = 1263 new UnicodeBlock("CJK_RADICALS_SUPPLEMENT", new String [] {"CJK Radicals Supplement", 1264 "CJKRadicalsSupplement"}); 1265 1266 1270 public static final UnicodeBlock KANGXI_RADICALS = 1271 new UnicodeBlock("KANGXI_RADICALS", new String [] {"Kangxi Radicals", "KangxiRadicals"}); 1272 1273 1277 public static final UnicodeBlock IDEOGRAPHIC_DESCRIPTION_CHARACTERS = 1278 new UnicodeBlock("IDEOGRAPHIC_DESCRIPTION_CHARACTERS", new String [] {"Ideographic Description Characters", 1279 "IdeographicDescriptionCharacters"}); 1280 1281 1285 public static final UnicodeBlock BOPOMOFO_EXTENDED = 1286 new UnicodeBlock("BOPOMOFO_EXTENDED", new String [] {"Bopomofo Extended", 1287 "BopomofoExtended"}); 1288 1289 1293 public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A = 1294 new UnicodeBlock("CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A", new String [] {"CJK Unified Ideographs Extension A", 1295 "CJKUnifiedIdeographsExtensionA"}); 1296 1297 1301 public static final UnicodeBlock YI_SYLLABLES = 1302 new UnicodeBlock("YI_SYLLABLES", new String [] {"Yi Syllables", "YiSyllables"}); 1303 1304 1308 public static final UnicodeBlock YI_RADICALS = 1309 new UnicodeBlock("YI_RADICALS", new String [] {"Yi Radicals", "YiRadicals"}); 1310 1311 1312 1316 public static final UnicodeBlock CYRILLIC_SUPPLEMENTARY = 1317 new UnicodeBlock("CYRILLIC_SUPPLEMENTARY", new String [] {"Cyrillic Supplementary", 1318 "CyrillicSupplementary"}); 1319 1320 1324 public static final UnicodeBlock TAGALOG = 1325 new UnicodeBlock("TAGALOG"); 1326 1327 1331 public static final UnicodeBlock HANUNOO = 1332 new UnicodeBlock("HANUNOO"); 1333 1334 1338 public static final UnicodeBlock BUHID = 1339 new UnicodeBlock("BUHID"); 1340 1341 1345 public static final UnicodeBlock TAGBANWA = 1346 new UnicodeBlock("TAGBANWA"); 1347 1348 1352 public static final UnicodeBlock LIMBU = 1353 new UnicodeBlock("LIMBU"); 1354 1355 1359 public static final UnicodeBlock TAI_LE = 1360 new UnicodeBlock("TAI_LE", new String [] {"Tai Le", "TaiLe"}); 1361 1362 1366 public static final UnicodeBlock KHMER_SYMBOLS = 1367 new UnicodeBlock("KHMER_SYMBOLS", new String [] {"Khmer Symbols", "KhmerSymbols"}); 1368 1369 1373 public static final UnicodeBlock PHONETIC_EXTENSIONS = 1374 new UnicodeBlock("PHONETIC_EXTENSIONS", new String [] {"Phonetic Extensions", "PhoneticExtensions"}); 1375 1376 1380 public static final UnicodeBlock MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A = 1381 new UnicodeBlock("MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A", 1382 new String []{"Miscellaneous Mathematical Symbols-A", 1383 "MiscellaneousMathematicalSymbols-A"}); 1384 1385 1389 public static final UnicodeBlock SUPPLEMENTAL_ARROWS_A = 1390 new UnicodeBlock("SUPPLEMENTAL_ARROWS_A", new String [] {"Supplemental Arrows-A", 1391 "SupplementalArrows-A"}); 1392 1393 1397 public static final UnicodeBlock SUPPLEMENTAL_ARROWS_B = 1398 new UnicodeBlock("SUPPLEMENTAL_ARROWS_B", new String [] {"Supplemental Arrows-B", 1399 "SupplementalArrows-B"}); 1400 1401 1405 public static final UnicodeBlock MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B 1406 = new UnicodeBlock("MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B", 1407 new String [] {"Miscellaneous Mathematical Symbols-B", 1408 "MiscellaneousMathematicalSymbols-B"}); 1409 1410 1414 public static final UnicodeBlock SUPPLEMENTAL_MATHEMATICAL_OPERATORS = 1415 new UnicodeBlock("SUPPLEMENTAL_MATHEMATICAL_OPERATORS", 1416 new String []{"Supplemental Mathematical Operators", 1417 "SupplementalMathematicalOperators"} ); 1418 1419 1423 public static final UnicodeBlock MISCELLANEOUS_SYMBOLS_AND_ARROWS = 1424 new UnicodeBlock("MISCELLANEOUS_SYMBOLS_AND_ARROWS", new String [] {"Miscellaneous Symbols and Arrows", 1425 "MiscellaneousSymbolsandArrows"}); 1426 1427 1431 public static final UnicodeBlock KATAKANA_PHONETIC_EXTENSIONS = 1432 new UnicodeBlock("KATAKANA_PHONETIC_EXTENSIONS", new String [] {"Katakana Phonetic Extensions", 1433 "KatakanaPhoneticExtensions"}); 1434 1435 1439 public static final UnicodeBlock YIJING_HEXAGRAM_SYMBOLS = 1440 new UnicodeBlock("YIJING_HEXAGRAM_SYMBOLS", new String [] {"Yijing Hexagram Symbols", 1441 "YijingHexagramSymbols"}); 1442 1443 1447 public static final UnicodeBlock VARIATION_SELECTORS = 1448 new UnicodeBlock("VARIATION_SELECTORS", new String [] {"Variation Selectors", "VariationSelectors"}); 1449 1450 1454 public static final UnicodeBlock LINEAR_B_SYLLABARY = 1455 new UnicodeBlock("LINEAR_B_SYLLABARY", new String [] {"Linear B Syllabary", "LinearBSyllabary"}); 1456 1457 1461 public static final UnicodeBlock LINEAR_B_IDEOGRAMS = 1462 new UnicodeBlock("LINEAR_B_IDEOGRAMS", new String [] {"Linear B Ideograms", "LinearBIdeograms"}); 1463 1464 1468 public static final UnicodeBlock AEGEAN_NUMBERS = 1469 new UnicodeBlock("AEGEAN_NUMBERS", new String [] {"Aegean Numbers", "AegeanNumbers"}); 1470 1471 1475 public static final UnicodeBlock OLD_ITALIC = 1476 new UnicodeBlock("OLD_ITALIC", new String [] {"Old Italic", "OldItalic"}); 1477 1478 1482 public static final UnicodeBlock GOTHIC = new UnicodeBlock("GOTHIC"); 1483 1484 1488 public static final UnicodeBlock UGARITIC = new UnicodeBlock("UGARITIC"); 1489 1490 1494 public static final UnicodeBlock DESERET = new UnicodeBlock("DESERET"); 1495 1496 1500 public static final UnicodeBlock SHAVIAN = new UnicodeBlock("SHAVIAN"); 1501 1502 1506 public static final UnicodeBlock OSMANYA = new UnicodeBlock("OSMANYA"); 1507 1508 1512 public static final UnicodeBlock CYPRIOT_SYLLABARY = 1513 new UnicodeBlock("CYPRIOT_SYLLABARY", new String [] {"Cypriot Syllabary", "CypriotSyllabary"}); 1514 1515 1519 public static final UnicodeBlock BYZANTINE_MUSICAL_SYMBOLS = 1520 new UnicodeBlock("BYZANTINE_MUSICAL_SYMBOLS", new String [] {"Byzantine Musical Symbols", 1521 "ByzantineMusicalSymbols"}); 1522 1523 1527 public static final UnicodeBlock MUSICAL_SYMBOLS = 1528 new UnicodeBlock("MUSICAL_SYMBOLS", new String [] {"Musical Symbols", "MusicalSymbols"}); 1529 1530 1534 public static final UnicodeBlock TAI_XUAN_JING_SYMBOLS = 1535 new UnicodeBlock("TAI_XUAN_JING_SYMBOLS", new String [] {"Tai Xuan Jing Symbols", 1536 "TaiXuanJingSymbols"}); 1537 1538 1542 public static final UnicodeBlock MATHEMATICAL_ALPHANUMERIC_SYMBOLS = 1543 new UnicodeBlock("MATHEMATICAL_ALPHANUMERIC_SYMBOLS", 1544 new String [] {"Mathematical Alphanumeric Symbols", "MathematicalAlphanumericSymbols"}); 1545 1546 1550 public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B = 1551 new UnicodeBlock("CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B", 1552 new String [] {"CJK Unified Ideographs Extension B", "CJKUnifiedIdeographsExtensionB"}); 1553 1554 1558 public static final UnicodeBlock CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT = 1559 new UnicodeBlock("CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT", 1560 new String []{"CJK Compatibility Ideographs Supplement", 1561 "CJKCompatibilityIdeographsSupplement"}); 1562 1563 1567 public static final UnicodeBlock TAGS = new UnicodeBlock("TAGS"); 1568 1569 1573 public static final UnicodeBlock VARIATION_SELECTORS_SUPPLEMENT = 1574 new UnicodeBlock("VARIATION_SELECTORS_SUPPLEMENT", new String [] {"Variation Selectors Supplement", 1575 "VariationSelectorsSupplement"}); 1576 1577 1581 public static final UnicodeBlock SUPPLEMENTARY_PRIVATE_USE_AREA_A = 1582 new UnicodeBlock("SUPPLEMENTARY_PRIVATE_USE_AREA_A", 1583 new String [] {"Supplementary Private Use Area-A", 1584 "SupplementaryPrivateUseArea-A"}); 1585 1586 1590 public static final UnicodeBlock SUPPLEMENTARY_PRIVATE_USE_AREA_B = 1591 new UnicodeBlock("SUPPLEMENTARY_PRIVATE_USE_AREA_B", 1592 new String [] {"Supplementary Private Use Area-B", 1593 "SupplementaryPrivateUseArea-B"}); 1594 1595 1602 public static final UnicodeBlock HIGH_SURROGATES = 1603 new UnicodeBlock("HIGH_SURROGATES", new String [] {"High Surrogates", "HighSurrogates"}); 1604 1605 1612 public static final UnicodeBlock HIGH_PRIVATE_USE_SURROGATES = 1613 new UnicodeBlock("HIGH_PRIVATE_USE_SURROGATES", new String [] { "High Private Use Surrogates", 1614 "HighPrivateUseSurrogates"}); 1615 1616 1623 public static final UnicodeBlock LOW_SURROGATES = 1624 new UnicodeBlock("LOW_SURROGATES", new String [] {"Low Surrogates", "LowSurrogates"}); 1625 1626 private static final int blockStarts[] = { 1627 0x0000, 0x0080, 0x0100, 0x0180, 0x0250, 0x02B0, 0x0300, 0x0370, 0x0400, 0x0500, 0x0530, 0x0590, 0x0600, 0x0700, 0x0750, 0x0780, 0x07C0, 0x0900, 0x0980, 0x0A00, 0x0A80, 0x0B00, 0x0B80, 0x0C00, 0x0C80, 0x0D00, 0x0D80, 0x0E00, 0x0E80, 0x0F00, 0x1000, 0x10A0, 0x1100, 0x1200, 0x1380, 0x13A0, 0x1400, 0x1680, 0x16A0, 0x1700, 0x1720, 0x1740, 0x1760, 0x1780, 0x1800, 0x18B0, 0x1900, 0x1950, 0x1980, 0x19E0, 0x1A00, 0x1D00, 0x1D80, 0x1E00, 0x1F00, 0x2000, 0x2070, 0x20A0, 0x20D0, 0x2100, 0x2150, 0x2190, 0x2200, 0x2300, 0x2400, 0x2440, 0x2460, 0x2500, 0x2580, 0x25A0, 0x2600, 0x2700, 0x27C0, 0x27F0, 0x2800, 0x2900, 0x2980, 0x2A00, 0x2B00, 0x2C00, 0x2E80, 0x2F00, 0x2FE0, 0x2FF0, 0x3000, 0x3040, 0x30A0, 0x3100, 0x3130, 0x3190, 0x31A0, 0x31C0, 0x31F0, 0x3200, 0x3300, 0x3400, 0x4DC0, 0x4E00, 0xA000, 0xA490, 0xA4D0, 0xAC00, 0xD7B0, 0xD800, 0xDB80, 0xDC00, 0xE000, 0xF900, 0xFB00, 0xFB50, 0xFE00, 0xFE10, 0xFE20, 0xFE30, 0xFE50, 0xFE70, 0xFF00, 0xFFF0, 0x10000, 0x10080, 0x10100, 0x10140, 0x10300, 0x10330, 0x10350, 0x10380, 0x103A0, 0x10400, 0x10450, 0x10480, 0x104B0, 0x10800, 0x10840, 0x1D000, 0x1D100, 0x1D200, 0x1D300, 0x1D360, 0x1D400, 0x1D800, 0x20000, 0x2A6E0, 0x2F800, 0x2FA20, 0xE0000, 0xE0080, 0xE0100, 0xE01F0, 0xF0000, 0x100000, }; 1778 1779 private static final UnicodeBlock[] blocks = { 1780 BASIC_LATIN, 1781 LATIN_1_SUPPLEMENT, 1782 LATIN_EXTENDED_A, 1783 LATIN_EXTENDED_B, 1784 IPA_EXTENSIONS, 1785 SPACING_MODIFIER_LETTERS, 1786 COMBINING_DIACRITICAL_MARKS, 1787 GREEK, 1788 CYRILLIC, 1789 CYRILLIC_SUPPLEMENTARY, 1790 ARMENIAN, 1791 HEBREW, 1792 ARABIC, 1793 SYRIAC, 1794 null, 1795 THAANA, 1796 null, 1797 DEVANAGARI, 1798 BENGALI, 1799 GURMUKHI, 1800 GUJARATI, 1801 ORIYA, 1802 TAMIL, 1803 TELUGU, 1804 KANNADA, 1805 MALAYALAM, 1806 SINHALA, 1807 THAI, 1808 LAO, 1809 TIBETAN, 1810 MYANMAR, 1811 GEORGIAN, 1812 HANGUL_JAMO, 1813 ETHIOPIC, 1814 null, 1815 CHEROKEE, 1816 UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS, 1817 OGHAM, 1818 RUNIC, 1819 TAGALOG, 1820 HANUNOO, 1821 BUHID, 1822 TAGBANWA, 1823 KHMER, 1824 MONGOLIAN, 1825 null, 1826 LIMBU, 1827 TAI_LE, 1828 null, 1829 KHMER_SYMBOLS, 1830 null, 1831 PHONETIC_EXTENSIONS, 1832 null, 1833 LATIN_EXTENDED_ADDITIONAL, 1834 GREEK_EXTENDED, 1835 GENERAL_PUNCTUATION, 1836 SUPERSCRIPTS_AND_SUBSCRIPTS, 1837 CURRENCY_SYMBOLS, 1838 COMBINING_MARKS_FOR_SYMBOLS, 1839 LETTERLIKE_SYMBOLS, 1840 NUMBER_FORMS, 1841 ARROWS, 1842 MATHEMATICAL_OPERATORS, 1843 MISCELLANEOUS_TECHNICAL, 1844 CONTROL_PICTURES, 1845 OPTICAL_CHARACTER_RECOGNITION, 1846 ENCLOSED_ALPHANUMERICS, 1847 BOX_DRAWING, 1848 BLOCK_ELEMENTS, 1849 GEOMETRIC_SHAPES, 1850 MISCELLANEOUS_SYMBOLS, 1851 DINGBATS, 1852 MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A, 1853 SUPPLEMENTAL_ARROWS_A, 1854 BRAILLE_PATTERNS, 1855 SUPPLEMENTAL_ARROWS_B, 1856 MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B, 1857 SUPPLEMENTAL_MATHEMATICAL_OPERATORS, 1858 MISCELLANEOUS_SYMBOLS_AND_ARROWS, 1859 null, 1860 CJK_RADICALS_SUPPLEMENT, 1861 KANGXI_RADICALS, 1862 null, 1863 IDEOGRAPHIC_DESCRIPTION_CHARACTERS, 1864 CJK_SYMBOLS_AND_PUNCTUATION, 1865 HIRAGANA, 1866 KATAKANA, 1867 BOPOMOFO, 1868 HANGUL_COMPATIBILITY_JAMO, 1869 KANBUN, 1870 BOPOMOFO_EXTENDED, 1871 null, 1872 KATAKANA_PHONETIC_EXTENSIONS, 1873 ENCLOSED_CJK_LETTERS_AND_MONTHS, 1874 CJK_COMPATIBILITY, 1875 CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A, 1876 YIJING_HEXAGRAM_SYMBOLS, 1877 CJK_UNIFIED_IDEOGRAPHS, 1878 YI_SYLLABLES, 1879 YI_RADICALS, 1880 null, 1881 HANGUL_SYLLABLES, 1882 null, 1883 HIGH_SURROGATES, 1884 HIGH_PRIVATE_USE_SURROGATES, 1885 LOW_SURROGATES, 1886 PRIVATE_USE_AREA, 1887 CJK_COMPATIBILITY_IDEOGRAPHS, 1888 ALPHABETIC_PRESENTATION_FORMS, 1889 ARABIC_PRESENTATION_FORMS_A, 1890 VARIATION_SELECTORS, 1891 null, 1892 COMBINING_HALF_MARKS, 1893 CJK_COMPATIBILITY_FORMS, 1894 SMALL_FORM_VARIANTS, 1895 ARABIC_PRESENTATION_FORMS_B, 1896 HALFWIDTH_AND_FULLWIDTH_FORMS, 1897 SPECIALS, 1898 LINEAR_B_SYLLABARY, 1899 LINEAR_B_IDEOGRAMS, 1900 AEGEAN_NUMBERS, 1901 null, 1902 OLD_ITALIC, 1903 GOTHIC, 1904 null, 1905 UGARITIC, 1906 null, 1907 DESERET, 1908 SHAVIAN, 1909 OSMANYA, 1910 null, 1911 CYPRIOT_SYLLABARY, 1912 null, 1913 BYZANTINE_MUSICAL_SYMBOLS, 1914 MUSICAL_SYMBOLS, 1915 null, 1916 TAI_XUAN_JING_SYMBOLS, 1917 null, 1918 MATHEMATICAL_ALPHANUMERIC_SYMBOLS, 1919 null, 1920 CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B, 1921 null, 1922 CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT, 1923 null, 1924 TAGS, 1925 null, 1926 VARIATION_SELECTORS_SUPPLEMENT, 1927 null, 1928 SUPPLEMENTARY_PRIVATE_USE_AREA_A, 1929 SUPPLEMENTARY_PRIVATE_USE_AREA_B 1930 }; 1931 1932 1933 1950 public static UnicodeBlock of(char c) { 1951 return of((int)c); 1952 } 1953 1954 1955 1971 public static UnicodeBlock of(int codePoint) { 1972 if (!isValidCodePoint(codePoint)) { 1973 throw new IllegalArgumentException (); 1974 } 1975 1976 int top, bottom, current; 1977 bottom = 0; 1978 top = blockStarts.length; 1979 current = top/2; 1980 1981 while (top - bottom > 1) { 1983 if (codePoint >= blockStarts[current]) { 1984 bottom = current; 1985 } else { 1986 top = current; 1987 } 1988 current = (top + bottom) / 2; 1989 } 1990 return blocks[current]; 1991 } 1992 1993 2029 public static final UnicodeBlock forName(String blockName) { 2030 UnicodeBlock block = (UnicodeBlock)map.get(blockName.toUpperCase(Locale.US)); 2031 if (block == null) { 2032 throw new IllegalArgumentException (); 2033 } 2034 return block; 2035 } 2036 } 2037 2038 2039 2044 private final char value; 2045 2046 2047 private static final long serialVersionUID = 3786198910865385080L; 2048 2049 2056 public Character(char value) { 2057 this.value = value; 2058 } 2059 2060 private static class CharacterCache { 2061 private CharacterCache(){} 2062 2063 static final Character cache[] = new Character [127 + 1]; 2064 2065 static { 2066 for(int i = 0; i < cache.length; i++) 2067 cache[i] = new Character ((char)i); 2068 } 2069 } 2070 2071 2084 public static Character valueOf(char c) { 2085 if(c <= 127) { return CharacterCache.cache[(int)c]; 2087 } 2088 return new Character (c); 2089 } 2090 2091 2096 public char charValue() { 2097 return value; 2098 } 2099 2100 2104 public int hashCode() { 2105 return (int)value; 2106 } 2107 2108 2118 public boolean equals(Object obj) { 2119 if (obj instanceof Character ) { 2120 return value == ((Character )obj).charValue(); 2121 } 2122 return false; 2123 } 2124 2125 2134 public String toString() { 2135 char buf[] = {value}; 2136 return String.valueOf(buf); 2137 } 2138 2139 2148 public static String toString(char c) { 2149 return String.valueOf(c); 2150 } 2151 2152 2158 private static final int FAST_PATH_MAX = 255; 2159 2160 2167 private static int getPlane(int ch) { 2168 return (ch >>> 16); 2169 } 2170 2171 2187 public static boolean isValidCodePoint(int codePoint) { 2188 return codePoint >= MIN_CODE_POINT && codePoint <= MAX_CODE_POINT; 2189 } 2190 2191 2204 public static boolean isSupplementaryCodePoint(int codePoint) { 2205 return codePoint >= MIN_SUPPLEMENTARY_CODE_POINT 2206 && codePoint <= MAX_CODE_POINT; 2207 } 2208 2209 2230 public static boolean isHighSurrogate(char ch) { 2231 return ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE; 2232 } 2233 2234 2252 public static boolean isLowSurrogate(char ch) { 2253 return ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE; 2254 } 2255 2256 2271 public static boolean isSurrogatePair(char high, char low) { 2272 return isHighSurrogate(high) && isLowSurrogate(low); 2273 } 2274 2275 2291 public static int charCount(int codePoint) { 2292 return codePoint >= MIN_SUPPLEMENTARY_CODE_POINT? 2 : 1; 2293 } 2294 2295 2307 public static int toCodePoint(char high, char low) { 2308 return ((high - MIN_HIGH_SURROGATE) << 10) 2309 + (low - MIN_LOW_SURROGATE) + MIN_SUPPLEMENTARY_CODE_POINT; 2310 } 2311 2312 2334 public static int codePointAt(CharSequence seq, int index) { 2335 char c1 = seq.charAt(index++); 2336 if (isHighSurrogate(c1)) { 2337 if (index < seq.length()) { 2338 char c2 = seq.charAt(index); 2339 if (isLowSurrogate(c2)) { 2340 return toCodePoint(c1, c2); 2341 } 2342 } 2343 } 2344 return c1; 2345 } 2346 2347 2368 public static int codePointAt(char[] a, int index) { 2369 return codePointAtImpl(a, index, a.length); 2370 } 2371 2372 2397 public static int codePointAt(char[] a, int index, int limit) { 2398 if (index >= limit || limit < 0 || limit > a.length) { 2399 throw new IndexOutOfBoundsException (); 2400 } 2401 return codePointAtImpl(a, index, limit); 2402 } 2403 2404 static int codePointAtImpl(char[] a, int index, int limit) { 2405 char c1 = a[index++]; 2406 if (isHighSurrogate(c1)) { 2407 if (index < limit) { 2408 char c2 = a[index]; 2409 if (isLowSurrogate(c2)) { 2410 return toCodePoint(c1, c2); 2411 } 2412 } 2413 } 2414 return c1; 2415 } 2416 2417 2438 public static int codePointBefore(CharSequence seq, int index) { 2439 char c2 = seq.charAt(--index); 2440 if (isLowSurrogate(c2)) { 2441 if (index > 0) { 2442 char c1 = seq.charAt(--index); 2443 if (isHighSurrogate(c1)) { 2444 return toCodePoint(c1, c2); 2445 } 2446 } 2447 } 2448 return c2; 2449 } 2450 2451 2472 public static int codePointBefore(char[] a, int index) { 2473 return codePointBeforeImpl(a, index, 0); 2474 } 2475 2476 2503 public static int codePointBefore(char[] a, int index, int start) { 2504 if (index <= start || start < 0 || start >= a.length) { 2505 throw new IndexOutOfBoundsException (); 2506 } 2507 return codePointBeforeImpl(a, index, start); 2508 } 2509 2510 static int codePointBeforeImpl(char[] a, int index, int start) { 2511 char c2 = a[--index]; 2512 if (isLowSurrogate(c2)) { 2513 if (index > start) { 2514 char c1 = a[--index]; 2515 if (isHighSurrogate(c1)) { 2516 return toCodePoint(c1, c2); 2517 } 2518 } 2519 } 2520 return c2; 2521 } 2522 2523 2554 public static int toChars(int codePoint, char[] dst, int dstIndex) { 2555 if (codePoint < 0 || codePoint > MAX_CODE_POINT) { 2556 throw new IllegalArgumentException (); 2557 } 2558 if (codePoint < MIN_SUPPLEMENTARY_CODE_POINT) { 2559 dst[dstIndex] = (char) codePoint; 2560 return 1; 2561 } 2562 toSurrogates(codePoint, dst, dstIndex); 2563 return 2; 2564 } 2565 2566 2582 public static char[] toChars(int codePoint) { 2583 if (codePoint < 0 || codePoint > MAX_CODE_POINT) { 2584 throw new IllegalArgumentException (); 2585 } 2586 if (codePoint < MIN_SUPPLEMENTARY_CODE_POINT) { 2587 return new char[] { (char) codePoint }; 2588 } 2589 char[] result = new char[2]; 2590 toSurrogates(codePoint, result, 0); 2591 return result; 2592 } 2593 2594 static void toSurrogates(int codePoint, char[] dst, int index) { 2595 int offset = codePoint - MIN_SUPPLEMENTARY_CODE_POINT; 2596 dst[index+1] = (char)((offset & 0x3ff) + MIN_LOW_SURROGATE); 2597 dst[index] = (char)((offset >>> 10) + MIN_HIGH_SURROGATE); 2598 } 2599 2600 2623 public static int codePointCount(CharSequence seq, int beginIndex, int endIndex) { 2624 int length = seq.length(); 2625 if (beginIndex < 0 || endIndex > length || beginIndex > endIndex) { 2626 throw new IndexOutOfBoundsException (); 2627 } 2628 int n = 0; 2629 for (int i = beginIndex; i < endIndex; ) { 2630 n++; 2631 if (isHighSurrogate(seq.charAt(i++))) { 2632 if (i < endIndex && isLowSurrogate(seq.charAt(i))) { 2633 i++; 2634 } 2635 } 2636 } 2637 return n; 2638 } 2639 2640 2659 public static int codePointCount(char[] a, int offset, int count) { 2660 if (count > a.length - offset || offset < 0 || count < 0) { 2661 throw new IndexOutOfBoundsException (); 2662 } 2663 return codePointCountImpl(a, offset, count); 2664 } 2665 2666 static int codePointCountImpl(char[] a, int offset, int count) { 2667 int endIndex = offset + count; 2668 int n = 0; 2669 for (int i = offset; i < endIndex; ) { 2670 n++; 2671 if (isHighSurrogate(a[i++])) { 2672 if (i < endIndex && isLowSurrogate(a[i])) { 2673 i++; 2674 } 2675 } 2676 } 2677 return n; 2678 } 2679 2680 2702 public static int offsetByCodePoints(CharSequence seq, int index, 2703 int codePointOffset) { 2704 int length = seq.length(); 2705 if (index < 0 || index > length) { 2706 throw new IndexOutOfBoundsException (); 2707 } 2708 2709 int x = index; 2710 if (codePointOffset >= 0) { 2711 int i; 2712 for (i = 0; x < length && i < codePointOffset; i++) { 2713 if (isHighSurrogate(seq.charAt(x++))) { 2714 if (x < length && isLowSurrogate(seq.charAt(x))) { 2715 x++; 2716 } 2717 } 2718 } 2719 if (i < codePointOffset) { 2720 throw new IndexOutOfBoundsException (); 2721 } 2722 } else { 2723 int i; 2724 for (i = codePointOffset; x > 0 && i < 0; i++) { 2725 if (isLowSurrogate(seq.charAt(--x))) { 2726 if (x > 0 && isHighSurrogate(seq.charAt(x-1))) { 2727 x--; 2728 } 2729 } 2730 } 2731 if (i < 0) { 2732 throw new IndexOutOfBoundsException (); 2733 } 2734 } 2735 return x; 2736 } 2737 2738 2771 public static int offsetByCodePoints(char[] a, int start, int count, 2772 int index, int codePointOffset) { 2773 if (count > a.length-start || start < 0 || count < 0 2774 || index < start || index > start+count) { 2775 throw new IndexOutOfBoundsException (); 2776 } 2777 return offsetByCodePointsImpl(a, start, count, index, codePointOffset); 2778 } 2779 2780 static int offsetByCodePointsImpl(char[]a, int start, int count, 2781 int index, int codePointOffset) { 2782 int x = index; 2783 if (codePointOffset >= 0) { 2784 int limit = start + count; 2785 int i; 2786 for (i = 0; x < limit && i < codePointOffset; i++) { 2787 if (isHighSurrogate(a[x++])) { 2788 if (x < limit && isLowSurrogate(a[x])) { 2789 x++; 2790 } 2791 } 2792 } 2793 if (i < codePointOffset) { 2794 throw new IndexOutOfBoundsException (); 2795 } 2796 } else { 2797 int i; 2798 for (i = codePointOffset; x > start && i < 0; i++) { 2799 if (isLowSurrogate(a[--x])) { 2800 if (x > start && isHighSurrogate(a[x-1])) { 2801 x--; 2802 } 2803 } 2804 } 2805 if (i < 0) { 2806 throw new IndexOutOfBoundsException (); 2807 } 2808 } 2809 return x; 2810 } 2811 2812 2842 public static boolean isLowerCase(char ch) { 2843 return isLowerCase((int)ch); 2844 } 2845 2846 2873 public static boolean isLowerCase(int codePoint) { 2874 boolean bLowerCase = false; 2875 2876 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 2878 bLowerCase = CharacterDataLatin1.isLowerCase(codePoint); 2879 } else { 2880 int plane = getPlane(codePoint); 2881 switch(plane) { 2882 case(0): 2883 bLowerCase = CharacterData00.isLowerCase(codePoint); 2884 break; 2885 case(1): 2886 bLowerCase = CharacterData01.isLowerCase(codePoint); 2887 break; 2888 case(2): 2889 bLowerCase = CharacterData02.isLowerCase(codePoint); 2890 break; 2891 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): bLowerCase = CharacterDataUndefined.isLowerCase(codePoint); 2903 break; 2904 case(14): 2905 bLowerCase = CharacterData0E.isLowerCase(codePoint); 2906 break; 2907 case(15): case(16): bLowerCase = CharacterDataPrivateUse.isLowerCase(codePoint); 2910 break; 2911 default: 2912 break; 2915 } 2916 } 2917 return bLowerCase; 2918 } 2919 2920 2950 public static boolean isUpperCase(char ch) { 2951 return isUpperCase((int)ch); 2952 } 2953 2954 2979 public static boolean isUpperCase(int codePoint) { 2980 boolean bUpperCase = false; 2981 2982 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 2983 bUpperCase = CharacterDataLatin1.isUpperCase(codePoint); 2984 } else { 2985 int plane = getPlane(codePoint); 2986 switch(plane) { 2987 case(0): 2988 bUpperCase = CharacterData00.isUpperCase(codePoint); 2989 break; 2990 case(1): 2991 bUpperCase = CharacterData01.isUpperCase(codePoint); 2992 break; 2993 case(2): 2994 bUpperCase = CharacterData02.isUpperCase(codePoint); 2995 break; 2996 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): bUpperCase = CharacterDataUndefined.isUpperCase(codePoint); 3008 break; 3009 case(14): 3010 bUpperCase = CharacterData0E.isUpperCase(codePoint); 3011 break; 3012 case(15): case(16): bUpperCase = CharacterDataPrivateUse.isUpperCase(codePoint); 3015 break; 3016 default: 3017 break; 3020 } 3021 } 3022 return bUpperCase; 3023 } 3024 3025 3062 public static boolean isTitleCase(char ch) { 3063 return isTitleCase((int)ch); 3064 } 3065 3066 3098 public static boolean isTitleCase(int codePoint) { 3099 boolean bTitleCase = false; 3100 3101 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 3102 bTitleCase = CharacterDataLatin1.isTitleCase(codePoint); 3103 } else { 3104 int plane = getPlane(codePoint); 3105 switch(plane) { 3106 case(0): 3107 bTitleCase = CharacterData00.isTitleCase(codePoint); 3108 break; 3109 case(1): 3110 bTitleCase = CharacterData01.isTitleCase(codePoint); 3111 break; 3112 case(2): 3113 bTitleCase = CharacterData02.isTitleCase(codePoint); 3114 break; 3115 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): bTitleCase = CharacterDataUndefined.isTitleCase(codePoint); 3127 break; 3128 case(14): 3129 bTitleCase = CharacterData0E.isTitleCase(codePoint); 3130 break; 3131 case(15): case(16): bTitleCase = CharacterDataPrivateUse.isTitleCase(codePoint); 3134 break; 3135 default: 3136 break; 3139 } 3140 } 3141 return bTitleCase; 3142 } 3143 3144 3179 public static boolean isDigit(char ch) { 3180 return isDigit((int)ch); 3181 } 3182 3183 3213 public static boolean isDigit(int codePoint) { 3214 boolean bDigit = false; 3215 3216 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 3217 bDigit = CharacterDataLatin1.isDigit(codePoint); 3218 } else { 3219 int plane = getPlane(codePoint); 3220 switch(plane) { 3221 case(0): 3222 bDigit = CharacterData00.isDigit(codePoint); 3223 break; 3224 case(1): 3225 bDigit = CharacterData01.isDigit(codePoint); 3226 break; 3227 case(2): 3228 bDigit = CharacterData02.isDigit(codePoint); 3229 break; 3230 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): bDigit = CharacterDataUndefined.isDigit(codePoint); 3242 break; 3243 case(14): 3244 bDigit = CharacterData0E.isDigit(codePoint); 3245 break; 3246 case(15): case(16): bDigit = CharacterDataPrivateUse.isDigit(codePoint); 3249 break; 3250 default: 3251 break; 3254 } 3255 } 3256 return bDigit; 3257 } 3258 3259 3284 public static boolean isDefined(char ch) { 3285 return isDefined((int)ch); 3286 } 3287 3288 3308 public static boolean isDefined(int codePoint) { 3309 boolean bDefined = false; 3310 3311 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 3312 bDefined = CharacterDataLatin1.isDefined(codePoint); 3313 } else { 3314 int plane = getPlane(codePoint); 3315 switch(plane) { 3316 case(0): 3317 bDefined = CharacterData00.isDefined(codePoint); 3318 break; 3319 case(1): 3320 bDefined = CharacterData01.isDefined(codePoint); 3321 break; 3322 case(2): 3323 bDefined = CharacterData02.isDefined(codePoint); 3324 break; 3325 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): bDefined = CharacterDataUndefined.isDefined(codePoint); 3337 break; 3338 case(14): 3339 bDefined = CharacterData0E.isDefined(codePoint); 3340 break; 3341 case(15): case(16): bDefined = CharacterDataPrivateUse.isDefined(codePoint); 3344 break; 3345 default: 3346 break; 3349 } 3350 } 3351 return bDefined; 3352 } 3353 3354 3389 public static boolean isLetter(char ch) { 3390 return isLetter((int)ch); 3391 } 3392 3393 3422 public static boolean isLetter(int codePoint) { 3423 boolean bLetter = false; 3424 3425 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 3426 bLetter = CharacterDataLatin1.isLetter(codePoint); 3427 } else { 3428 int plane = getPlane(codePoint); 3429 switch(plane) { 3430 case(0): 3431 bLetter = CharacterData00.isLetter(codePoint); 3432 break; 3433 case(1): 3434 bLetter = CharacterData01.isLetter(codePoint); 3435 break; 3436 case(2): 3437 bLetter = CharacterData02.isLetter(codePoint); 3438 break; 3439 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): bLetter = CharacterDataUndefined.isLetter(codePoint); 3451 break; 3452 case(14): 3453 bLetter = CharacterData0E.isLetter(codePoint); 3454 break; 3455 case(15): case(16): bLetter = CharacterDataPrivateUse.isLetter(codePoint); 3458 break; 3459 default: 3460 break; 3463 } 3464 } 3465 return bLetter; 3466 } 3467 3468 3492 public static boolean isLetterOrDigit(char ch) { 3493 return isLetterOrDigit((int)ch); 3494 } 3495 3496 3513 public static boolean isLetterOrDigit(int codePoint) { 3514 boolean bLetterOrDigit = false; 3515 3516 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 3517 bLetterOrDigit = CharacterDataLatin1.isLetterOrDigit(codePoint); 3518 } else { 3519 int plane = getPlane(codePoint); 3520 switch(plane) { 3521 case(0): 3522 bLetterOrDigit = CharacterData00.isLetterOrDigit(codePoint); 3523 break; 3524 case(1): 3525 bLetterOrDigit = CharacterData01.isLetterOrDigit(codePoint); 3526 break; 3527 case(2): 3528 bLetterOrDigit = CharacterData02.isLetterOrDigit(codePoint); 3529 break; 3530 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): bLetterOrDigit = CharacterDataUndefined.isLetterOrDigit(codePoint); 3542 break; 3543 case(14): bLetterOrDigit = CharacterData0E.isLetterOrDigit(codePoint); 3545 break; 3546 case(15): case(16): bLetterOrDigit = CharacterDataPrivateUse.isLetterOrDigit(codePoint); 3549 break; 3550 default: 3551 break; 3554 } 3555 } 3556 return bLetterOrDigit; 3557 } 3558 3559 3584 @Deprecated 3585 public static boolean isJavaLetter(char ch) { 3586 return isJavaIdentifierStart(ch); 3587 } 3588 3589 3620 @Deprecated 3621 public static boolean isJavaLetterOrDigit(char ch) { 3622 return isJavaIdentifierPart(ch); 3623 } 3624 3625 3651 public static boolean isJavaIdentifierStart(char ch) { 3652 return isJavaIdentifierStart((int)ch); 3653 } 3654 3655 3679 public static boolean isJavaIdentifierStart(int codePoint) { 3680 boolean bJavaStart = false; 3681 3682 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 3683 bJavaStart = CharacterDataLatin1.isJavaIdentifierStart(codePoint); 3684 } else { 3685 int plane = getPlane(codePoint); 3686 switch(plane) { 3687 case(0): 3688 bJavaStart = CharacterData00.isJavaIdentifierStart(codePoint); 3689 break; 3690 case(1): 3691 bJavaStart = CharacterData01.isJavaIdentifierStart(codePoint); 3692 break; 3693 case(2): 3694 bJavaStart = CharacterData02.isJavaIdentifierStart(codePoint); 3695 break; 3696 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): bJavaStart = CharacterDataUndefined.isJavaIdentifierStart(codePoint); 3708 break; 3709 case(14): 3710 bJavaStart = CharacterData0E.isJavaIdentifierStart(codePoint); 3711 break; 3712 case(15): case(16): bJavaStart = CharacterDataPrivateUse.isJavaIdentifierStart(codePoint); 3715 break; 3716 default: 3717 break; 3720 } 3721 } 3722 return bJavaStart; 3723 } 3724 3725 3757 public static boolean isJavaIdentifierPart(char ch) { 3758 return isJavaIdentifierPart((int)ch); 3759 } 3760 3761 3789 public static boolean isJavaIdentifierPart(int codePoint) { 3790 boolean bJavaPart = false; 3791 3792 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 3793 bJavaPart = CharacterDataLatin1.isJavaIdentifierPart(codePoint); 3794 } else { 3795 int plane = getPlane(codePoint); 3796 switch(plane) { 3797 case(0): 3798 bJavaPart = CharacterData00.isJavaIdentifierPart(codePoint); 3799 break; 3800 case(1): 3801 bJavaPart = CharacterData01.isJavaIdentifierPart(codePoint); 3802 break; 3803 case(2): 3804 bJavaPart = CharacterData02.isJavaIdentifierPart(codePoint); 3805 break; 3806 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): bJavaPart = CharacterDataUndefined.isJavaIdentifierPart(codePoint); 3818 break; 3819 case(14): 3820 bJavaPart = CharacterData0E.isJavaIdentifierPart(codePoint); 3821 break; 3822 case(15): case(16): bJavaPart = CharacterDataPrivateUse.isJavaIdentifierPart(codePoint); 3825 break; 3826 default: 3827 break; 3830 } 3831 } 3832 return bJavaPart; 3833 } 3834 3835 3860 public static boolean isUnicodeIdentifierStart(char ch) { 3861 return isUnicodeIdentifierStart((int)ch); 3862 } 3863 3864 3884 public static boolean isUnicodeIdentifierStart(int codePoint) { 3885 boolean bUnicodeStart = false; 3886 3887 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 3888 bUnicodeStart = CharacterDataLatin1.isUnicodeIdentifierStart(codePoint); 3889 } else { 3890 int plane = getPlane(codePoint); 3891 switch(plane) { 3892 case(0): 3893 bUnicodeStart = CharacterData00.isUnicodeIdentifierStart(codePoint); 3894 break; 3895 case(1): 3896 bUnicodeStart = CharacterData01.isUnicodeIdentifierStart(codePoint); 3897 break; 3898 case(2): 3899 bUnicodeStart = CharacterData02.isUnicodeIdentifierStart(codePoint); 3900 break; 3901 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): bUnicodeStart = CharacterDataUndefined.isUnicodeIdentifierStart(codePoint); 3913 break; 3914 case(14): 3915 bUnicodeStart = CharacterData0E.isUnicodeIdentifierStart(codePoint); 3916 break; 3917 case(15): case(16): bUnicodeStart = CharacterDataPrivateUse.isUnicodeIdentifierStart(codePoint); 3920 break; 3921 default: 3922 break; 3925 } 3926 } 3927 return bUnicodeStart; 3928 } 3929 3930 3961 public static boolean isUnicodeIdentifierPart(char ch) { 3962 return isUnicodeIdentifierPart((int)ch); 3963 } 3964 3965 3990 public static boolean isUnicodeIdentifierPart(int codePoint) { 3991 boolean bUnicodePart = false; 3992 3993 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 3994 bUnicodePart = CharacterDataLatin1.isUnicodeIdentifierPart(codePoint); 3995 } else { 3996 int plane = getPlane(codePoint); 3997 switch(plane) { 3998 case(0): 3999 bUnicodePart = CharacterData00.isUnicodeIdentifierPart(codePoint); 4000 break; 4001 case(1): 4002 bUnicodePart = CharacterData01.isUnicodeIdentifierPart(codePoint); 4003 break; 4004 case(2): 4005 bUnicodePart = CharacterData02.isUnicodeIdentifierPart(codePoint); 4006 break; 4007 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): bUnicodePart = CharacterDataUndefined.isUnicodeIdentifierPart(codePoint); 4019 break; 4020 case(14): 4021 bUnicodePart = CharacterData0E.isUnicodeIdentifierPart(codePoint); 4022 break; 4023 case(15): case(16): bUnicodePart = CharacterDataPrivateUse.isUnicodeIdentifierPart(codePoint); 4026 break; 4027 default: 4028 break; 4031 } 4032 } 4033 return bUnicodePart; 4034 } 4035 4036 4067 public static boolean isIdentifierIgnorable(char ch) { 4068 return isIdentifierIgnorable((int)ch); 4069 } 4070 4071 4097 public static boolean isIdentifierIgnorable(int codePoint) { 4098 boolean bIdentifierIgnorable = false; 4099 4100 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 4101 bIdentifierIgnorable = CharacterDataLatin1.isIdentifierIgnorable(codePoint); 4102 } else { 4103 int plane = getPlane(codePoint); 4104 switch(plane) { 4105 case(0): 4106 bIdentifierIgnorable = CharacterData00.isIdentifierIgnorable(codePoint); 4107 break; 4108 case(1): 4109 bIdentifierIgnorable = CharacterData01.isIdentifierIgnorable(codePoint); 4110 break; 4111 case(2): 4112 bIdentifierIgnorable = CharacterData02.isIdentifierIgnorable(codePoint); 4113 break; 4114 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): bIdentifierIgnorable = CharacterDataUndefined.isIdentifierIgnorable(codePoint); 4126 break; 4127 case(14): 4128 bIdentifierIgnorable = CharacterData0E.isIdentifierIgnorable(codePoint); 4129 break; 4130 case(15): case(16): bIdentifierIgnorable = CharacterDataPrivateUse.isIdentifierIgnorable(codePoint); 4133 break; 4134 default: 4135 break; 4138 } 4139 } 4140 return bIdentifierIgnorable; 4141 } 4142 4143 4170 public static char toLowerCase(char ch) { 4171 return (char)toLowerCase((int)ch); 4172 } 4173 4174 4199 public static int toLowerCase(int codePoint) { 4200 int lowerCase = codePoint; 4201 int plane = 0; 4202 4203 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 4204 lowerCase = CharacterDataLatin1.toLowerCase(codePoint); 4205 } else { 4206 plane = getPlane(codePoint); 4207 switch(plane) { 4208 case(0): 4209 lowerCase = CharacterData00.toLowerCase(codePoint); 4210 break; 4211 case(1): 4212 lowerCase = CharacterData01.toLowerCase(codePoint); 4213 break; 4214 case(2): 4215 lowerCase = CharacterData02.toLowerCase(codePoint); 4216 break; 4217 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): lowerCase = CharacterDataUndefined.toLowerCase(codePoint); 4229 break; 4230 case(14): 4231 lowerCase = CharacterData0E.toLowerCase(codePoint); 4232 break; 4233 case(15): case(16): lowerCase = CharacterDataPrivateUse.toLowerCase(codePoint); 4236 break; 4237 default: 4238 break; 4241 } 4242 } 4243 return lowerCase; 4244 } 4245 4246 4273 public static char toUpperCase(char ch) { 4274 return (char)toUpperCase((int)ch); 4275 } 4276 4277 4302 public static int toUpperCase(int codePoint) { 4303 int upperCase = codePoint; 4304 int plane = 0; 4305 4306 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 4307 upperCase = CharacterDataLatin1.toUpperCase(codePoint); 4308 } else { 4309 plane = getPlane(codePoint); 4310 switch(plane) { 4311 case(0): 4312 upperCase = CharacterData00.toUpperCase(codePoint); 4313 break; 4314 case(1): 4315 upperCase = CharacterData01.toUpperCase(codePoint); 4316 break; 4317 case(2): 4318 upperCase = CharacterData02.toUpperCase(codePoint); 4319 break; 4320 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): upperCase = CharacterDataUndefined.toUpperCase(codePoint); 4332 break; 4333 case(14): 4334 upperCase = CharacterData0E.toUpperCase(codePoint); 4335 break; 4336 case(15): case(16): upperCase = CharacterDataPrivateUse.toUpperCase(codePoint); 4339 break; 4340 default: 4341 break; 4344 } 4345 } 4346 return upperCase; 4347 } 4348 4349 4377 public static char toTitleCase(char ch) { 4378 return (char)toTitleCase((int)ch); 4379 } 4380 4381 4404 public static int toTitleCase(int codePoint) { 4405 int titleCase = codePoint; 4406 int plane = 0; 4407 4408 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 4409 titleCase = CharacterDataLatin1.toTitleCase(codePoint); 4410 } else { 4411 plane = getPlane(codePoint); 4412 switch(plane) { 4413 case(0): 4414 titleCase = CharacterData00.toTitleCase(codePoint); 4415 break; 4416 case(1): 4417 titleCase = CharacterData01.toTitleCase(codePoint); 4418 break; 4419 case(2): 4420 titleCase = CharacterData02.toTitleCase(codePoint); 4421 break; 4422 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): titleCase = CharacterDataUndefined.toTitleCase(codePoint); 4434 break; 4435 case(14): 4436 titleCase = CharacterData0E.toTitleCase(codePoint); 4437 break; 4438 case(15): case(16): titleCase = CharacterDataPrivateUse.toTitleCase(codePoint); 4441 break; 4442 default: 4443 break; 4446 } 4447 } 4448 return titleCase; 4449 } 4450 4451 4489 public static int digit(char ch, int radix) { 4490 return digit((int)ch, radix); 4491 } 4492 4493 4527 public static int digit(int codePoint, int radix) { 4528 int digit = -1; 4529 4530 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 4531 digit = CharacterDataLatin1.digit(codePoint, radix); 4532 } else { 4533 int plane = getPlane(codePoint); 4534 switch(plane) { 4535 case(0): 4536 digit = CharacterData00.digit(codePoint, radix); 4537 break; 4538 case(1): 4539 digit = CharacterData01.digit(codePoint, radix); 4540 break; 4541 case(2): 4542 digit = CharacterData02.digit(codePoint, radix); 4543 break; 4544 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): digit = CharacterDataUndefined.digit(codePoint, radix); 4556 break; 4557 case(14): 4558 digit = CharacterData0E.digit(codePoint, radix); 4559 break; 4560 case(15): case(16): digit = CharacterDataPrivateUse.digit(codePoint, radix); 4563 break; 4564 default: 4565 break; 4568 } 4569 } 4570 return digit; 4571 } 4572 4573 4607 public static int getNumericValue(char ch) { 4608 return getNumericValue((int)ch); 4609 } 4610 4611 4640 public static int getNumericValue(int codePoint) { 4641 int numericValue = -1; 4642 4643 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 4644 numericValue = CharacterDataLatin1.getNumericValue(codePoint); 4645 } else { 4646 int plane = getPlane(codePoint); 4647 switch(plane) { 4648 case(0): 4649 numericValue = CharacterData00.getNumericValue(codePoint); 4650 break; 4651 case(1): 4652 numericValue = CharacterData01.getNumericValue(codePoint); 4653 break; 4654 case(2): 4655 numericValue = CharacterData02.getNumericValue(codePoint); 4656 break; 4657 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): numericValue = CharacterDataUndefined.getNumericValue(codePoint); 4669 break; 4670 case(14): 4671 numericValue = CharacterData0E.getNumericValue(codePoint); 4672 break; 4673 case(15): case(16): numericValue = CharacterDataPrivateUse.getNumericValue(codePoint); 4676 break; 4677 default: 4678 break; 4681 } 4682 } 4683 return numericValue; 4684 } 4685 4686 4710 @Deprecated 4711 public static boolean isSpace(char ch) { 4712 return (ch <= 0x0020) && 4713 (((((1L << 0x0009) | 4714 (1L << 0x000A) | 4715 (1L << 0x000C) | 4716 (1L << 0x000D) | 4717 (1L << 0x0020)) >> ch) & 1L) != 0); 4718 } 4719 4720 4721 4744 public static boolean isSpaceChar(char ch) { 4745 return isSpaceChar((int)ch); 4746 } 4747 4748 4767 public static boolean isSpaceChar(int codePoint) { 4768 boolean bSpaceChar = false; 4769 4770 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 4771 bSpaceChar = CharacterDataLatin1.isSpaceChar(codePoint); 4772 } else { 4773 int plane = getPlane(codePoint); 4774 switch(plane) { 4775 case(0): 4776 bSpaceChar = CharacterData00.isSpaceChar(codePoint); 4777 break; 4778 case(1): 4779 bSpaceChar = CharacterData01.isSpaceChar(codePoint); 4780 break; 4781 case(2): 4782 bSpaceChar = CharacterData02.isSpaceChar(codePoint); 4783 break; 4784 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): bSpaceChar = CharacterDataUndefined.isSpaceChar(codePoint); 4796 break; 4797 case(14): 4798 bSpaceChar = CharacterData0E.isSpaceChar(codePoint); 4799 break; 4800 case(15): case(16): bSpaceChar = CharacterDataPrivateUse.isSpaceChar(codePoint); 4803 break; 4804 default: 4805 break; 4808 } 4809 } 4810 return bSpaceChar; 4811 } 4812 4813 4844 public static boolean isWhitespace(char ch) { 4845 return isWhitespace((int)ch); 4846 } 4847 4848 4876 public static boolean isWhitespace(int codePoint) { 4877 boolean bWhiteSpace = false; 4878 4879 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 4880 bWhiteSpace = CharacterDataLatin1.isWhitespace(codePoint); 4881 } else { 4882 int plane = getPlane(codePoint); 4883 switch(plane) { 4884 case(0): 4885 bWhiteSpace = CharacterData00.isWhitespace(codePoint); 4886 break; 4887 case(1): 4888 bWhiteSpace = CharacterData01.isWhitespace(codePoint); 4889 break; 4890 case(2): 4891 bWhiteSpace = CharacterData02.isWhitespace(codePoint); 4892 break; 4893 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): bWhiteSpace = CharacterDataUndefined.isWhitespace(codePoint); 4905 break; 4906 case(14): 4907 bWhiteSpace = CharacterData0E.isWhitespace(codePoint); 4908 break; 4909 case(15): case(16): bWhiteSpace = CharacterDataPrivateUse.isWhitespace(codePoint); 4912 break; 4913 default: 4914 break; 4917 } 4918 } 4919 return bWhiteSpace; 4920 } 4921 4922 4942 public static boolean isISOControl(char ch) { 4943 return isISOControl((int)ch); 4944 } 4945 4946 4960 public static boolean isISOControl(int codePoint) { 4961 return (codePoint >= 0x0000 && codePoint <= 0x001F) || 4962 (codePoint >= 0x007F && codePoint <= 0x009F); 4963 } 4964 4965 5008 public static int getType(char ch) { 5009 return getType((int)ch); 5010 } 5011 5012 5050 public static int getType(int codePoint) { 5051 int type = Character.UNASSIGNED; 5052 5053 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 5054 type = CharacterDataLatin1.getType(codePoint); 5055 } else { 5056 int plane = getPlane(codePoint); 5057 switch(plane) { 5058 case(0): 5059 type = CharacterData00.getType(codePoint); 5060 break; 5061 case(1): 5062 type = CharacterData01.getType(codePoint); 5063 break; 5064 case(2): 5065 type = CharacterData02.getType(codePoint); 5066 break; 5067 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): type = CharacterDataUndefined.getType(codePoint); 5079 break; 5080 case(14): 5081 type = CharacterData0E.getType(codePoint); 5082 break; 5083 case(15): case(16): type = CharacterDataPrivateUse.getType(codePoint); 5086 break; 5087 default: 5088 break; 5091 } 5092 } 5093 return type; 5094 } 5095 5096 5120 public static char forDigit(int digit, int radix) { 5121 if ((digit >= radix) || (digit < 0)) { 5122 return '\0'; 5123 } 5124 if ((radix < Character.MIN_RADIX) || (radix > Character.MAX_RADIX)) { 5125 return '\0'; 5126 } 5127 if (digit < 10) { 5128 return (char)('0' + digit); 5129 } 5130 return (char)('a' - 10 + digit); 5131 } 5132 5133 5170 public static byte getDirectionality(char ch) { 5171 return getDirectionality((int)ch); 5172 } 5173 5174 5207 public static byte getDirectionality(int codePoint) { 5208 byte directionality = Character.DIRECTIONALITY_UNDEFINED; 5209 5210 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 5211 directionality = CharacterDataLatin1.getDirectionality(codePoint); 5212 } else { 5213 int plane = getPlane(codePoint); 5214 switch(plane) { 5215 case(0): 5216 directionality = CharacterData00.getDirectionality(codePoint); 5217 break; 5218 case(1): 5219 directionality = CharacterData01.getDirectionality(codePoint); 5220 break; 5221 case(2): 5222 directionality = CharacterData02.getDirectionality(codePoint); 5223 break; 5224 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): directionality = CharacterDataUndefined.getDirectionality(codePoint); 5236 break; 5237 case(14): 5238 directionality = CharacterData0E.getDirectionality(codePoint); 5239 break; 5240 case(15): case(16): directionality = CharacterDataPrivateUse.getDirectionality(codePoint); 5243 break; 5244 default: 5245 break; 5248 } 5249 } 5250 return directionality; 5251 } 5252 5253 5272 public static boolean isMirrored(char ch) { 5273 return isMirrored((int)ch); 5274 } 5275 5276 5291 public static boolean isMirrored(int codePoint) { 5292 boolean bMirrored = false; 5293 5294 if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) { 5295 bMirrored = CharacterDataLatin1.isMirrored(codePoint); 5296 } else { 5297 int plane = getPlane(codePoint); 5298 switch(plane) { 5299 case(0): 5300 bMirrored = CharacterData00.isMirrored(codePoint); 5301 break; 5302 case(1): 5303 bMirrored = CharacterData01.isMirrored(codePoint); 5304 break; 5305 case(2): 5306 bMirrored = CharacterData02.isMirrored(codePoint); 5307 break; 5308 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): bMirrored = CharacterDataUndefined.isMirrored(codePoint); 5320 break; 5321 case(14): 5322 bMirrored = CharacterData0E.isMirrored(codePoint); 5323 break; 5324 case(15): case(16): bMirrored = CharacterDataPrivateUse.isMirrored(codePoint); 5327 break; 5328 default: 5329 break; 5332 } 5333 } 5334 return bMirrored; 5335 } 5336 5337 5352 public int compareTo(Character anotherCharacter) { 5353 return this.value - anotherCharacter.value; 5354 } 5355 5356 5371 static int toUpperCaseEx(int codePoint) { 5372 int upperCase = codePoint; 5373 int plane = 0; 5374 5375 assert isValidCodePoint(codePoint); 5376 5377 if (codePoint <= FAST_PATH_MAX) { 5378 upperCase = CharacterDataLatin1.toUpperCaseEx(codePoint); 5379 } else { 5380 plane = getPlane(codePoint); 5381 switch(plane) { 5382 case(0): 5383 upperCase = CharacterData00.toUpperCaseEx(codePoint); 5384 break; 5385 case(1): 5386 upperCase = CharacterData01.toUpperCase(codePoint); 5387 break; 5388 case(2): 5389 upperCase = CharacterData02.toUpperCase(codePoint); 5390 break; 5391 case(3): case(4): case(5): case(6): case(7): case(8): case(9): case(10): case(11): case(12): case(13): upperCase = CharacterDataUndefined.toUpperCase(codePoint); 5403 break; 5404 case(14): 5405 upperCase = CharacterData0E.toUpperCase(codePoint); 5406 break; 5407 case(15): case(16): upperCase = CharacterDataPrivateUse.toUpperCase(codePoint); 5410 break; 5411 default: 5412 break; 5415 } 5416 } 5417 return upperCase; 5418 } 5419 5420 5431 static char[] toUpperCaseCharArray(int codePoint) { 5432 char[] upperCase = null; 5433 5434 assert isValidCodePoint(codePoint) && 5436 !isSupplementaryCodePoint(codePoint); 5437 5438 if (codePoint <= FAST_PATH_MAX) { 5439 upperCase = CharacterDataLatin1.toUpperCaseCharArray(codePoint); 5440 } else { 5441 upperCase = CharacterData00.toUpperCaseCharArray(codePoint); 5442 } 5443 return upperCase; 5444 } 5445 5446 5452 public static final int SIZE = 16; 5453 5454 5462 public static char reverseBytes(char ch) { 5463 return (char) (((ch & 0xFF00) >> 8) | (ch << 8)); 5464 } 5465} 5466 | Popular Tags |