1 3 11 12 package java.lang; 13 14 16 17 class CharacterDataLatin1 { 18 19 54 55 static int getProperties(int ch) { 56 char offset = (char)ch; 57 int props = A[offset]; 58 return props; 59 } 60 61 static int getType(int ch) { 62 int props = getProperties(ch); 63 return (props & 0x1F); 64 } 65 66 static boolean isLowerCase(int ch) { 67 int type = getType(ch); 68 return (type == Character.LOWERCASE_LETTER); 69 } 70 71 static boolean isUpperCase(int ch) { 72 int type = getType(ch); 73 return (type == Character.UPPERCASE_LETTER); 74 } 75 76 static boolean isTitleCase(int ch) { 77 return false; 78 } 79 80 static boolean isDigit(int ch) { 81 int type = getType(ch); 82 return (type == Character.DECIMAL_DIGIT_NUMBER); 83 } 84 85 static boolean isDefined(int ch) { 86 int type = getType(ch); 87 return (type != Character.UNASSIGNED); 88 } 89 90 static boolean isLetter(int ch) { 91 int type = getType(ch); 92 return (((((1 << Character.UPPERCASE_LETTER) | 93 (1 << Character.LOWERCASE_LETTER) | 94 (1 << Character.TITLECASE_LETTER) | 95 (1 << Character.MODIFIER_LETTER) | 96 (1 << Character.OTHER_LETTER)) >> type) & 1) != 0); 97 } 98 99 static boolean isLetterOrDigit(int ch) { 100 int type = getType(ch); 101 return (((((1 << Character.UPPERCASE_LETTER) | 102 (1 << Character.LOWERCASE_LETTER) | 103 (1 << Character.TITLECASE_LETTER) | 104 (1 << Character.MODIFIER_LETTER) | 105 (1 << Character.OTHER_LETTER) | 106 (1 << Character.DECIMAL_DIGIT_NUMBER)) >> type) & 1) != 0); 107 } 108 109 static boolean isSpaceChar(int ch) { 110 int type = getType(ch); 111 return (((((1 << Character.SPACE_SEPARATOR) | 112 (1 << Character.LINE_SEPARATOR) | 113 (1 << Character.PARAGRAPH_SEPARATOR)) >> type) & 1) != 0); 114 } 115 116 117 static boolean isJavaIdentifierStart(int ch) { 118 int props = getProperties(ch); 119 return ((props & 0x00007000) >= 0x00005000); 120 } 121 122 static boolean isJavaIdentifierPart(int ch) { 123 int props = getProperties(ch); 124 return ((props & 0x00003000) != 0); 125 } 126 127 static boolean isUnicodeIdentifierStart(int ch) { 128 int props = getProperties(ch); 129 return ((props & 0x00007000) == 0x00007000); 130 } 131 132 static boolean isUnicodeIdentifierPart(int ch) { 133 int props = getProperties(ch); 134 return ((props & 0x00001000) != 0); 135 } 136 137 static boolean isIdentifierIgnorable(int ch) { 138 int props = getProperties(ch); 139 return ((props & 0x00007000) == 0x00001000); 140 } 141 142 static int toLowerCase(int ch) { 143 int mapChar = ch; 144 int val = getProperties(ch); 145 146 if (((val & 0x00020000) != 0) && 147 ((val & 0x07FC0000) != 0x07FC0000)) { 148 int offset = val << 5 >> (5+18); 149 mapChar = ch + offset; 150 } 151 return mapChar; 152 } 153 154 static int toUpperCase(int ch) { 155 int mapChar = ch; 156 int val = getProperties(ch); 157 158 if ((val & 0x00010000) != 0) { 159 if ((val & 0x07FC0000) != 0x07FC0000) { 160 int offset = val << 5 >> (5+18); 161 mapChar = ch - offset; 162 } else if (ch == 0x00B5) { 163 mapChar = 0x039C; 164 } 165 } 166 return mapChar; 167 } 168 169 static int toTitleCase(int ch) { 170 return toUpperCase(ch); 171 } 172 173 static int digit(int ch, int radix) { 174 int value = -1; 175 if (radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX) { 176 int val = getProperties(ch); 177 int kind = val & 0x1F; 178 if (kind == Character.DECIMAL_DIGIT_NUMBER) { 179 value = ch + ((val & 0x3E0) >> 5) & 0x1F; 180 } 181 else if ((val & 0xC00) == 0x00000C00) { 182 value = (ch + ((val & 0x3E0) >> 5) & 0x1F) + 10; 184 } 185 } 186 return (value < radix) ? value : -1; 187 } 188 189 static int getNumericValue(int ch) { 190 int val = getProperties(ch); 191 int retval = -1; 192 193 switch (val & 0xC00) { 194 default: case (0x00000000): retval = -1; 197 break; 198 case (0x00000400): retval = ch + ((val & 0x3E0) >> 5) & 0x1F; 200 break; 201 case (0x00000800) : retval = -2; 203 break; 204 case (0x00000C00): retval = (ch + ((val & 0x3E0) >> 5) & 0x1F) + 10; 206 break; 207 } 208 return retval; 209 } 210 211 static boolean isWhitespace(int ch) { 212 int props = getProperties(ch); 213 return ((props & 0x00007000) == 0x00004000); 214 } 215 216 static byte getDirectionality(int ch) { 217 int val = getProperties(ch); 218 byte directionality = (byte)((val & 0x78000000) >> 27); 219 220 if (directionality == 0xF ) { 221 directionality = -1; 222 } 223 return directionality; 224 } 225 226 static boolean isMirrored(int ch) { 227 int props = getProperties(ch); 228 return ((props & 0x80000000) != 0); 229 } 230 231 static int toUpperCaseEx(int ch) { 232 int mapChar = ch; 233 int val = getProperties(ch); 234 235 if ((val & 0x00010000) != 0) { 236 if ((val & 0x07FC0000) != 0x07FC0000) { 237 int offset = val << 5 >> (5+18); 238 mapChar = ch - offset; 239 } 240 else { 241 switch(ch) { 242 case 0x00B5 : mapChar = 0x039C; break; 244 default : mapChar = Character.ERROR; break; 245 } 246 } 247 } 248 return mapChar; 249 } 250 251 static char[] sharpsMap = new char[] {'S', 'S'}; 252 253 static char[] toUpperCaseCharArray(int ch) { 254 char[] upperMap = {(char)ch}; 255 if (ch == 0x00DF) { 256 upperMap = sharpsMap; 257 } 258 return upperMap; 259 } 260 261 262 266 static final int A[] = new int[256]; 267 static final String A_DATA = 268 "\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800"+ 269 "\u100F\u4800\u100F\u4800\u100F\u5800\u400F\u5000\u400F\u5800\u400F\u6000\u400F"+ 270 "\u5000\u400F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800"+ 271 "\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F"+ 272 "\u4800\u100F\u4800\u100F\u5000\u400F\u5000\u400F\u5000\u400F\u5800\u400F\u6000"+ 273 "\u400C\u6800\030\u6800\030\u2800\030\u2800\u601A\u2800\030\u6800\030\u6800"+ 274 "\030\uE800\025\uE800\026\u6800\030\u2800\031\u3800\030\u2800\024\u3800\030"+ 275 "\u2000\030\u1800\u3609\u1800\u3609\u1800\u3609\u1800\u3609\u1800\u3609\u1800"+ 276 "\u3609\u1800\u3609\u1800\u3609\u1800\u3609\u1800\u3609\u3800\030\u6800\030"+ 277 "\uE800\031\u6800\031\uE800\031\u6800\030\u6800\030\202\u7FE1\202\u7FE1\202"+ 278 "\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1"+ 279 "\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202"+ 280 "\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1"+ 281 "\202\u7FE1\uE800\025\u6800\030\uE800\026\u6800\033\u6800\u5017\u6800\033\201"+ 282 "\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2"+ 283 "\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201"+ 284 "\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2"+ 285 "\201\u7FE2\201\u7FE2\201\u7FE2\uE800\025\u6800\031\uE800\026\u6800\031\u4800"+ 286 "\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u5000\u100F"+ 287 "\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800"+ 288 "\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F"+ 289 "\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800"+ 290 "\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F"+ 291 "\u3800\014\u6800\030\u2800\u601A\u2800\u601A\u2800\u601A\u2800\u601A\u6800"+ 292 "\034\u6800\034\u6800\033\u6800\034\000\u7002\uE800\035\u6800\031\u6800\u1010"+ 293 "\u6800\034\u6800\033\u2800\034\u2800\031\u1800\u060B\u1800\u060B\u6800\033"+ 294 "\u07FD\u7002\u6800\034\u6800\030\u6800\033\u1800\u050B\000\u7002\uE800\036"+ 295 "\u6800\u080B\u6800\u080B\u6800\u080B\u6800\030\202\u7001\202\u7001\202\u7001"+ 296 "\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001\202"+ 297 "\u7001\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001"+ 298 "\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001\u6800\031\202\u7001\202"+ 299 "\u7001\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001\u07FD\u7002\201\u7002"+ 300 "\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201"+ 301 "\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002"+ 302 "\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\u6800"+ 303 "\031\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002"+ 304 "\u061D\u7002"; 305 306 308 static { 309 { char[] data = A_DATA.toCharArray(); 311 assert (data.length == (256 * 2)); 312 int i = 0, j = 0; 313 while (i < (256 * 2)) { 314 int entry = data[i++] << 16; 315 A[j++] = entry | data[i++]; 316 } 317 } 318 319 } 320 } 321 322 | Popular Tags |