1. // This file was generated AUTOMATICALLY from a template file Sun Feb 22 22:52:18 PST 2004
  2. /* @(#)CharacterDataLatin1.java.template 1.2 02/11/11
  3. *
  4. * Copyright 1994-2002 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package java.lang;
  11. /** The CharacterData class encapsulates the large tables found in
  12. Java.lang.Character. */
  13. class CharacterDataLatin1 {
  14. /* The character properties are currently encoded into 32 bits in the following manner:
  15. 1 bit mirrored property
  16. 4 bits directionality property
  17. 9 bits signed offset used for converting case
  18. 1 bit if 1, adding the signed offset converts the character to lowercase
  19. 1 bit if 1, subtracting the signed offset converts the character to uppercase
  20. 1 bit if 1, this character has a titlecase equivalent (possibly itself)
  21. 3 bits 0 may not be part of an identifier
  22. 1 ignorable control; may continue a Unicode identifier or Java identifier
  23. 2 may continue a Java identifier but not a Unicode identifier (unused)
  24. 3 may continue a Unicode identifier or Java identifier
  25. 4 is a Java whitespace character
  26. 5 may start or continue a Java identifier;
  27. may continue but not start a Unicode identifier (underscores)
  28. 6 may start or continue a Java identifier but not a Unicode identifier ($)
  29. 7 may start or continue a Unicode identifier or Java identifier
  30. Thus:
  31. 5, 6, 7 may start a Java identifier
  32. 1, 2, 3, 5, 6, 7 may continue a Java identifier
  33. 7 may start a Unicode identifier
  34. 1, 3, 5, 7 may continue a Unicode identifier
  35. 1 is ignorable within an identifier
  36. 4 is Java whitespace
  37. 2 bits 0 this character has no numeric property
  38. 1 adding the digit offset to the character code and then
  39. masking with 0x1F will produce the desired numeric value
  40. 2 this character has a "strange" numeric value
  41. 3 a Java supradecimal digit: adding the digit offset to the
  42. character code, then masking with 0x1F, then adding 10
  43. will produce the desired numeric value
  44. 5 bits digit offset
  45. 5 bits character type
  46. The encoding of character properties is subject to change at any time.
  47. */
  48. static int getProperties(char ch) {
  49. return A[ch];
  50. }
  51. static int getType(char ch) {
  52. return getProperties(ch) & 0x1F;
  53. }
  54. static boolean isLowerCase(char ch) {
  55. return getType(ch) == Character.LOWERCASE_LETTER;
  56. }
  57. static boolean isUpperCase(char ch) {
  58. return getType(ch) == Character.UPPERCASE_LETTER;
  59. }
  60. static boolean isTitleCase(char ch) {
  61. return false;
  62. }
  63. static boolean isDigit(char ch) {
  64. return getType(ch) == Character.DECIMAL_DIGIT_NUMBER;
  65. }
  66. static boolean isDefined(char ch) {
  67. return getType(ch) != Character.UNASSIGNED;
  68. }
  69. static boolean isLetter(char ch) {
  70. return (((((1 << Character.UPPERCASE_LETTER) |
  71. (1 << Character.LOWERCASE_LETTER) |
  72. (1 << Character.TITLECASE_LETTER) |
  73. (1 << Character.MODIFIER_LETTER) |
  74. (1 << Character.OTHER_LETTER)) >> getType(ch)) & 1) != 0);
  75. }
  76. static boolean isLetterOrDigit(char ch) {
  77. return (((((1 << Character.UPPERCASE_LETTER) |
  78. (1 << Character.LOWERCASE_LETTER) |
  79. (1 << Character.TITLECASE_LETTER) |
  80. (1 << Character.MODIFIER_LETTER) |
  81. (1 << Character.OTHER_LETTER) |
  82. (1 << Character.DECIMAL_DIGIT_NUMBER)) >> getType(ch)) & 1) != 0);
  83. }
  84. static boolean isSpaceChar(char ch) {
  85. return (((((1 << Character.SPACE_SEPARATOR) |
  86. (1 << Character.LINE_SEPARATOR) |
  87. (1 << Character.PARAGRAPH_SEPARATOR))
  88. >> getType(ch)) & 1) != 0);
  89. }
  90. static boolean isJavaIdentifierStart(char ch) {
  91. return (getProperties(ch) & 0x00007000) >= 0x00005000;
  92. }
  93. static boolean isJavaIdentifierPart(char ch) {
  94. return (getProperties(ch) & 0x00003000) != 0;
  95. }
  96. static boolean isUnicodeIdentifierStart(char ch) {
  97. return (getProperties(ch) & 0x00007000) == 0x00007000;
  98. }
  99. static boolean isUnicodeIdentifierPart(char ch) {
  100. return (getProperties(ch)& 0x00001000) != 0;
  101. }
  102. static boolean isIdentifierIgnorable(char ch) {
  103. return (getProperties(ch) & 0x00007000) == 0x00001000;
  104. }
  105. static char toLowerCase(char ch) {
  106. char mapChar = ch;
  107. int val = getProperties(ch);
  108. if (((val & 0x00020000) != 0) &&
  109. ((val & 0x07FC0000) != 0x07FC0000)) {
  110. int offset = val << 5 >> (5+18);
  111. mapChar = (char)(ch + offset);
  112. }
  113. return mapChar;
  114. }
  115. static char toUpperCase(char ch) {
  116. char mapChar = ch;
  117. int val = getProperties(ch);
  118. if ((val & 0x00010000) != 0) {
  119. if ((val & 0x07FC0000) != 0x07FC0000) {
  120. int offset = val << 5 >> (5+18);
  121. mapChar = (char)(ch - offset);
  122. } else if (ch == '\u00B5') {
  123. mapChar = '\u039C';
  124. }
  125. }
  126. return mapChar;
  127. }
  128. static char toTitleCase(char ch) {
  129. return toUpperCase(ch);
  130. }
  131. static int digit(char ch, int radix) {
  132. int value = -1;
  133. if (radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX) {
  134. int val = getProperties(ch);
  135. int kind = val & 0x1F;
  136. if (kind == Character.DECIMAL_DIGIT_NUMBER) {
  137. value = ch + ((val & 0x3E0) >> 5) & 0x1F;
  138. }
  139. else if ((val & 0xC00) == 0x00000C00) {
  140. // Java supradecimal digit
  141. value = (ch + ((val & 0x3E0) >> 5) & 0x1F) + 10;
  142. }
  143. }
  144. return (value < radix) ? value : -1;
  145. }
  146. static int getNumericValue(char ch) {
  147. int val = getProperties(ch);
  148. int retval = -1;
  149. switch (val & 0xC00) {
  150. default: // cannot occur
  151. case (0x00000000): // not numeric
  152. retval = -1;
  153. break;
  154. case (0x00000400): // simple numeric
  155. retval = ch + ((val & 0x3E0) >> 5) & 0x1F;
  156. break;
  157. case (0x00000800) : // "strange" numeric
  158. retval = -2;
  159. break;
  160. case (0x00000C00): // Java supradecimal
  161. retval = (ch + ((val & 0x3E0) >> 5) & 0x1F) + 10;
  162. break;
  163. }
  164. return retval;
  165. }
  166. static boolean isWhitespace(char ch) {
  167. return (getProperties(ch) & 0x00007000) == 0x00004000;
  168. }
  169. static byte getDirectionality(char ch) {
  170. int val = getProperties(ch);
  171. byte directionality = (byte)((val & 0x78000000) >> 27);
  172. if (directionality == 0xF ) {
  173. directionality = -1;
  174. }
  175. return directionality;
  176. }
  177. static boolean isMirrored(char ch) {
  178. return (getProperties(ch) & 0x80000000) != 0;
  179. }
  180. static char toUpperCaseEx(char ch) {
  181. char mapChar = ch;
  182. int val = getProperties(ch);
  183. if ((val & 0x00010000) != 0) {
  184. if ((val & 0x07FC0000) != 0x07FC0000) {
  185. int offset = val << 5 >> (5+18);
  186. mapChar = (char)(ch - offset);
  187. }
  188. else {
  189. switch(ch) {
  190. // map overflow characters
  191. case '\u00B5' : mapChar = '\u039C'; break;
  192. default : mapChar = Character.CHAR_ERROR; break;
  193. }
  194. }
  195. }
  196. return mapChar;
  197. }
  198. // The following tables and code generated using:
  199. // java GenerateCharacter -template ../../tools/GenerateCharacter/CharacterDataLatin1.java.template -spec ../../tools/GenerateCharacter/UnicodeData.txt -specialcasing ../../tools/GenerateCharacter/SpecialCasing.txt -o D:/BUILD_AREA/jdk142-update/ws/fcs/control/build/windows-i586/gensrc/java/lang/CharacterDataLatin1.java -string -usecharforbyte -latin1 8
  200. // The A table has 256 entries for a total of 1024 bytes.
  201. static final int A[] = new int[256];
  202. static final String A_DATA =
  203. "\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800"+
  204. "\u100F\u4800\u100F\u4800\u100F\u5800\u400F\u5000\u400F\u5800\u400F\u6000\u400F"+
  205. "\u5000\u400F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800"+
  206. "\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F"+
  207. "\u4800\u100F\u4800\u100F\u5000\u400F\u5000\u400F\u5000\u400F\u5800\u400F\u6000"+
  208. "\u400C\u6800\030\u6800\030\u2800\030\u2800\u601A\u2800\030\u6800\030\u6800"+
  209. "\030\uE800\025\uE800\026\u6800\030\u2800\031\u3800\030\u2800\024\u3800\030"+
  210. "\u2000\030\u1800\u3609\u1800\u3609\u1800\u3609\u1800\u3609\u1800\u3609\u1800"+
  211. "\u3609\u1800\u3609\u1800\u3609\u1800\u3609\u1800\u3609\u3800\030\u6800\030"+
  212. "\uE800\031\u6800\031\uE800\031\u6800\030\u6800\030\202\u7FE1\202\u7FE1\202"+
  213. "\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1"+
  214. "\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202"+
  215. "\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1\202\u7FE1"+
  216. "\202\u7FE1\uE800\025\u6800\030\uE800\026\u6800\033\u6800\u5017\u6800\033\201"+
  217. "\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2"+
  218. "\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201"+
  219. "\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2\201\u7FE2"+
  220. "\201\u7FE2\201\u7FE2\201\u7FE2\uE800\025\u6800\031\uE800\026\u6800\031\u4800"+
  221. "\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u5000\u100F"+
  222. "\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800"+
  223. "\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F"+
  224. "\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800"+
  225. "\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F\u4800\u100F"+
  226. "\u3800\014\u6800\030\u2800\u601A\u2800\u601A\u2800\u601A\u2800\u601A\u6800"+
  227. "\034\u6800\034\u6800\033\u6800\034\000\u7002\uE800\035\u6800\031\u6800\024"+
  228. "\u6800\034\u6800\033\u2800\034\u2800\031\u1800\u060B\u1800\u060B\u6800\033"+
  229. "\u07FD\u7002\u6800\034\u6800\030\u6800\033\u1800\u050B\000\u7002\uE800\036"+
  230. "\u6800\u080B\u6800\u080B\u6800\u080B\u6800\030\202\u7001\202\u7001\202\u7001"+
  231. "\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001\202"+
  232. "\u7001\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001"+
  233. "\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001\u6800\031\202\u7001\202"+
  234. "\u7001\202\u7001\202\u7001\202\u7001\202\u7001\202\u7001\u07FD\u7002\201\u7002"+
  235. "\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201"+
  236. "\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002"+
  237. "\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\u6800"+
  238. "\031\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002\201\u7002"+
  239. "\u061D\u7002";
  240. // In all, the character property tables require 1024 bytes.
  241. static {
  242. { // THIS CODE WAS AUTOMATICALLY CREATED BY GenerateCharacter:
  243. char[] data = A_DATA.toCharArray();
  244. assert (data.length == (256 * 2));
  245. int i = 0, j = 0;
  246. while (i < (256 * 2)) {
  247. int entry = data[i++] << 16;
  248. A[j++] = entry | data[i++];
  249. }
  250. }
  251. }
  252. }