1 |
/* java.lang.Character |
/* java.lang.Character -- Wrapper class for char, and Unicode subsets |
2 |
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. |
Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
7 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
8 |
the Free Software Foundation; either version 2, or (at your option) |
the Free Software Foundation; either version 2, or (at your option) |
9 |
any later version. |
any later version. |
10 |
|
|
11 |
GNU Classpath is distributed in the hope that it will be useful, but |
GNU Classpath is distributed in the hope that it will be useful, but |
12 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
46 |
* Wrapper class for the primitive char data type. In addition, |
* Wrapper class for the primitive char data type. In addition, |
47 |
* this class allows one to retrieve property information and |
* this class allows one to retrieve property information and |
48 |
* perform transformations on the 38,000+ characters in the |
* perform transformations on the 38,000+ characters in the |
49 |
* Unicode Standard, Version 2. java.lang.Character is designed |
* Unicode Standard, Version 2. java.lang.Character is designed |
50 |
* to be very dynamic, and as such, it retrieves information on |
* to be very dynamic, and as such, it retrieves information on |
51 |
* the Unicode character set from a separate database, which |
* the Unicode character set from a separate database, which |
52 |
* can be easily upgraded.<br> |
* can be easily upgraded. |
53 |
* <br> |
* |
54 |
* For predicates, boundaries are used to describe |
* <p>For predicates, boundaries are used to describe |
55 |
* the set of characters for which the method will return true. |
* the set of characters for which the method will return true. |
56 |
* This syntax uses fairly normal regular expression notation. |
* This syntax uses fairly normal regular expression notation. |
57 |
* See 5.13 of the Unicode Standard, Version 2.0, for the |
* See 5.13 of the Unicode Standard, Version 2.0, for the |
58 |
* boundary specification.<br> |
* boundary specification. |
59 |
* <br> |
* |
60 |
* See http://www.unicode.org for more information on the Unicode Standard. |
* <p><b>TODO: Update this class to Unicode Standard Version 3.0</b> |
61 |
|
* |
62 |
|
* <p>See <a href="http://www.unicode.org">http://www.unicode.org</a> |
63 |
|
* for more information on the Unicode Standard. |
64 |
* |
* |
65 |
* @author Paul N. Fisher |
* @author Paul N. Fisher |
66 |
* @since JDK1.0 |
* @author Eric Blake <ebb9@email.byu.edu> |
67 |
|
* @since 1.0 |
68 |
*/ |
*/ |
69 |
public final class Character implements Serializable, Comparable |
public final class Character implements Serializable, Comparable |
70 |
{ |
{ |
71 |
/** |
/** |
72 |
* Constants for character blocks. |
* Constants to define subsets of the Unicode standard. |
73 |
* All character blocks are part of the Unicode 2 standard, unless |
* All character blocks are part of the Unicode 2 standard, unless |
74 |
* otherwise noted. |
* otherwise noted. |
75 |
|
* |
76 |
|
* @author Paul N. Fisher |
77 |
|
* @author Eric Blake <ebb9@email.byu.edu> |
78 |
|
* @since 1.2 |
79 |
*/ |
*/ |
80 |
public static class Subset { |
public static class Subset |
81 |
|
{ |
82 |
|
/** |
83 |
|
* The start of the subset. |
84 |
|
*/ |
85 |
private char start; |
private char start; |
86 |
|
|
87 |
|
/** |
88 |
|
* The end of the subset. |
89 |
|
*/ |
90 |
private char end; |
private char end; |
91 |
|
|
92 |
|
/** |
93 |
|
* The number of defined subsets. |
94 |
|
*/ |
95 |
private static final int NUM_SUBSETS = 66; |
private static final int NUM_SUBSETS = 66; |
96 |
|
|
97 |
|
/** |
98 |
|
* The defined subsets. |
99 |
|
*/ |
100 |
private static final Subset sets[] = new Subset[NUM_SUBSETS]; |
private static final Subset sets[] = new Subset[NUM_SUBSETS]; |
101 |
|
|
102 |
/** |
/** |
103 |
* Returns the Unicode character block which a character belongs to. |
* Returns the Unicode character block which a character belongs to. |
104 |
|
* |
105 |
|
* @param ch the character to look up |
106 |
|
* @return the set it belongs to, or null |
107 |
*/ |
*/ |
108 |
private static Subset getBlock(char ch) { |
private static Subset getBlock(char ch) |
109 |
|
{ |
110 |
// do a simple binary search for the correct block |
// do a simple binary search for the correct block |
111 |
int low = 0; int hi = sets.length-1; int mid = 0; |
int low = 0; |
112 |
while (low <= hi) { |
int hi = sets.length - 1; |
113 |
mid = (low + hi) >> 1; |
int mid = 0; |
114 |
Subset b = sets[mid]; |
while (low <= hi) |
115 |
if (ch < b.start) |
{ |
116 |
hi = mid - 1; |
mid = (low + hi) >> 1; |
117 |
else if (ch > b.end) |
Subset b = sets[mid]; |
118 |
low = mid + 1; |
if (ch < b.start) |
119 |
else return b; |
hi = mid - 1; |
120 |
} |
else if (ch > b.end) |
121 |
|
low = mid + 1; |
122 |
|
else |
123 |
|
return b; |
124 |
|
} |
125 |
return null; |
return null; |
126 |
} |
} |
127 |
|
|
128 |
/** |
/** |
129 |
* Constructor for strictly defined normative blocks |
* Constructor for strictly defined normative blocks. |
130 |
|
* |
131 |
|
* @param num the position of this set |
132 |
|
* @param start the start character of the range |
133 |
|
* @param end the end character of the range |
134 |
*/ |
*/ |
135 |
private Subset(int num, char start, char end) { |
private Subset(int num, char start, char end) |
136 |
|
{ |
137 |
this.start = start; |
this.start = start; |
138 |
this.end = end; |
this.end = end; |
139 |
sets[num] = this; |
sets[num] = this; |
141 |
|
|
142 |
/** |
/** |
143 |
* Constructor for strictly defined blocks. |
* Constructor for strictly defined blocks. |
144 |
|
* |
145 |
|
* @param start the start character of the range |
146 |
|
* @param end the end character of the range |
147 |
*/ |
*/ |
148 |
private Subset(char start, char end) { |
private Subset(char start, char end) |
149 |
|
{ |
150 |
this.start = start; |
this.start = start; |
151 |
this.end = end; |
this.end = end; |
152 |
} |
} |
155 |
* Constructor for loosely defined CJK blocks |
* Constructor for loosely defined CJK blocks |
156 |
*/ |
*/ |
157 |
private Subset() { } |
private Subset() { } |
158 |
|
|
159 |
/** |
/** |
160 |
* U+0000 - U+007F |
* U+0000 - U+007F. |
161 |
*/ |
*/ |
162 |
public final static Subset BASIC_LATIN = new Subset(0, '\u0000', '\u007F'); |
public final static Subset BASIC_LATIN |
163 |
|
= new Subset(0, '\u0000', '\u007F'); |
164 |
|
|
165 |
/** |
/** |
166 |
* U+0080 - U+00FF |
* U+0080 - U+00FF. |
167 |
*/ |
*/ |
168 |
public final static Subset LATIN_1_SUPPLEMENT = new Subset(1, '\u0080', '\u00FF'); |
public final static Subset LATIN_1_SUPPLEMENT |
169 |
|
= new Subset(1, '\u0080', '\u00FF'); |
170 |
|
|
171 |
/** |
/** |
172 |
* U+0100 - U+017F |
* U+0100 - U+017F. |
173 |
*/ |
*/ |
174 |
public final static Subset LATIN_EXTENDED_A = new Subset(2, '\u0100', '\u017F'); |
public final static Subset LATIN_EXTENDED_A |
175 |
|
= new Subset(2, '\u0100', '\u017F'); |
176 |
|
|
177 |
/** |
/** |
178 |
* U+0180 - U+024F |
* U+0180 - U+024F. |
179 |
*/ |
*/ |
180 |
public final static Subset LATIN_EXTENDED_B = new Subset(3, '\u0180', '\u024F'); |
public final static Subset LATIN_EXTENDED_B |
181 |
|
= new Subset(3, '\u0180', '\u024F'); |
182 |
|
|
183 |
/** |
/** |
184 |
* U+0250 - U+02AF |
* U+0250 - U+02AF. |
185 |
*/ |
*/ |
186 |
public final static Subset IPA_EXTENSIONS = new Subset(4,'\u0250', '\u02AF'); |
public final static Subset IPA_EXTENSIONS |
187 |
|
= new Subset(4,'\u0250', '\u02AF'); |
188 |
|
|
189 |
/** |
/** |
190 |
* U+02B0 - U+02FF |
* U+02B0 - U+02FF. |
191 |
*/ |
*/ |
192 |
public final static Subset SPACING_MODIFIER_LETTERS = new Subset(5, '\u02B0', '\u02FF'); |
public final static Subset SPACING_MODIFIER_LETTERS |
193 |
|
= new Subset(5, '\u02B0', '\u02FF'); |
194 |
|
|
195 |
/** |
/** |
196 |
* U+0300 - U+036F |
* U+0300 - U+036F. |
197 |
*/ |
*/ |
198 |
public final static Subset COMBINING_DIACRITICAL_MARKS = new Subset(6, '\u0300', '\u036F'); |
public final static Subset COMBINING_DIACRITICAL_MARKS |
199 |
|
= new Subset(6, '\u0300', '\u036F'); |
200 |
|
|
201 |
/** |
/** |
202 |
* U+0370 - U+03FF |
* U+0370 - U+03FF. |
203 |
*/ |
*/ |
204 |
public final static Subset GREEK = new Subset(7, '\u0370', '\u03FF'); |
public final static Subset GREEK |
205 |
|
= new Subset(7, '\u0370', '\u03FF'); |
206 |
|
|
207 |
/** |
/** |
208 |
* U+0400 - U+04FF |
* U+0400 - U+04FF. |
209 |
*/ |
*/ |
210 |
public final static Subset CYRILLIC = new Subset(8, '\u0400', '\u04FF'); |
public final static Subset CYRILLIC |
211 |
|
= new Subset(8, '\u0400', '\u04FF'); |
212 |
|
|
213 |
/** |
/** |
214 |
* U+0530 - U+058F |
* U+0530 - U+058F. |
215 |
*/ |
*/ |
216 |
public final static Subset ARMENIAN = new Subset(9, '\u0530', '\u058F'); |
public final static Subset ARMENIAN |
217 |
|
= new Subset(9, '\u0530', '\u058F'); |
218 |
|
|
219 |
/** |
/** |
220 |
* U+0590 - U+05FF |
* U+0590 - U+05FF. |
221 |
*/ |
*/ |
222 |
public final static Subset HEBREW = new Subset(10, '\u0590', '\u05FF'); |
public final static Subset HEBREW |
223 |
/** |
= new Subset(10, '\u0590', '\u05FF'); |
224 |
* U+0600 - U+06FF |
|
225 |
|
/** |
226 |
|
* U+0600 - U+06FF. |
227 |
*/ |
*/ |
228 |
public final static Subset ARABIC = new Subset(11, '\u0600', '\u06FF'); |
public final static Subset ARABIC |
229 |
|
= new Subset(11, '\u0600', '\u06FF'); |
230 |
|
|
231 |
/** |
/** |
232 |
* U+0900 - U+097F |
* U+0900 - U+097F. |
233 |
*/ |
*/ |
234 |
public final static Subset DEVANAGARI = new Subset(12, '\u0900', '\u097F'); |
public final static Subset DEVANAGARI |
235 |
|
= new Subset(12, '\u0900', '\u097F'); |
236 |
|
|
237 |
/** |
/** |
238 |
* U+0980 - U+09FF |
* U+0980 - U+09FF. |
239 |
*/ |
*/ |
240 |
public final static Subset BENGALI = new Subset(13, '\u0980', '\u09FF'); |
public final static Subset BENGALI |
241 |
|
= new Subset(13, '\u0980', '\u09FF'); |
242 |
|
|
243 |
/** |
/** |
244 |
* U+0A00 - U+0A7F |
* U+0A00 - U+0A7F. |
245 |
*/ |
*/ |
246 |
public final static Subset GURMUKHI = new Subset(14, '\u0A00', '\u0A7F'); |
public final static Subset GURMUKHI |
247 |
|
= new Subset(14, '\u0A00', '\u0A7F'); |
248 |
|
|
249 |
/** |
/** |
250 |
* U+0A80 - U+0AFF |
* U+0A80 - U+0AFF. |
251 |
*/ |
*/ |
252 |
public final static Subset GUJARATI = new Subset(15, '\u0A80', '\u0AFF'); |
public final static Subset GUJARATI |
253 |
|
= new Subset(15, '\u0A80', '\u0AFF'); |
254 |
|
|
255 |
/** |
/** |
256 |
* U+0B00 - U+0B7F |
* U+0B00 - U+0B7F. |
257 |
*/ |
*/ |
258 |
public final static Subset ORIYA = new Subset(16, '\u0B00', '\u0B7F'); |
public final static Subset ORIYA |
259 |
|
= new Subset(16, '\u0B00', '\u0B7F'); |
260 |
|
|
261 |
/** |
/** |
262 |
* U+0B80 - U+0BFF |
* U+0B80 - U+0BFF. |
263 |
*/ |
*/ |
264 |
public final static Subset TAMIL = new Subset(17, '\u0B80', '\u0BFF'); |
public final static Subset TAMIL |
265 |
|
= new Subset(17, '\u0B80', '\u0BFF'); |
266 |
|
|
267 |
/** |
/** |
268 |
* U+0C00 - U+0C7F |
* U+0C00 - U+0C7F. |
269 |
*/ |
*/ |
270 |
public final static Subset TELUGU = new Subset(18, '\u0C00', '\u0C7F'); |
public final static Subset TELUGU |
271 |
|
= new Subset(18, '\u0C00', '\u0C7F'); |
272 |
|
|
273 |
/** |
/** |
274 |
* U+0C80 - U+0CFF |
* U+0C80 - U+0CFF. |
275 |
*/ |
*/ |
276 |
public final static Subset KANNADA = new Subset(19, '\u0C80', '\u0CFF'); |
public final static Subset KANNADA |
277 |
|
= new Subset(19, '\u0C80', '\u0CFF'); |
278 |
|
|
279 |
/** |
/** |
280 |
* U+0D00 - U+0D7F |
* U+0D00 - U+0D7F. |
281 |
*/ |
*/ |
282 |
public final static Subset MALAYALAM = new Subset(20, '\u0D00', '\u0D7F'); |
public final static Subset MALAYALAM |
283 |
|
= new Subset(20, '\u0D00', '\u0D7F'); |
284 |
|
|
285 |
/** |
/** |
286 |
* U+0E00 - U+0E7F |
* U+0E00 - U+0E7F. |
287 |
*/ |
*/ |
288 |
public final static Subset THAI = new Subset(21, '\u0E00', '\u0E7F'); |
public final static Subset THAI |
289 |
|
= new Subset(21, '\u0E00', '\u0E7F'); |
290 |
|
|
291 |
/** |
/** |
292 |
* U+0E80 - U+0EFF |
* U+0E80 - U+0EFF. |
293 |
*/ |
*/ |
294 |
public final static Subset LAO = new Subset(22, '\u0E80', '\u0EFF'); |
public final static Subset LAO |
295 |
|
= new Subset(22, '\u0E80', '\u0EFF'); |
296 |
|
|
297 |
/** |
/** |
298 |
* U+0F00 - U+0FBF |
* U+0F00 - U+0FBF. |
299 |
*/ |
*/ |
300 |
public final static Subset TIBETAN = new Subset(23, '\u0F00', '\u0FBF'); |
public final static Subset TIBETAN |
301 |
|
= new Subset(23, '\u0F00', '\u0FBF'); |
302 |
|
|
303 |
/** |
/** |
304 |
* U+10A0 - U+10FF |
* U+10A0 - U+10FF. |
305 |
*/ |
*/ |
306 |
public final static Subset GEORGIAN = new Subset(24, '\u10A0', '\u10FF'); |
public final static Subset GEORGIAN |
307 |
|
= new Subset(24, '\u10A0', '\u10FF'); |
308 |
|
|
309 |
/** |
/** |
310 |
* U+1100 - U+11FF |
* U+1100 - U+11FF. |
311 |
*/ |
*/ |
312 |
public final static Subset HANGUL_JAMO = new Subset(25, '\u1100', '\u11FF'); |
public final static Subset HANGUL_JAMO |
313 |
|
= new Subset(25, '\u1100', '\u11FF'); |
314 |
|
|
315 |
/** |
/** |
316 |
* U+1E00 - U+1EFF |
* U+1E00 - U+1EFF. |
317 |
*/ |
*/ |
318 |
public final static Subset LATIN_EXTENDED_ADDITIONAL = new Subset(26, '\u1E00', '\u1EFF'); |
public final static Subset LATIN_EXTENDED_ADDITIONAL |
319 |
|
= new Subset(26, '\u1E00', '\u1EFF'); |
320 |
|
|
321 |
/** |
/** |
322 |
* U+1F00 - U+1FFF |
* U+1F00 - U+1FFF. |
323 |
*/ |
*/ |
324 |
public final static Subset GREEK_EXTENDED = new Subset(27, '\u1F00', '\u1FFF'); |
public final static Subset GREEK_EXTENDED |
325 |
|
= new Subset(27, '\u1F00', '\u1FFF'); |
326 |
|
|
327 |
/** |
/** |
328 |
* U+2000 - U+206F |
* U+2000 - U+206F. |
329 |
*/ |
*/ |
330 |
public final static Subset GENERAL_PUNCTUATION = new Subset(28, '\u2000', '\u206F'); |
public final static Subset GENERAL_PUNCTUATION |
331 |
|
= new Subset(28, '\u2000', '\u206F'); |
332 |
|
|
333 |
/** |
/** |
334 |
* U+2070 - U+209F |
* U+2070 - U+209F. |
335 |
*/ |
*/ |
336 |
public final static Subset SUPERSCRIPTS_AND_SUBSCRIPTS = new Subset(29, '\u2070', '\u209F'); |
public final static Subset SUPERSCRIPTS_AND_SUBSCRIPTS |
337 |
|
= new Subset(29, '\u2070', '\u209F'); |
338 |
|
|
339 |
/** |
/** |
340 |
* U+20A0 - U+20CF |
* U+20A0 - U+20CF. |
341 |
*/ |
*/ |
342 |
public final static Subset CURRENCY_SYMBOLS = new Subset(30, '\u20A0', '\u20CF'); |
public final static Subset CURRENCY_SYMBOLS |
343 |
|
= new Subset(30, '\u20A0', '\u20CF'); |
344 |
|
|
345 |
/** |
/** |
346 |
* U+20D0 - U+20FF |
* U+20D0 - U+20FF. |
347 |
*/ |
*/ |
348 |
public final static Subset COMBINING_MARKS_FOR_SYMBOLS = new Subset(31, '\u20D0', '\u20FF'); |
public final static Subset COMBINING_MARKS_FOR_SYMBOLS |
349 |
|
= new Subset(31, '\u20D0', '\u20FF'); |
350 |
|
|
351 |
/** |
/** |
352 |
* U+2100 - U+214F |
* U+2100 - U+214F. |
353 |
*/ |
*/ |
354 |
public final static Subset LETTERLIKE_SYMBOLS = new Subset(32, '\u2100', '\u214F'); |
public final static Subset LETTERLIKE_SYMBOLS |
355 |
|
= new Subset(32, '\u2100', '\u214F'); |
356 |
|
|
357 |
/** |
/** |
358 |
* U+2150 - U+218F |
* U+2150 - U+218F. |
359 |
*/ |
*/ |
360 |
public final static Subset NUMBER_FORMS = new Subset(33, '\u2150', '\u218F'); |
public final static Subset NUMBER_FORMS |
361 |
|
= new Subset(33, '\u2150', '\u218F'); |
362 |
|
|
363 |
/** |
/** |
364 |
* U+2190 - U+21FF |
* U+2190 - U+21FF. |
365 |
*/ |
*/ |
366 |
public final static Subset ARROWS = new Subset(34, '\u2190', '\u21FF'); |
public final static Subset ARROWS |
367 |
|
= new Subset(34, '\u2190', '\u21FF'); |
368 |
|
|
369 |
/** |
/** |
370 |
* U+2200 - U+22FF |
* U+2200 - U+22FF. |
371 |
*/ |
*/ |
372 |
public final static Subset MATHEMATICAL_OPERATORS = new Subset(35, '\u2200', '\u22FF'); |
public final static Subset MATHEMATICAL_OPERATORS |
373 |
|
= new Subset(35, '\u2200', '\u22FF'); |
374 |
|
|
375 |
/** |
/** |
376 |
* U+2300 - U+23FF |
* U+2300 - U+23FF. |
377 |
*/ |
*/ |
378 |
public final static Subset MISCELLANEOUS_TECHNICAL = new Subset(36, '\u2300', '\u23FF'); |
public final static Subset MISCELLANEOUS_TECHNICAL |
379 |
|
= new Subset(36, '\u2300', '\u23FF'); |
380 |
|
|
381 |
/** |
/** |
382 |
* U+2400 - U+243F |
* U+2400 - U+243F. |
383 |
*/ |
*/ |
384 |
public final static Subset CONTROL_PICTURES = new Subset(37, '\u2400', '\u243F'); |
public final static Subset CONTROL_PICTURES |
385 |
|
= new Subset(37, '\u2400', '\u243F'); |
386 |
|
|
387 |
/** |
/** |
388 |
* U+2440 - U+245F |
* U+2440 - U+245F. |
389 |
*/ |
*/ |
390 |
public final static Subset OPTICAL_CHARACTER_RECOGNITION = new Subset(38, '\u2440', '\u245F'); |
public final static Subset OPTICAL_CHARACTER_RECOGNITION |
391 |
|
= new Subset(38, '\u2440', '\u245F'); |
392 |
|
|
393 |
/** |
/** |
394 |
* U+2460 - U+24FF |
* U+2460 - U+24FF. |
395 |
*/ |
*/ |
396 |
public final static Subset ENCLOSED_ALPHANUMERICS = new Subset(39, '\u2460', '\u24FF'); |
public final static Subset ENCLOSED_ALPHANUMERICS |
397 |
|
= new Subset(39, '\u2460', '\u24FF'); |
398 |
|
|
399 |
/** |
/** |
400 |
* U+2500 - U+257F |
* U+2500 - U+257F. |
401 |
*/ |
*/ |
402 |
public final static Subset BOX_DRAWING = new Subset(40, '\u2500', '\u257F'); |
public final static Subset BOX_DRAWING |
403 |
|
= new Subset(40, '\u2500', '\u257F'); |
404 |
|
|
405 |
/** |
/** |
406 |
* U+2580 - U+259F |
* U+2580 - U+259F. |
407 |
*/ |
*/ |
408 |
public final static Subset BLOCK_ELEMENTS = new Subset(41, '\u2580', '\u259F'); |
public final static Subset BLOCK_ELEMENTS |
409 |
|
= new Subset(41, '\u2580', '\u259F'); |
410 |
|
|
411 |
/** |
/** |
412 |
* U+25A0 - U+25FF |
* U+25A0 - U+25FF. |
413 |
*/ |
*/ |
414 |
public final static Subset GEOMETRIC_SHAPES = new Subset(42, '\u25A0', '\u25FF'); |
public final static Subset GEOMETRIC_SHAPES |
415 |
|
= new Subset(42, '\u25A0', '\u25FF'); |
416 |
|
|
417 |
/** |
/** |
418 |
* U+2600 - U+26FF |
* U+2600 - U+26FF. |
419 |
*/ |
*/ |
420 |
public final static Subset MISCELLANEOUS_SYMBOLS = new Subset(43, '\u2600', '\u26FF'); |
public final static Subset MISCELLANEOUS_SYMBOLS |
421 |
|
= new Subset(43, '\u2600', '\u26FF'); |
422 |
|
|
423 |
/** |
/** |
424 |
* U+2700 - U+27BF |
* U+2700 - U+27BF. |
425 |
*/ |
*/ |
426 |
public final static Subset DINGBATS = new Subset(44, '\u2700', '\u27BF'); |
public final static Subset DINGBATS |
427 |
|
= new Subset(44, '\u2700', '\u27BF'); |
428 |
|
|
429 |
/** |
/** |
430 |
* U+3000 - U+303F |
* U+3000 - U+303F. |
431 |
*/ |
*/ |
432 |
public final static Subset CJK_SYMBOLS_AND_PUNCTUATION = new Subset(45, '\u3000', '\u303F'); |
public final static Subset CJK_SYMBOLS_AND_PUNCTUATION |
433 |
|
= new Subset(45, '\u3000', '\u303F'); |
434 |
|
|
435 |
/** |
/** |
436 |
* U+3040 - U+309F |
* U+3040 - U+309F. |
437 |
*/ |
*/ |
438 |
public final static Subset HIRAGANA = new Subset(46, '\u3040', '\u309F'); |
public final static Subset HIRAGANA |
439 |
|
= new Subset(46, '\u3040', '\u309F'); |
440 |
|
|
441 |
/** |
/** |
442 |
* U+30A0 - U+30FF |
* U+30A0 - U+30FF. |
443 |
*/ |
*/ |
444 |
public final static Subset KATAKANA = new Subset(47, '\u30A0', '\u30FF'); |
public final static Subset KATAKANA |
445 |
|
= new Subset(47, '\u30A0', '\u30FF'); |
446 |
|
|
447 |
/** |
/** |
448 |
* U+3100 - U+312F |
* U+3100 - U+312F. |
449 |
*/ |
*/ |
450 |
public final static Subset BOPOMOFO = new Subset(48, '\u3100', '\u312F'); |
public final static Subset BOPOMOFO |
451 |
|
= new Subset(48, '\u3100', '\u312F'); |
452 |
|
|
453 |
/** |
/** |
454 |
* U+3130 - U+318F |
* U+3130 - U+318F. |
455 |
*/ |
*/ |
456 |
public final static Subset HANGUL_COMPATIBILITY_JAMO = new Subset(49, '\u3130', '\u318F'); |
public final static Subset HANGUL_COMPATIBILITY_JAMO |
457 |
|
= new Subset(49, '\u3130', '\u318F'); |
458 |
|
|
459 |
/** |
/** |
460 |
* U+3190 - U+319F |
* U+3190 - U+319F. |
461 |
*/ |
*/ |
462 |
public final static Subset KANBUN = new Subset(50, '\u3190', '\u319F'); |
public final static Subset KANBUN |
463 |
|
= new Subset(50, '\u3190', '\u319F'); |
464 |
|
|
465 |
/** |
/** |
466 |
* U+3200 - U+32FF |
* U+3200 - U+32FF. |
467 |
*/ |
*/ |
468 |
public final static Subset ENCLOSED_CJK_LETTERS_AND_MONTHS = new Subset(51, '\u3200', '\u32FF'); |
public final static Subset ENCLOSED_CJK_LETTERS_AND_MONTHS |
469 |
|
= new Subset(51, '\u3200', '\u32FF'); |
470 |
|
|
471 |
/** |
/** |
472 |
* U+3300 - U+33FF |
* U+3300 - U+33FF. |
473 |
*/ |
*/ |
474 |
public final static Subset CJK_COMPATIBILITY = new Subset(52, '\u3300', '\u33FF'); |
public final static Subset CJK_COMPATIBILITY |
475 |
|
= new Subset(52, '\u3300', '\u33FF'); |
476 |
|
|
477 |
/** |
/** |
478 |
* U+4E00 - U+9FFF |
* U+4E00 - U+9FFF. |
479 |
*/ |
*/ |
480 |
public final static Subset CJK_UNIFIED_IDEOGRAPHS = new Subset(53, '\u4E00', '\u9FFF'); |
public final static Subset CJK_UNIFIED_IDEOGRAPHS |
481 |
|
= new Subset(53, '\u4E00', '\u9FFF'); |
482 |
|
|
483 |
/** |
/** |
484 |
* U+AC00 - U+D7A3 |
* U+AC00 - U+D7A3. |
485 |
*/ |
*/ |
486 |
public final static Subset HANGUL_SYLLABLES = new Subset(54, '\uAC00', '\uD7A3'); |
public final static Subset HANGUL_SYLLABLES |
487 |
|
= new Subset(54, '\uAC00', '\uD7A3'); |
488 |
|
|
489 |
/** |
/** |
490 |
* SURROGATES combines the following 3 Unicode character blocks:<br> |
* SURROGATES combines the following 3 Unicode character blocks:<br> |
492 |
* High Private Use Surrogates: U+DB80 - U+DBFF<br> |
* High Private Use Surrogates: U+DB80 - U+DBFF<br> |
493 |
* Low Surrogates: U+DC00 - U+DFFF |
* Low Surrogates: U+DC00 - U+DFFF |
494 |
*/ |
*/ |
495 |
public final static Subset SURROGATES = new Subset(55, '\uD800', '\uDFFF'); |
public final static Subset SURROGATES |
496 |
|
= new Subset(55, '\uD800', '\uDFFF'); |
497 |
|
|
498 |
/** |
/** |
499 |
* U+E000 - U+F8FF |
* U+E000 - U+F8FF. |
500 |
*/ |
*/ |
501 |
public final static Subset PRIVATE_USE = new Subset(56, '\uE000', '\uF8FF'); |
public final static Subset PRIVATE_USE |
502 |
|
= new Subset(56, '\uE000', '\uF8FF'); |
503 |
|
|
504 |
/** |
/** |
505 |
* U+F900 - U+FAFF |
* U+F900 - U+FAFF. |
506 |
*/ |
*/ |
507 |
public final static Subset CJK_COMPATIBILITY_IDEOGRAPHS = new Subset(57, '\uF900', '\uFAFF'); |
public final static Subset CJK_COMPATIBILITY_IDEOGRAPHS |
508 |
|
= new Subset(57, '\uF900', '\uFAFF'); |
509 |
|
|
510 |
/** |
/** |
511 |
* U+FB00 - U+FB4F |
* U+FB00 - U+FB4F. |
512 |
*/ |
*/ |
513 |
public final static Subset ALPHABETIC_PRESENTATION_FORMS = new Subset(58, '\uFB00', '\uFB4F'); |
public final static Subset ALPHABETIC_PRESENTATION_FORMS |
514 |
|
= new Subset(58, '\uFB00', '\uFB4F'); |
515 |
|
|
516 |
/** |
/** |
517 |
* U+FB50 - U+FDFF |
* U+FB50 - U+FDFF. |
518 |
*/ |
*/ |
519 |
public final static Subset ARABIC_PRESENTATION_FORMS_A = new Subset(59, '\uFB50', '\uFDFF'); |
public final static Subset ARABIC_PRESENTATION_FORMS_A |
520 |
|
= new Subset(59, '\uFB50', '\uFDFF'); |
521 |
|
|
522 |
/** |
/** |
523 |
* U+FE20 - U+FE2F |
* U+FE20 - U+FE2F. |
524 |
*/ |
*/ |
525 |
public final static Subset COMBINING_HALF_MARKS = new Subset(60, '\uFE20', '\uFE2F'); |
public final static Subset COMBINING_HALF_MARKS |
526 |
|
= new Subset(60, '\uFE20', '\uFE2F'); |
527 |
|
|
528 |
/** |
/** |
529 |
* U+FE30 - U+FE4F |
* U+FE30 - U+FE4F. |
530 |
*/ |
*/ |
531 |
public final static Subset CJK_COMPATIBILITY_FORMS = new Subset(61, '\uFE30', '\uFE4F'); |
public final static Subset CJK_COMPATIBILITY_FORMS |
532 |
|
= new Subset(61, '\uFE30', '\uFE4F'); |
533 |
|
|
534 |
/** |
/** |
535 |
* U+FE50 - U+FE6F |
* U+FE50 - U+FE6F. |
536 |
*/ |
*/ |
537 |
public final static Subset SMALL_FORM_VARIANTS = new Subset(62, '\uFE50', '\uFE6F'); |
public final static Subset SMALL_FORM_VARIANTS |
538 |
|
= new Subset(62, '\uFE50', '\uFE6F'); |
539 |
|
|
540 |
/** |
/** |
541 |
* U+FE70 - U+FEFF |
* U+FE70 - U+FEFF. |
542 |
*/ |
*/ |
543 |
public final static Subset ARABIC_PRESENTATION_FORMS_B = new Subset(63, '\uFE70', '\uFEFF'); |
public final static Subset ARABIC_PRESENTATION_FORMS_B |
544 |
|
= new Subset(63, '\uFE70', '\uFEFF'); |
545 |
|
|
546 |
/** |
/** |
547 |
* U+FF00 - U+FFEF |
* U+FF00 - U+FFEF. |
548 |
*/ |
*/ |
549 |
public final static Subset HALFWIDTH_AND_FULLWIDTH_FORMS = new Subset(64, '\uFF00', '\uFFEF'); |
public final static Subset HALFWIDTH_AND_FULLWIDTH_FORMS |
550 |
|
= new Subset(64, '\uFF00', '\uFFEF'); |
551 |
|
|
552 |
/** |
/** |
553 |
* SPECIALS combine the following two Unicode character blocks:<br> |
* SPECIALS combine the following two Unicode character blocks:<br> |
554 |
* SPECIALS: U+FEFF - U+FEFF<br> |
* SPECIALS: U+FEFF - U+FEFF<br> |
555 |
* SPECIALS: U+FFF0 - U+FFFF |
* SPECIALS: U+FFF0 - U+FFFF |
556 |
*/ |
*/ |
557 |
public final static Subset SPECIALS = new Subset(65, '\uFEFF', '\uFFFF'); |
public final static Subset SPECIALS |
558 |
|
= new Subset(65, '\uFEFF', '\uFFFF'); |
559 |
|
|
560 |
/** |
/** |
561 |
* All Latin character blocks combined into one. |
* All Latin character blocks combined into one. |
562 |
* Informative block added by Sun. |
* Informative block added by Sun. |
563 |
* U+0000 - U+024F |
* U+0000 - U+024F |
564 |
*/ |
*/ |
565 |
public final static Subset LATIN = new Subset('\u0000', '\u024F'); |
public final static Subset LATIN |
566 |
|
= new Subset('\u0000', '\u024F'); |
567 |
|
|
568 |
/** |
/** |
569 |
* All Latin digits. |
* All Latin digits. |
570 |
* Informative block added by Sun. |
* Informative block added by Sun. |
571 |
* U+0030 - U+0039 |
* U+0030 - U+0039 |
572 |
*/ |
*/ |
573 |
public final static Subset LATIN_DIGITS = new Subset('\u0030', '\u0039'); |
public final static Subset LATIN_DIGITS |
574 |
|
= new Subset('\u0030', '\u0039'); |
575 |
|
|
576 |
/** |
/** |
577 |
* Halfwidth Katakana characters. |
* Halfwidth Katakana characters. |
578 |
* Informative block added by Sun. |
* Informative block added by Sun. |
579 |
* U+FF60 - U+FF9F |
* U+FF60 - U+FF9F |
580 |
*/ |
*/ |
581 |
public final static Subset HALFWIDTH_KATAKANA = new Subset('\uFF60', '\uFF9F'); |
public final static Subset HALFWIDTH_KATAKANA |
582 |
|
= new Subset('\uFF60', '\uFF9F'); |
583 |
|
|
584 |
/** |
/** |
585 |
* All Han characters used for writing traditional Chinese. |
* All Han characters used for writing traditional Chinese. |
586 |
* Loosely defined as Unicode characters which |
* Loosely defined as Unicode characters which |
588 |
* Informative block added by Sun. |
* Informative block added by Sun. |
589 |
*/ |
*/ |
590 |
public final static Subset TRADITIONAL_HANZI = new Subset(); |
public final static Subset TRADITIONAL_HANZI = new Subset(); |
591 |
|
|
592 |
/** |
/** |
593 |
* All Han characters used for writing simplified Chinese. |
* All Han characters used for writing simplified Chinese. |
594 |
* Loosely defined as Unicode characters which |
* Loosely defined as Unicode characters which |
596 |
* Informative block added by Sun. |
* Informative block added by Sun. |
597 |
*/ |
*/ |
598 |
public final static Subset SIMPLIFIED_HANZI = new Subset(); |
public final static Subset SIMPLIFIED_HANZI = new Subset(); |
599 |
|
|
600 |
/** |
/** |
601 |
* All Han characters used for writing Japanese. |
* All Han characters used for writing Japanese. |
602 |
* Loosely defined as Unicode characters which |
* Loosely defined as Unicode characters which |
604 |
* Informative block added by Sun. |
* Informative block added by Sun. |
605 |
*/ |
*/ |
606 |
public final static Subset KANJI = new Subset(); |
public final static Subset KANJI = new Subset(); |
607 |
|
|
608 |
/** |
/** |
609 |
* All Han characters used for writing Korean. |
* All Han characters used for writing Korean. |
610 |
* Loosely defined as Unicode characters which |
* Loosely defined as Unicode characters which |
612 |
* Informative block added by Sun. |
* Informative block added by Sun. |
613 |
*/ |
*/ |
614 |
public final static Subset HANJA = new Subset(); |
public final static Subset HANJA = new Subset(); |
615 |
}; |
} // class Subset |
616 |
|
|
617 |
|
/** |
618 |
|
* A family of character subsets in the Unicode specification. A character |
619 |
|
* is in at most one of these blocks. |
620 |
|
* |
621 |
|
* @since 1.2 |
622 |
|
* TODO: Add class UnicodeBlock |
623 |
|
*/ |
624 |
|
// class UnicodeBlock |
625 |
|
|
626 |
/** |
/** |
627 |
* The immutable value of this Character. |
* The immutable value of this Character. |
628 |
*/ |
*/ |
629 |
private final char value; |
private final char value; |
630 |
|
|
631 |
|
/** |
632 |
|
* Compatible with JDK 1.0+. |
633 |
|
*/ |
634 |
static final long serialVersionUID = 3786198910865385080L; |
static final long serialVersionUID = 3786198910865385080L; |
635 |
|
|
636 |
/** |
/** |
637 |
* The minimum value the char data type can hold. |
* Smallest value allowed for radix arguments in Java. This value is 2. |
638 |
* This value is U+0000. |
* |
639 |
|
* @see #digit(char, int) |
640 |
|
* @see #forDigit(int, int) |
641 |
|
* @see Integer#toString(int, int) |
642 |
|
* @see Integer#valueOf(String) |
643 |
*/ |
*/ |
644 |
public static final char MIN_VALUE = '\u0000'; |
public static final int MIN_RADIX = 2; |
645 |
|
|
646 |
/** |
/** |
647 |
* The maximum value the char data type can hold. |
* Largest value allowed for radix arguments in Java. This value is 36. |
648 |
* This value is U+FFFF. |
* |
649 |
|
* @see #digit(char, int) |
650 |
|
* @see #forDigit(int, int) |
651 |
|
* @see Integer#toString(int, int) |
652 |
|
* @see Integer#valueOf(String) |
653 |
*/ |
*/ |
654 |
public static final char MAX_VALUE = '\uFFFF'; |
public static final int MAX_RADIX = 36; |
655 |
|
|
656 |
/** |
/** |
657 |
* Smallest value allowed for radix arguments in Java. |
* The minimum value the char data type can hold. |
658 |
* This value is 2. |
* This value is <code>'\\u0000'</code>. |
659 |
*/ |
*/ |
660 |
public static final int MIN_RADIX = 2; |
public static final char MIN_VALUE = '\u0000'; |
661 |
|
|
662 |
/** |
/** |
663 |
* Largest value allowed for radix arguments in Java. |
* The maximum value the char data type can hold. |
664 |
* This value is 36. |
* This value is <code>'\\uFFFF'</code>. |
665 |
*/ |
*/ |
666 |
public static final int MAX_RADIX = 36; |
public static final char MAX_VALUE = '\uFFFF'; |
667 |
|
|
668 |
/** |
/** |
669 |
* Class object representing the primitive char data type. |
* Class object representing the primitive char data type. |
670 |
|
* |
671 |
|
* @since 1.1 |
672 |
*/ |
*/ |
673 |
public static final Class TYPE = VMClassLoader.getPrimitiveClass('C'); |
public static final Class TYPE = VMClassLoader.getPrimitiveClass('C'); |
674 |
|
|
675 |
/** |
/** |
676 |
* Cn = Other, Not Assigned (Normative) |
* Lu = Letter, Uppercase (Informative). |
677 |
*/ |
* |
678 |
public static final byte UNASSIGNED = 0; |
* @since 1.1 |
|
/** |
|
|
* Lu = Letter, Uppercase (Informative) |
|
679 |
*/ |
*/ |
680 |
public static final byte UPPERCASE_LETTER = 1; |
public static final byte UPPERCASE_LETTER = 1; |
681 |
|
|
682 |
/** |
/** |
683 |
* Ll = Letter, Lowercase (Informative) |
* Ll = Letter, Lowercase (Informative). |
684 |
|
* |
685 |
|
* @since 1.1 |
686 |
*/ |
*/ |
687 |
public static final byte LOWERCASE_LETTER = 2; |
public static final byte LOWERCASE_LETTER = 2; |
688 |
|
|
689 |
/** |
/** |
690 |
* Lt = Letter, Titlecase (Informative) |
* Lt = Letter, Titlecase (Informative). |
691 |
|
* |
692 |
|
* @since 1.1 |
693 |
*/ |
*/ |
694 |
public static final byte TITLECASE_LETTER = 3; |
public static final byte TITLECASE_LETTER = 3; |
695 |
|
|
696 |
/** |
/** |
697 |
* Lm = Letter, Modifier (Informative) |
* Mn = Mark, Non-Spacing (Normative). |
698 |
*/ |
* |
699 |
public static final byte MODIFIER_LETTER = 4; |
* @since 1.1 |
|
/** |
|
|
* Lo = Letter, Other (Informative) |
|
|
*/ |
|
|
public static final byte OTHER_LETTER = 5; |
|
|
/** |
|
|
* Mn = Mark, Non-Spacing (Normative) |
|
700 |
*/ |
*/ |
701 |
public static final byte NON_SPACING_MARK = 6; |
public static final byte NON_SPACING_MARK = 6; |
702 |
|
|
703 |
/** |
/** |
704 |
* Me = Mark, Enclosing (Normative) |
* Mc = Mark, Spacing Combining (Normative). |
705 |
|
* |
706 |
|
* @since 1.1 |
707 |
*/ |
*/ |
708 |
public static final byte ENCLOSING_MARK = 7; |
public static final byte COMBINING_SPACING_MARK = 8; |
709 |
|
|
710 |
/** |
/** |
711 |
* Mc = Mark, Spacing Combining (Normative) |
* Me = Mark, Enclosing (Normative). |
712 |
|
* |
713 |
|
* @since 1.1 |
714 |
*/ |
*/ |
715 |
public static final byte COMBINING_SPACING_MARK = 8; |
public static final byte ENCLOSING_MARK = 7; |
716 |
|
|
717 |
/** |
/** |
718 |
* Nd = Number, Decimal Digit (Normative) |
* Nd = Number, Decimal Digit (Normative). |
719 |
|
* |
720 |
|
* @since 1.1 |
721 |
*/ |
*/ |
722 |
public static final byte DECIMAL_DIGIT_NUMBER = 9; |
public static final byte DECIMAL_DIGIT_NUMBER = 9; |
723 |
|
|
724 |
/** |
/** |
725 |
* Nl = Number, Letter (Normative) |
* Nl = Number, Letter (Normative). |
726 |
|
* |
727 |
|
* @since 1.1 |
728 |
*/ |
*/ |
729 |
public static final byte LETTER_NUMBER = 10; |
public static final byte LETTER_NUMBER = 10; |
730 |
|
|
731 |
/** |
/** |
732 |
* No = Number, Other (Normative) |
* No = Number, Other (Normative). |
733 |
|
* |
734 |
|
* @since 1.1 |
735 |
*/ |
*/ |
736 |
public static final byte OTHER_NUMBER = 11; |
public static final byte OTHER_NUMBER = 11; |
737 |
|
|
738 |
/** |
/** |
739 |
* Zs = Separator, Space (Normative) |
* Zs = Separator, Space (Normative). |
740 |
|
* |
741 |
|
* @since 1.1 |
742 |
*/ |
*/ |
743 |
public static final byte SPACE_SEPARATOR = 12; |
public static final byte SPACE_SEPARATOR = 12; |
744 |
|
|
745 |
/** |
/** |
746 |
* Zl = Separator, Line (Normative) |
* Zl = Separator, Line (Normative). |
747 |
|
* |
748 |
|
* @since 1.1 |
749 |
*/ |
*/ |
750 |
public static final byte LINE_SEPARATOR = 13; |
public static final byte LINE_SEPARATOR = 13; |
751 |
|
|
752 |
/** |
/** |
753 |
* Zp = Separator, Paragraph (Normative) |
* Zp = Separator, Paragraph (Normative). |
754 |
|
* |
755 |
|
* @since 1.1 |
756 |
*/ |
*/ |
757 |
public static final byte PARAGRAPH_SEPARATOR = 14; |
public static final byte PARAGRAPH_SEPARATOR = 14; |
758 |
|
|
759 |
/** |
/** |
760 |
* Cc = Other, Control (Normative) |
* Cc = Other, Control (Normative). |
761 |
|
* |
762 |
|
* @since 1.1 |
763 |
*/ |
*/ |
764 |
public static final byte CONTROL = 15; |
public static final byte CONTROL = 15; |
765 |
|
|
766 |
/** |
/** |
767 |
* Cf = Other, Format (Normative) |
* Cf = Other, Format (Normative). |
768 |
|
* |
769 |
|
* @since 1.1 |
770 |
*/ |
*/ |
771 |
public static final byte FORMAT = 16; |
public static final byte FORMAT = 16; |
772 |
|
|
773 |
// 17 is skipped (don't ask me why) |
/** |
774 |
|
* Cs = Other, Surrogate (Normative). |
775 |
|
* |
776 |
|
* @since 1.1 |
777 |
|
*/ |
778 |
|
public static final byte SURROGATE = 19; |
779 |
|
|
780 |
/** |
/** |
781 |
* Co = Other, Private Use (Normative) |
* Co = Other, Private Use (Normative). |
782 |
|
* |
783 |
|
* @since 1.1 |
784 |
*/ |
*/ |
785 |
public static final byte PRIVATE_USE = 18; |
public static final byte PRIVATE_USE = 18; |
786 |
|
|
787 |
/** |
/** |
788 |
* Cs = Other, Surrogate (Normative) |
* Cn = Other, Not Assigned (Normative). |
789 |
|
* |
790 |
|
* @since 1.1 |
791 |
*/ |
*/ |
792 |
public static final byte SURROGATE = 19; |
public static final byte UNASSIGNED = 0; |
793 |
|
|
794 |
/** |
/** |
795 |
* Pd = Punctuation, Dash (Informative) |
* Lm = Letter, Modifier (Informative). |
796 |
|
* |
797 |
|
* @since 1.1 |
798 |
|
*/ |
799 |
|
public static final byte MODIFIER_LETTER = 4; |
800 |
|
|
801 |
|
/** |
802 |
|
* Lo = Letter, Other (Informative). |
803 |
|
* |
804 |
|
* @since 1.1 |
805 |
|
*/ |
806 |
|
public static final byte OTHER_LETTER = 5; |
807 |
|
|
808 |
|
/** |
809 |
|
* Pc = Punctuation, Connector (Informative). |
810 |
|
* |
811 |
|
* @since 1.1 |
812 |
|
*/ |
813 |
|
public static final byte CONNECTOR_PUNCTUATION = 23; |
814 |
|
|
815 |
|
/** |
816 |
|
* Pd = Punctuation, Dash (Informative). |
817 |
|
* |
818 |
|
* @since 1.1 |
819 |
*/ |
*/ |
820 |
public static final byte DASH_PUNCTUATION = 20; |
public static final byte DASH_PUNCTUATION = 20; |
821 |
|
|
822 |
/** |
/** |
823 |
* Ps = Punctuation, Open (Informative) |
* Ps = Punctuation, Open (Informative). |
824 |
|
* |
825 |
|
* @since 1.1 |
826 |
*/ |
*/ |
827 |
public static final byte START_PUNCTUATION = 21; |
public static final byte START_PUNCTUATION = 21; |
828 |
|
|
829 |
/** |
/** |
830 |
* Pe = Punctuation, Close (Informative) |
* Pe = Punctuation, Close (Informative). |
831 |
|
* |
832 |
|
* @since 1.1 |
833 |
*/ |
*/ |
834 |
public static final byte END_PUNCTUATION = 22; |
public static final byte END_PUNCTUATION = 22; |
835 |
|
|
836 |
/** |
/** |
837 |
* Pc = Punctuation, Connector (Informative) |
* TODO: Add INITIAL_QUOTE_PUNCTUATION. |
838 |
|
* Pi = ???. |
839 |
|
* |
840 |
|
* @since 1.4 |
841 |
*/ |
*/ |
842 |
public static final byte CONNECTOR_PUNCTUATION = 23; |
|
843 |
/** |
/** |
844 |
* Po = Punctuation, Other (Informative) |
* TODO: Add FINAL_QUOTE_PUNCTUATION. |
845 |
|
* Pf = ???. |
846 |
|
* |
847 |
|
* @since 1.4 |
848 |
|
*/ |
849 |
|
|
850 |
|
/** |
851 |
|
* Po = Punctuation, Other (Informative). |
852 |
|
* |
853 |
|
* @since 1.1 |
854 |
*/ |
*/ |
855 |
public static final byte OTHER_PUNCTUATION = 24; |
public static final byte OTHER_PUNCTUATION = 24; |
856 |
|
|
857 |
/** |
/** |
858 |
* Sm = Symbol, Math (Informative) |
* Sm = Symbol, Math (Informative). |
859 |
|
* |
860 |
|
* @since 1.1 |
861 |
*/ |
*/ |
862 |
public static final byte MATH_SYMBOL = 25; |
public static final byte MATH_SYMBOL = 25; |
863 |
|
|
864 |
/** |
/** |
865 |
* Sc = Symbol, Currency (Informative) |
* Sc = Symbol, Currency (Informative). |
866 |
|
* |
867 |
|
* @since 1.1 |
868 |
*/ |
*/ |
869 |
public static final byte CURRENCY_SYMBOL = 26; |
public static final byte CURRENCY_SYMBOL = 26; |
870 |
|
|
871 |
/** |
/** |
872 |
* Sk = Symbol, Modifier (Informative) |
* Sk = Symbol, Modifier (Informative). |
873 |
|
* |
874 |
|
* @since 1.1 |
875 |
*/ |
*/ |
876 |
public static final byte MODIFIER_SYMBOL = 27; |
public static final byte MODIFIER_SYMBOL = 27; |
877 |
|
|
878 |
/** |
/** |
879 |
* So = Symbol, Other (Informative) |
* So = Symbol, Other (Informative). |
880 |
|
* |
881 |
|
* @since 1.1 |
882 |
*/ |
*/ |
883 |
public static final byte OTHER_SYMBOL = 28; |
public static final byte OTHER_SYMBOL = 28; |
884 |
|
|
885 |
static Block blocks[]; // block.uni |
/** |
886 |
static char tcs[][]; // titlecase.uni |
* TODO: Add DIRECTIONALITY_UNDEFINED. |
887 |
static byte[] unicodeData; // character.uni |
* Undefined bidirectional character type. Undefined char values have |
888 |
|
* undefined directionality in the Unicode specification. |
889 |
|
* |
890 |
|
* @since 1.4 |
891 |
|
*/ |
892 |
|
|
893 |
|
/** |
894 |
|
* TODO: Add DIRECTIONALITY_LEFT_TO_RIGHT. |
895 |
|
* Strong bidirectional character type "L". |
896 |
|
* |
897 |
|
* @since 1.4 |
898 |
|
*/ |
899 |
|
|
900 |
|
/** |
901 |
|
* TODO: Add DIRECTIONALITY_RIGHT_TO_LEFT. |
902 |
|
* Strong bidirectional character type "R". |
903 |
|
* |
904 |
|
* @since 1.4 |
905 |
|
*/ |
906 |
|
|
907 |
|
/** |
908 |
|
* TODO: Add DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC. |
909 |
|
* Strong bidirectional character type "AL". |
910 |
|
* |
911 |
|
* @since 1.4 |
912 |
|
*/ |
913 |
|
|
914 |
|
/** |
915 |
|
* TODO: Add DIRECTIONALITY_EUROPEAN_NUMBER. |
916 |
|
* Strong bidirectional character type "EN". |
917 |
|
* |
918 |
|
* @since 1.4 |
919 |
|
*/ |
920 |
|
|
921 |
|
/** |
922 |
|
* TODO: Add DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR. |
923 |
|
* Strong bidirectional character type "ES". |
924 |
|
* |
925 |
|
* @since 1.4 |
926 |
|
*/ |
927 |
|
|
928 |
|
/** |
929 |
|
* TODO: Add DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR. |
930 |
|
* Strong bidirectional character type "ET". |
931 |
|
* |
932 |
|
* @since 1.4 |
933 |
|
*/ |
934 |
|
|
935 |
|
/** |
936 |
|
* TODO: Add DIRECTIONALITY_ARABIC_NUMBER. |
937 |
|
* Strong bidirectional character type "AN". |
938 |
|
* |
939 |
|
* @since 1.4 |
940 |
|
*/ |
941 |
|
|
942 |
|
/** |
943 |
|
* TODO: Add DIRECTIONALITY_COMMON_NUMBER_SEPARATOR. |
944 |
|
* Strong bidirectional character type "CS". |
945 |
|
* |
946 |
|
* @since 1.4 |
947 |
|
*/ |
948 |
|
|
949 |
|
/** |
950 |
|
* TODO: Add DIRECTIONALITY_NONSPACING_MARK. |
951 |
|
* Strong bidirectional character type "NSM". |
952 |
|
* |
953 |
|
* @since 1.4 |
954 |
|
*/ |
955 |
|
|
956 |
|
/** |
957 |
|
* TODO: Add DIRECTIONALITY_BOUNDARY_NEUTRAL. |
958 |
|
* Strong bidirectional character type "BN". |
959 |
|
* |
960 |
|
* @since 1.4 |
961 |
|
*/ |
962 |
|
|
963 |
|
/** |
964 |
|
* TODO: Add DIRECTIONALITY_PARAGRAPH_SEPARATOR. |
965 |
|
* Strong bidirectional character type "B". |
966 |
|
* |
967 |
|
* @since 1.4 |
968 |
|
*/ |
969 |
|
|
970 |
|
/** |
971 |
|
* TODO: Add DIRECTIONALITY_SEGMENT_SEPARATOR. |
972 |
|
* Strong bidirectional character type "S". |
973 |
|
* |
974 |
|
* @since 1.4 |
975 |
|
*/ |
976 |
|
|
977 |
|
/** |
978 |
|
* TODO: Add DIRECTIONALITY_WHITESPACE. |
979 |
|
* Strong bidirectional character type "WS". |
980 |
|
* |
981 |
|
* @since 1.4 |
982 |
|
*/ |
983 |
|
|
984 |
|
/** |
985 |
|
* TODO: Add DIRECTIONALITY_OTHER_NEUTRALS. |
986 |
|
* Strong bidirectional character type "ON". |
987 |
|
* |
988 |
|
* @since 1.4 |
989 |
|
*/ |
990 |
|
|
991 |
|
/** |
992 |
|
* TODO: Add DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING. |
993 |
|
* Strong bidirectional character type "LRE". |
994 |
|
* |
995 |
|
* @since 1.4 |
996 |
|
*/ |
997 |
|
|
998 |
|
/** |
999 |
|
* TODO: Add DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE. |
1000 |
|
* Strong bidirectional character type "LRO". |
1001 |
|
* |
1002 |
|
* @since 1.4 |
1003 |
|
*/ |
1004 |
|
|
1005 |
|
/** |
1006 |
|
* TODO: Add DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING. |
1007 |
|
* Strong bidirectional character type "RLE". |
1008 |
|
* |
1009 |
|
* @since 1.4 |
1010 |
|
*/ |
1011 |
|
|
1012 |
|
/** |
1013 |
|
* TODO: Add DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE. |
1014 |
|
* Strong bidirectional character type "RLO". |
1015 |
|
* |
1016 |
|
* @since 1.4 |
1017 |
|
*/ |
1018 |
|
|
1019 |
|
/** |
1020 |
|
* TODO: Add DIRECTIONALITY_POP_DIRECTIONAL_FORMAT. |
1021 |
|
* Strong bidirectional character type "PDF". |
1022 |
|
* |
1023 |
|
* @since 1.4 |
1024 |
|
*/ |
1025 |
|
|
1026 |
|
/** |
1027 |
|
* Stores unicode blocks in gnu/java/locale/character.uni. |
1028 |
|
*/ |
1029 |
|
static Block blocks[]; |
1030 |
|
|
1031 |
|
/** |
1032 |
|
* Stores titlecase blocks in gnu/java/locale/titlecase.uni. |
1033 |
|
*/ |
1034 |
|
static char tcs[][]; |
1035 |
|
|
1036 |
|
/** |
1037 |
|
* Stores unicode data in gnu/java/locale/character.uni. |
1038 |
|
*/ |
1039 |
|
static byte[] unicodeData; |
1040 |
|
|
1041 |
|
/** |
1042 |
|
* Caches the most recently used CharAttr. |
1043 |
|
*/ |
1044 |
static CharAttr cachedCharAttr; |
static CharAttr cachedCharAttr; |
1045 |
|
|
1046 |
// open up the Unicode attribute database and read the index into memory |
/** |
1047 |
static { |
* Open up the Unicode attribute database and read the index into memory. |
1048 |
|
* TODO: How are these resource files generated? |
1049 |
|
*/ |
1050 |
|
static |
1051 |
|
{ |
1052 |
File cFile = ClassLoaderHelper.getSystemResourceAsFile( |
File cFile = ClassLoaderHelper.getSystemResourceAsFile( |
1053 |
"/gnu/java/locale/character.uni"); |
"/gnu/java/locale/character.uni"); |
1054 |
File blockFile = ClassLoaderHelper.getSystemResourceAsFile( |
File blockFile = ClassLoaderHelper.getSystemResourceAsFile( |
1059 |
throw new Error("Cannot locate Unicode attribute database."); |
throw new Error("Cannot locate Unicode attribute database."); |
1060 |
|
|
1061 |
blocks = new Block[(int) blockFile.length() / 9]; |
blocks = new Block[(int) blockFile.length() / 9]; |
1062 |
try { |
try |
1063 |
DataInputStream blockIS = |
{ |
1064 |
new DataInputStream(new FileInputStream(blockFile)); |
DataInputStream blockIS |
1065 |
for (int i = 0; i < blocks.length; i++) { |
= new DataInputStream(new FileInputStream(blockFile)); |
1066 |
char start = blockIS.readChar(); |
for (int i = 0; i < blocks.length; i++) |
1067 |
char end = blockIS.readChar(); |
{ |
1068 |
boolean compressed = (blockIS.readUnsignedByte() != 0); |
char start = blockIS.readChar(); |
1069 |
int offset = blockIS.readInt(); |
char end = blockIS.readChar(); |
1070 |
blocks[i] = new Block(start, end, compressed, offset); |
boolean compressed = blockIS.readUnsignedByte() != 0; |
1071 |
|
int offset = blockIS.readInt(); |
1072 |
|
blocks[i] = new Block(start, end, compressed, offset); |
1073 |
|
} |
1074 |
|
} |
1075 |
|
catch (IOException e) |
1076 |
|
{ |
1077 |
|
throw new Error("Error reading block file: " + e); |
1078 |
} |
} |
|
} catch (IOException e) { |
|
|
throw new Error("Error reading block file: " + e); |
|
|
} |
|
1079 |
|
|
1080 |
tcs = new char[(int) tcFile.length() / 4][2]; |
tcs = new char[(int) tcFile.length() / 4][2]; |
1081 |
try { |
try |
1082 |
DataInputStream tcIS = new DataInputStream(new FileInputStream(tcFile)); |
{ |
1083 |
for (int i = 0; i < tcs.length; i++) { |
DataInputStream tcIS |
1084 |
tcs[i][0] = tcIS.readChar(); |
= new DataInputStream(new FileInputStream(tcFile)); |
1085 |
tcs[i][1] = tcIS.readChar(); |
for (int i = 0; i < tcs.length; i++) |
1086 |
|
{ |
1087 |
|
tcs[i][0] = tcIS.readChar(); |
1088 |
|
tcs[i][1] = tcIS.readChar(); |
1089 |
|
} |
1090 |
|
} |
1091 |
|
catch (IOException e) |
1092 |
|
{ |
1093 |
|
throw new Error("Error reading titlecase file: " + e); |
1094 |
} |
} |
|
} catch (IOException e) { |
|
|
throw new Error("Error reading titlecase file: " + e); |
|
|
} |
|
1095 |
|
|
1096 |
try { |
try |
1097 |
RandomAccessFile charFile = new RandomAccessFile(cFile, "r"); |
{ |
1098 |
unicodeData = new byte[(int)charFile.length()]; |
RandomAccessFile charFile = new RandomAccessFile(cFile, "r"); |
1099 |
charFile.readFully(unicodeData, 0, unicodeData.length); |
unicodeData = new byte[(int)charFile.length()]; |
1100 |
} catch (IOException e) { |
charFile.readFully(unicodeData, 0, unicodeData.length); |
1101 |
throw new Error("Unable to open Unicode character attribute file: " + e); |
} |
1102 |
} |
catch (IOException e) |
1103 |
|
{ |
1104 |
|
throw new Error("Unable to open Unicode character attribute file: " |
1105 |
|
+ e); |
1106 |
|
} |
1107 |
|
|
1108 |
cachedCharAttr = new CharAttr((char)0, false, CONTROL, 65535, |
cachedCharAttr = new CharAttr('\0', false, CONTROL, 65535, '\0', '\0'); |
|
(char)0, (char)0); |
|
1109 |
} |
} |
1110 |
|
|
1111 |
/** |
/** |
1112 |
* Grabs a character out of the Unicode attribute database. |
* Grabs a character out of the Unicode attribute database. |
1113 |
|
* |
1114 |
|
* @param ch the character to look up |
1115 |
|
* @return the character's CharAttr |
1116 |
*/ |
*/ |
1117 |
private static CharAttr readChar(char ch) { |
private static CharAttr readChar(char ch) |
1118 |
|
{ |
1119 |
CharAttr cached = cachedCharAttr; |
CharAttr cached = cachedCharAttr; |
1120 |
if (cached.ch == ch) |
if (cached.ch == ch) |
1121 |
return cached; |
return cached; |
1122 |
|
|
1123 |
int i = getBlock(ch); |
int i = getBlock(ch); |
1124 |
if (i == -1) return new CharAttr(ch, false, UNASSIGNED, 65535, ch, ch); |
if (i == -1) |
1125 |
|
return new CharAttr(ch, false, UNASSIGNED, 65535, ch, ch); |
1126 |
Block b = blocks[i]; |
Block b = blocks[i]; |
1127 |
int offset = (b.compressed) ? b.offset : (b.offset + (ch-b.start)*7); |
int offset = b.compressed ? b.offset : (b.offset + (ch - b.start) * 7); |
1128 |
int byte7 = unicodeData[offset] & 0xFF; |
int byte7 = unicodeData[offset] & 0xFF; |
1129 |
boolean noBreakSpace = ((byte7 >> 5 & 0x1) == 1); |
boolean noBreakSpace = (byte7 >> 5 & 0x1) == 1; |
1130 |
int category = byte7 & 0x1F; |
int category = byte7 & 0x1F; |
1131 |
int numericalDecimalValue = (((unicodeData[offset+1] & 0xFF) << 8) + |
int numericalDecimalValue = (((unicodeData[offset+1] & 0xFF) << 8) |
1132 |
(unicodeData[offset+2] & 0xFF)); |
+ (unicodeData[offset+2] & 0xFF)); |
1133 |
char uppercase = (char)(((unicodeData[offset+3] & 0xFF) << 8) + |
char uppercase = (char)(((unicodeData[offset+3] & 0xFF) << 8) |
1134 |
(unicodeData[offset+4] & 0xFF)); |
+ (unicodeData[offset+4] & 0xFF)); |
1135 |
char lowercase = (char)(((unicodeData[offset+5] & 0xFF) << 8) + |
char lowercase = (char)(((unicodeData[offset+5] & 0xFF) << 8) |
1136 |
(unicodeData[offset+6] & 0xFF)); |
+ (unicodeData[offset+6] & 0xFF)); |
1137 |
|
|
1138 |
CharAttr ca = new CharAttr(ch, noBreakSpace, category, |
CharAttr ca = new CharAttr(ch, noBreakSpace, category, |
1139 |
numericalDecimalValue, uppercase, lowercase); |
numericalDecimalValue, uppercase, lowercase); |
1140 |
cachedCharAttr = ca; |
cachedCharAttr = ca; |
1141 |
return ca; |
return ca; |
1142 |
} |
} |
1143 |
|
|
1144 |
/** |
/** |
1145 |
* Locates which block a character's information resides in |
* Locates which block a character's information resides in. |
1146 |
|
* |
1147 |
|
* @param ch the character to look up |
1148 |
|
* @return the block index, or -1 |
1149 |
*/ |
*/ |
1150 |
private static int getBlock(char ch) { |
private static int getBlock(char ch) |
1151 |
|
{ |
1152 |
// simple binary search |
// simple binary search |
1153 |
int low = 0; |
int low = 0; |
1154 |
int hi = blocks.length-1; |
int hi = blocks.length - 1; |
1155 |
int mid = 0; |
int mid = 0; |
1156 |
while (low <= hi) { |
while (low <= hi) |
1157 |
mid = (low + hi) >> 1; |
{ |
1158 |
Block b = blocks[mid]; |
mid = (low + hi) >> 1; |
1159 |
if (ch < b.start) |
Block b = blocks[mid]; |
1160 |
hi = mid - 1; |
if (ch < b.start) |
1161 |
else if (ch > b.end) |
hi = mid - 1; |
1162 |
low = mid + 1; |
else if (ch > b.end) |
1163 |
else return mid; |
low = mid + 1; |
1164 |
} |
else |
1165 |
|
return mid; |
1166 |
|
} |
1167 |
return -1; |
return -1; |
1168 |
} |
} |
1169 |
|
|
1172 |
* |
* |
1173 |
* @param value the character to wrap |
* @param value the character to wrap |
1174 |
*/ |
*/ |
1175 |
public Character(char value) { |
public Character(char value) |
1176 |
|
{ |
1177 |
this.value = value; |
this.value = value; |
1178 |
} |
} |
1179 |
|
|
1182 |
* |
* |
1183 |
* @return the character wrapped |
* @return the character wrapped |
1184 |
*/ |
*/ |
1185 |
public char charValue() { |
public char charValue() |
1186 |
|
{ |
1187 |
return value; |
return value; |
1188 |
} |
} |
1189 |
|
|
1191 |
* Returns the numerical value (unsigned) of the wrapped character. |
* Returns the numerical value (unsigned) of the wrapped character. |
1192 |
* Range of returned values: 0x0000-0xFFFF. |
* Range of returned values: 0x0000-0xFFFF. |
1193 |
* |
* |
1194 |
* @return an integer representing the numerical value of the |
* @return the value of the wrapped character |
|
* wrapped character |
|
1195 |
*/ |
*/ |
1196 |
public int hashCode() { |
public int hashCode() |
1197 |
return (int) value; |
{ |
1198 |
|
return value; |
1199 |
} |
} |
1200 |
|
|
1201 |
/** |
/** |
1202 |
* Determines if an object is equal to this object. |
* Determines if an object is equal to this object. This is only true for |
1203 |
|
* another Character object wrapping the same value. |
1204 |
* |
* |
1205 |
* @param o object to compare |
* @param o object to compare |
1206 |
* |
* @return true if o is a Character with the same value |
|
* @return true if o is an instance of Character and has the |
|
|
* same wrapped character, else false |
|
1207 |
*/ |
*/ |
1208 |
public boolean equals(Object o) { |
public boolean equals(Object o) |
1209 |
return (o instanceof Character && value == ((Character)o).value); |
{ |
1210 |
|
return o instanceof Character && value == ((Character) o).value; |
1211 |
} |
} |
1212 |
|
|
1213 |
/** |
/** |
1214 |
* Converts the wrapped character into a String. |
* Converts the wrapped character into a String. |
1215 |
* |
* |
1216 |
* @return a String containing one character -- the wrapped character |
* @return a String containing one character -- the wrapped character |
1217 |
* of this class |
* of this instance |
1218 |
*/ |
*/ |
1219 |
public String toString() { |
public String toString() |
1220 |
|
{ |
1221 |
return String.valueOf(value); |
return String.valueOf(value); |
1222 |
} |
} |
1223 |
|
|
1224 |
/** |
/** |
1225 |
* Returns the Unicode general category property of a character. |
* Returns a String of length 1 representing the specified character. |
1226 |
* |
* |
1227 |
* @param ch character from which the general category property will |
* @param ch the character to convert |
1228 |
* be retrieved |
* @return a String containing the character |
1229 |
* |
* @since 1.4 |
1230 |
* @return the character category property of ch as an integer |
* TODO: Add this method |
|
* |
|
|
* @see java.lang.Character#UNASSIGNED |
|
|
* @see java.lang.Character#UPPERCASE_LETTER |
|
|
* @see java.lang.Character#LOWERCASE_LETTER |
|
|
* @see java.lang.Character#TITLECASE_LETTER |
|
|
* @see java.lang.Character#MODIFIER_LETTER |
|
|
* @see java.lang.Character#OTHER_LETTER |
|
|
* @see java.lang.Character#NON_SPACING_MARK |
|
|
* @see java.lang.Character#ENCLOSING_MARK |
|
|
* @see java.lang.Character#COMBINING_SPACING_MARK |
|
|
* @see java.lang.Character#DECIMAL_DIGIT_NUMBER |
|
|
* @see java.lang.Character#LETTER_NUMBER |
|
|
* @see java.lang.Character#OTHER_NUMBER |
|
|
* @see java.lang.Character#SPACE_SEPARATOR |
|
|
* @see java.lang.Character#LINE_SEPARATOR |
|
|
* @see java.lang.Character#PARAGRAPH_SEPARATOR |
|
|
* @see java.lang.Character#CONTROL |
|
|
* @see java.lang.Character#FORMAT |
|
|
* @see java.lang.Character#PRIVATE_USE |
|
|
* @see java.lang.Character#SURROGATE |
|
|
* @see java.lang.Character#DASH_PUNCTUATION |
|
|
* @see java.lang.Character#START_PUNCTUATION |
|
|
* @see java.lang.Character#END_PUNCTUATION |
|
|
* @see java.lang.Character#CONNECTOR_PUNCTUATION |
|
|
* @see java.lang.Character#OTHER_PUNCTUATION |
|
|
* @see java.lang.Character#MATH_SYMBOL |
|
|
* @see java.lang.Character#CURRENCY_SYMBOL |
|
|
* @see java.lang.Character#MODIFIER_SYMBOL |
|
1231 |
*/ |
*/ |
1232 |
public static int getType(char ch) { |
|
|
return readChar(ch).getType(); |
|
|
} |
|
|
|
|
1233 |
/** |
/** |
1234 |
* Returns the Unicode numeric value property of a character. |
* Determines if a character is a Unicode lowercase letter. For example, |
1235 |
* If the character lacks a numeric value property, -1 is returned. |
* <code>'a'</code> is lowercase. |
1236 |
* If the character has a numeric value property which is not |
* <br> |
1237 |
* representable as a nonnegative integer, -2 is returned. |
* lowercase = [Ll] |
|
* |
|
|
* @param ch character from which the numeric value property will |
|
|
* be retrieved |
|
1238 |
* |
* |
1239 |
* @return the numeric value property of ch, or -1 if it does not exist, or |
* @param ch character to test |
1240 |
* -2 if it is not representable as a nonnegative integer |
* @return true if ch is a Unicode lowercase letter, else false |
1241 |
|
* @see #isUpperCase(char) |
1242 |
|
* @see #isTitleCase(char) |
1243 |
|
* @see #toLowerCase(char) |
1244 |
|
* @see #getType(char) |
1245 |
*/ |
*/ |
1246 |
public static int getNumericValue(char ch) { |
public static boolean isLowerCase(char ch) |
1247 |
return readChar(ch).getNumericValue(); |
{ |
1248 |
|
return getType(ch) == LOWERCASE_LETTER; |
1249 |
} |
} |
1250 |
|
|
1251 |
/** |
/** |
1252 |
* Determines if a character is a Unicode decimal digit. |
* Determines if a character is a Unicode uppercase letter. For example, |
1253 |
|
* <code>'A'</code> is uppercase. |
1254 |
* <br> |
* <br> |
1255 |
* Unicode decimal digit = [Nd] |
* uppercase = [Lu] |
1256 |
* |
* |
1257 |
* @param ch character to test |
* @param ch character to test |
1258 |
* |
* @return true if ch is a Unicode uppercase letter, else false |
1259 |
* @return true if ch is a Unicode decimal digit, else false |
* @see #isLowerCase(char) |
1260 |
|
* @see #isTitleCase(char) |
1261 |
|
* @see #toUpperCase(char) |
1262 |
|
* @see #getType(char) |
1263 |
*/ |
*/ |
1264 |
public static boolean isDigit(char ch) { |
public static boolean isUpperCase(char ch) |
1265 |
return (getType(ch) == DECIMAL_DIGIT_NUMBER); |
{ |
1266 |
|
return getType(ch) == UPPERCASE_LETTER; |
1267 |
} |
} |
1268 |
|
|
1269 |
/** |
/** |
1270 |
* Converts a character into a digit of the specified radix. |
* Determines if a character is a Unicode titlecase letter. For example, |
1271 |
|
* the character "Lj" (Latin capital L with small letter j) is titlecase. |
1272 |
* <br> |
* <br> |
1273 |
* character argument boundary = [Nd]|U+0041-U+005A|U+0061-007A |
* titlecase = [Lt] |
|
* |
|
|
* @param ch character to convert into a digit |
|
|
* @param radix radix in which ch is a digit |
|
|
* |
|
|
* @return digit which ch represents in radix, or -1 |
|
|
* if radix < MIN_RADIX or radix > MAX_RADIX or ch is not |
|
|
* a valid digit in radix |
|
1274 |
* |
* |
1275 |
* @see java.lang.Character#MIN_RADIX |
* @param ch character to test |
1276 |
* @see java.lang.Character#MAX_RADIX |
* @return true if ch is a Unicode titlecase letter, else false |
1277 |
|
* @see #isLowerCase(char) |
1278 |
|
* @see #isUpperCase(char) |
1279 |
|
* @see #toTitleCase(char) |
1280 |
|
* @see #getType(char) |
1281 |
*/ |
*/ |
1282 |
public static int digit(char ch, int radix) { |
public static boolean isTitleCase(char ch) |
1283 |
if (radix < MIN_RADIX || radix > MAX_RADIX) |
{ |
1284 |
return -1; |
return getType(ch) == TITLECASE_LETTER; |
|
CharAttr attr = readChar(ch); |
|
|
if (attr.getType() == DECIMAL_DIGIT_NUMBER && |
|
|
attr.getNumericValue() < radix) |
|
|
return attr.getNumericValue(); |
|
|
if (ch >= 'A' && ch <= 'Z' && ch < radix+'A'-10) |
|
|
return ch-'A'+10; |
|
|
if (ch >= 'a' && ch <= 'z' && ch < radix+'a'-10) |
|
|
return ch-'a'+10; |
|
|
return -1; |
|
1285 |
} |
} |
1286 |
|
|
1287 |
/** |
/** |
1288 |
* Converts a digit into a character which represents that digit |
* Determines if a character is a Unicode decimal digit. For example, |
1289 |
* in a specified radix. |
* <code>'0'</code> is a digit. |
1290 |
* <br> |
* <br> |
1291 |
* return value boundary = U+0030-U+0039|U+0061-U+007A |
* Unicode decimal digit = [Nd] |
|
* |
|
|
* @param digit digit to be converted into a character |
|
|
* @param radix radix of digit |
|
|
* |
|
|
* @return character representing digit in radix, or U+0000 if |
|
|
* radix < MIN_RADIX or radix > MAX_RADIX or digit < 0 or |
|
|
* digit >= radix |
|
1292 |
* |
* |
1293 |
* @see java.lang.Character#MIN_RADIX |
* @param ch character to test |
1294 |
* @see java.lang.Character#MAX_RADIX |
* @return true if ch is a Unicode decimal digit, else false |
1295 |
|
* @see #digit(char, int) |
1296 |
|
* @see #forDigit(int, int) |
1297 |
|
* @see #getType(char) |
1298 |
*/ |
*/ |
1299 |
public static char forDigit(int digit, int radix) { |
public static boolean isDigit(char ch) |
1300 |
if (radix < MIN_RADIX || radix > MAX_RADIX || |
{ |
1301 |
digit < 0 || digit >= radix) |
return getType(ch) == DECIMAL_DIGIT_NUMBER; |
|
return '\u0000'; |
|
|
return (char) ((digit < 10) ? ('0' + digit) : ('a'+digit-10)); |
|
1302 |
} |
} |
1303 |
|
|
1304 |
/** |
/** |
1305 |
* Determines if a character is a Unicode space character. |
* Determines if a character is part of the Unicode Standard. This is an |
1306 |
|
* evolving standard, but covers every character in the data file. |
1307 |
* <br> |
* <br> |
1308 |
* Unicode space = [Zs] |
* defined = not [Cn] |
1309 |
* |
* |
1310 |
* @param ch character to test |
* @param ch character to test |
1311 |
* |
* @return true if ch is a Unicode character, else false |
1312 |
* @return true if ch is a Unicode space, else false |
* @see #isDigit(char) |
1313 |
|
* @see #isLetter(char) |
1314 |
|
* @see #isLetterOrDigit(char) |
1315 |
|
* @see #isLowerCase(char) |
1316 |
|
* @see #isTitleCase(char) |
1317 |
|
* @see #isUpperCase(char) |
1318 |
*/ |
*/ |
1319 |
public static boolean isSpaceChar(char ch) { |
public static boolean isDefined(char ch) |
1320 |
return (getType(ch) == SPACE_SEPARATOR); |
{ |
1321 |
|
return getBlock(ch) != -1; |
1322 |
} |
} |
1323 |
|
|
1324 |
/** |
/** |
1325 |
* Determines if a character is a Java space, per JLS 20.5.19. |
* Determines if a character is a Unicode letter. Not all letters have case, |
1326 |
|
* so this may return true when isLowerCase and isUpperCase return false. |
1327 |
* <br> |
* <br> |
1328 |
* Java space = U+0020|U+0009|U+000A|U+000C|U+000D |
* letter = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl] |
1329 |
|
* TODO: Is [Nl] really part of this group? |
1330 |
* |
* |
1331 |
* @param ch character to test |
* @param ch character to test |
1332 |
* |
* @return true if ch is a Unicode letter, else false |
1333 |
* @return true if ch is a Java space, else false |
* @see #isDigit(char) |
1334 |
* |
* @see #isJavaIdentifierStart(char) |
1335 |
* @deprecated Replaced by isWhitespace() |
* @see #isJavaLetter(char) |
1336 |
|
* @see #isJavaLetterOrDigit(char) |
1337 |
|
* @see #isLetterOrDigit(char) |
1338 |
|
* @see #isLowerCase(char) |
1339 |
|
* @see #isTitleCase(char) |
1340 |
|
* @see #isUnicodeIdentifierStart(char) |
1341 |
|
* @see #isUpperCase(char) |
1342 |
*/ |
*/ |
1343 |
public static boolean isSpace(char ch) { |
public static boolean isLetter(char ch) |
1344 |
return ((ch == ' ') || (ch == '\t') || (ch == '\n') || (ch == '\f') || |
{ |
1345 |
(ch == '\r')); |
int category = getType(ch); |
1346 |
|
return (category >= UPPERCASE_LETTER && category <= OTHER_LETTER) |
1347 |
|
|| category == LETTER_NUMBER; |
1348 |
} |
} |
1349 |
|
|
1350 |
/** |
/** |
1351 |
* Determines if a character is Java whitespace. |
* Determines if a character is a Unicode letter or a Unicode digit. This |
1352 |
|
* is the combination of isLetter and isDigit. |
1353 |
* <br> |
* <br> |
1354 |
* Java whitespace = ([Zs] not Nb)|[Zl]|[Zp]|U+0009-U+000D|U+001C-U+001F |
* letter or digit = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Nd] |
1355 |
|
* TODO: Is [Nl] really part of this group? |
1356 |
* |
* |
1357 |
* @param ch character to test |
* @param ch character to test |
1358 |
* |
* @return true if ch is a Unicode letter or a Unicode digit, else false |
1359 |
* @return true if ch is Java whitespace, else false |
* @see #isDigit(char) |
1360 |
|
* @see #isJavaIdentifierPart(char) |
1361 |
|
* @see #isJavaLetter(char) |
1362 |
|
* @see #isJavaLetterOrDigit(char) |
1363 |
|
* @see #isLetter(char) |
1364 |
|
* @see #isUnicodeIdentifierPart(char) |
1365 |
*/ |
*/ |
1366 |
public static boolean isWhitespace(char ch) { |
public static boolean isLetterOrDigit(char ch) |
1367 |
CharAttr attr = readChar(ch); |
{ |
1368 |
int category = attr.getType(); |
int category = getType(ch); |
1369 |
return ((category == SPACE_SEPARATOR && !attr.isNoBreakSpace()) || |
return (category >= UPPERCASE_LETTER && category <= OTHER_LETTER) |
1370 |
category == LINE_SEPARATOR || |
|| category == LETTER_NUMBER || category == DECIMAL_DIGIT_NUMBER; |
|
category == PARAGRAPH_SEPARATOR || |
|
|
//(ch >= '\u0009' && ch <= '\ u000D') || |
|
|
(ch >= '\u0009' && ch <= '\r') || // Change to make javadep work |
|
|
(ch >= '\u001C' && ch <= '\u001F')); |
|
1371 |
} |
} |
1372 |
|
|
1373 |
/** |
/** |
1374 |
* Determines if a character has the ISO Control property. |
* Determines if a character can start a Java identifier. This is the |
1375 |
* <br> |
* combination of isLetter, any character where getType returns |
1376 |
* ISO Control = U+0000-U+001F|U+0074-U+0094 |
* LETTER_NUMBER, currency symbols (like '$'), and connecting punctuation |
1377 |
|
* (like '_'). |
1378 |
* |
* |
1379 |
* @param ch character to test |
* @param ch character to test |
1380 |
|
* @return true if ch can start a Java identifier, else false |
1381 |
|
* @deprecated Replaced by {@link #isJavaIdentifierStart(char)} |
1382 |
|
* @see #isJavaLetterOrDigit(char) |
1383 |
|
* @see #isJavaIdentifierStart(char) |
1384 |
|
* @see #isJavaIdentifierPart(char) |
1385 |
|
* @see #isLetter(char) |
1386 |
|
* @see #isLetterOrDigit(char) |
1387 |
|
* @see #isUnicodeIdentifierStart(char) |
1388 |
|
*/ |
1389 |
|
public static boolean isJavaLetter(char ch) |
1390 |
|
{ |
1391 |
|
return isJavaIdentifierStart(ch); |
1392 |
|
} |
1393 |
|
|
1394 |
|
/** |
1395 |
|
* Determines if a character can follow the first letter in |
1396 |
|
* a Java identifier. This is the combination of isJavaLetter (isLetter, |
1397 |
|
* type of LETTER_NUMBER, currency, connecting punctuation) and digit, |
1398 |
|
* numeric letter (like Roman numerals), combining marks, non-spacing marks, |
1399 |
|
* or isIdentifierIgnorable. |
1400 |
* |
* |
1401 |
* @return true if ch is an ISO Control character, else false |
* @param ch character to test |
1402 |
|
* @return true if ch can follow the first letter in a Java identifier |
1403 |
|
* @deprecated Replaced by {@link #isJavaIdentifierPart(char)} |
1404 |
|
* @see #isJavaLetter(char) |
1405 |
|
* @see #isJavaIdentifierStart(char) |
1406 |
|
* @see #isJavaIdentifierPart(char) |
1407 |
|
* @see #isLetter(char) |
1408 |
|
* @see #isLetterOrDigit(char) |
1409 |
|
* @see #isUnicodeIdentifierPart(char) |
1410 |
|
* @see #isIdentifierIgnorable(char) |
1411 |
*/ |
*/ |
1412 |
public static boolean isISOControl(char ch) { |
public static boolean isJavaLetterOrDigit(char ch) |
1413 |
return ((ch >= '\u0000' && ch <= '\u001F') || |
{ |
1414 |
(ch >= '\u007F' && ch <= '\u009F')); |
return isJavaIdentifierPart(ch); |
1415 |
} |
} |
1416 |
|
|
1417 |
/** |
/** |
1418 |
* Determines if a character is part of the Unicode Standard. |
* Determines if a character can start a Java identifier. This is the |
1419 |
|
* combination of isLetter, any character where getType returns |
1420 |
|
* LETTER_NUMBER, currency symbols (like '$'), and connecting punctuation |
1421 |
|
* (like '_'). |
1422 |
* <br> |
* <br> |
1423 |
* defined = not [Cn] |
* Java identifier start = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Sc]|[Pc] |
1424 |
* |
* |
1425 |
* @param ch character to test |
* @param ch character to test |
1426 |
* |
* @return true if ch can start a Java identifier, else false |
1427 |
* @return true if ch is a Unicode character, else false |
* @see #isJavaIdentifierPart(char) |
1428 |
|
* @see #isLetter(char) |
1429 |
|
* @see #isUnicodeIdentifierStart(char) |
1430 |
|
* @since 1.1 |
1431 |
*/ |
*/ |
1432 |
public static boolean isDefined(char ch) { |
public static boolean isJavaIdentifierStart(char ch) |
1433 |
return (getBlock(ch) != -1); |
{ |
1434 |
|
int category = getType(ch); |
1435 |
|
return (category >= UPPERCASE_LETTER && category <= OTHER_LETTER) |
1436 |
|
|| category == CURRENCY_SYMBOL || category == CONNECTOR_PUNCTUATION; |
1437 |
} |
} |
1438 |
|
|
1439 |
/** |
/** |
1440 |
* Determines if a character is a Unicode letter. |
* Determines if a character can follow the first letter in |
1441 |
|
* a Java identifier. This is the combination of isJavaLetter (isLetter, |
1442 |
|
* type of LETTER_NUMBER, currency, connecting punctuation) and digit, |
1443 |
|
* numeric letter (like Roman numerals), combining marks, non-spacing marks, |
1444 |
|
* or isIdentifierIgnorable. |
1445 |
* <br> |
* <br> |
1446 |
* letter = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl] |
* Java identifier extender = |
1447 |
|
* [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Sc]|[Pc]|[Mn]|[Mc]|[Nd]|[Cf] |
1448 |
* |
* |
1449 |
* @param ch character to test |
* @param ch character to test |
1450 |
* |
* @return true if ch can follow the first letter in a Java identifier |
1451 |
* @return true if ch is a Unicode letter, else false |
* @see #isIdentifierIgnorable(char) |
1452 |
|
* @see #isJavaIdentifierStart(char) |
1453 |
|
* @see #isLetterOrDigit(char) |
1454 |
|
* @see #isUnicodeIdentifierPart(char) |
1455 |
|
* @since 1.1 |
1456 |
*/ |
*/ |
1457 |
public static boolean isLetter(char ch) { |
public static boolean isJavaIdentifierPart(char ch) |
1458 |
|
{ |
1459 |
int category = getType(ch); |
int category = getType(ch); |
1460 |
return ((category >= UPPERCASE_LETTER && category <= OTHER_LETTER) || |
return (category >= UPPERCASE_LETTER && category <= OTHER_LETTER) |
1461 |
(category == LETTER_NUMBER)); |
|| category == LETTER_NUMBER || category == CURRENCY_SYMBOL |
1462 |
|
|| category == NON_SPACING_MARK || category == COMBINING_SPACING_MARK |
1463 |
|
|| category == DECIMAL_DIGIT_NUMBER || category == CONNECTOR_PUNCTUATION |
1464 |
|
|| category == FORMAT; |
1465 |
} |
} |
1466 |
|
|
1467 |
/** |
/** |
1468 |
* Determines if a character is a Unicode letter or a Unicode digit. |
* Determines if a character can start a Unicode identifier. Only |
1469 |
|
* letters can start a Unicode identifier, but this includes characters |
1470 |
|
* in LETTER_NUMBER. |
1471 |
* <br> |
* <br> |
1472 |
* letter or digit = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Nd] |
* Unicode identifier start = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl] |
1473 |
* |
* |
1474 |
* @param ch character to test |
* @param ch character to test |
1475 |
|
* @return true if ch can start a Unicode identifier, else false |
1476 |
|
* @see #isJavaIdentifierStart(char) |
1477 |
|
* @see #isLetter(char) |
1478 |
|
* @see #isUnicodeIdentifierPart(char) |
1479 |
|
* @since 1.1 |
1480 |
|
*/ |
1481 |
|
public static boolean isUnicodeIdentifierStart(char ch) |
1482 |
|
{ |
1483 |
|
// TODO: Fix this implementation when isLetter is fixed. |
1484 |
|
return isLetter(ch); |
1485 |
|
} |
1486 |
|
|
1487 |
|
/** |
1488 |
|
* Determines if a character can follow the first letter in |
1489 |
|
* a Unicode identifier. This includes letters, connecting punctuation, |
1490 |
|
* digits, numeric letters, combining marks, non-spacing marks, and |
1491 |
|
* isIdentifierIgnorable. |
1492 |
|
* <br> |
1493 |
|
* Unicode identifier extender = |
1494 |
|
* [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Mn]|[Mc]|[Nd]|[Pc]|[Cf] |
1495 |
* |
* |
1496 |
* @return true if ch is a Unicode letter or a Unicode digit, else false |
* @param ch character to test |
1497 |
*/ |
* @return true if ch can follow the first letter in a Unicode identifier |
1498 |
public static boolean isLetterOrDigit(char ch) { |
* @see #isIdentifierIgnorable(char) |
1499 |
|
* @see #isJavaIdentifierPart(char) |
1500 |
|
* @see #isLetterOrDigit(char) |
1501 |
|
* @see #isUnicodeIdentifierStart(char) |
1502 |
|
* @since 1.1 |
1503 |
|
*/ |
1504 |
|
public static boolean isUnicodeIdentifierPart(char ch) |
1505 |
|
{ |
1506 |
|
// TODO: Fixme - should this include CONTROL? |
1507 |
int category = getType(ch); |
int category = getType(ch); |
1508 |
return ((category >= UPPERCASE_LETTER && category <= OTHER_LETTER) || |
return (category >= UPPERCASE_LETTER && category <= OTHER_LETTER) |
1509 |
(category == LETTER_NUMBER) || |
|| category == LETTER_NUMBER || category == NON_SPACING_MARK |
1510 |
(category == DECIMAL_DIGIT_NUMBER)); |
|| category == COMBINING_SPACING_MARK |
1511 |
|
|| category == DECIMAL_DIGIT_NUMBER || category == CONNECTOR_PUNCTUATION |
1512 |
|
|| category == FORMAT; |
1513 |
} |
} |
1514 |
|
|
1515 |
/** |
/** |
1516 |
* Determines if a character is a Unicode lowercase letter. |
* Determines if a character is ignorable in a Unicode identifier. This |
1517 |
|
* includes the non-whitespace ISO control characters (<code>'\u0000'</code> |
1518 |
|
* through <code>'\u0008'</code>, <code>'\u000E'</code> through |
1519 |
|
* <code>'\u001B'</code>, and <code>'\u007F'</code> through |
1520 |
|
* <code>'\u009F'</code>), and FORMAT characters. |
1521 |
* <br> |
* <br> |
1522 |
* lowercase = [Ll] |
* Unicode identifier ignorable = [Cf] |
1523 |
|
* TODO: Should this include CONTROL [Cc]? |
1524 |
* |
* |
1525 |
* @param ch character to test |
* @param ch character to test |
1526 |
* |
* @return true if ch is ignorable in a Unicode or Java identifier |
1527 |
* @return true if ch is a Unicode lowercase letter, else false |
* @see #isJavaIdentifierPart(char) |
1528 |
*/ |
* @see #isUnicodeIdentifierPart(char) |
1529 |
public static boolean isLowerCase(char ch) { |
* @since 1.1 |
1530 |
return (getType(ch) == LOWERCASE_LETTER); |
*/ |
1531 |
|
public static boolean isIdentifierIgnorable(char ch) |
1532 |
|
{ |
1533 |
|
return getType(ch) == FORMAT; |
1534 |
} |
} |
1535 |
|
|
1536 |
/** |
/** |
1537 |
* Converts a Unicode character into its lowercase equivalent mapping. |
* Converts a Unicode character into its lowercase equivalent mapping. |
1538 |
* If a mapping does not exist, then the character passed is returned. |
* If a mapping does not exist, then the character passed is returned. |
1539 |
|
* Note that isLowerCase(toLowerCase(ch)) does not always return true. |
1540 |
* |
* |
1541 |
* @param ch character to convert to lowercase |
* @param ch character to convert to lowercase |
|
* |
|
1542 |
* @return lowercase mapping of ch, or ch if lowercase mapping does |
* @return lowercase mapping of ch, or ch if lowercase mapping does |
1543 |
* not exist. |
* not exist |
1544 |
|
* @see #isLowerCase(char) |
1545 |
|
* @see #isUpperCase(char) |
1546 |
|
* @see #toTitleCase(char) |
1547 |
|
* @see #toUpperCase(char) |
1548 |
*/ |
*/ |
1549 |
public static char toLowerCase(char ch) { |
public static char toLowerCase(char ch) |
1550 |
|
{ |
1551 |
return readChar(ch).toLowerCase(); |
return readChar(ch).toLowerCase(); |
1552 |
} |
} |
|
|
|
|
/** |
|
|
* Determines if a character is a Unicode uppercase letter. |
|
|
* <br> |
|
|
* uppercase = [Lu] |
|
|
* |
|
|
* @param ch character to test |
|
|
* |
|
|
* @return true if ch is a Unicode uppercase letter, else false |
|
|
*/ |
|
|
public static boolean isUpperCase(char ch) { |
|
|
return (getType(ch) == UPPERCASE_LETTER); |
|
|
} |
|
1553 |
|
|
1554 |
/** |
/** |
1555 |
* Converts a Unicode character into its uppercase equivalent mapping. |
* Converts a Unicode character into its uppercase equivalent mapping. |
1556 |
* If a mapping does not exist, then the character passed is returned. |
* If a mapping does not exist, then the character passed is returned. |
1557 |
|
* Note that isUpperCase(toUpperCase(ch)) does not always return true. |
1558 |
* |
* |
1559 |
* @param ch character to convert to uppercase |
* @param ch character to convert to uppercase |
|
* |
|
1560 |
* @return uppercase mapping of ch, or ch if uppercase mapping does |
* @return uppercase mapping of ch, or ch if uppercase mapping does |
1561 |
* not exist. |
* not exist |
1562 |
|
* @see #isLowerCase(char) |
1563 |
|
* @see #isUpperCase(char) |
1564 |
|
* @see #toLowerCase(char) |
1565 |
|
* @see #toTitleCase(char) |
1566 |
*/ |
*/ |
1567 |
public static char toUpperCase(char ch) { |
public static char toUpperCase(char ch) |
1568 |
|
{ |
1569 |
return readChar(ch).toUpperCase(); |
return readChar(ch).toUpperCase(); |
1570 |
} |
} |
1571 |
|
|
1572 |
/** |
/** |
|
* Determines if a character is a Unicode titlecase letter. |
|
|
* <br> |
|
|
* titlecase = [Lt] |
|
|
* |
|
|
* @param ch character to test |
|
|
* |
|
|
* @return true if ch is a Unicode titlecase letter, else false |
|
|
*/ |
|
|
public static boolean isTitleCase(char ch) { |
|
|
return (getType(ch) == TITLECASE_LETTER); |
|
|
} |
|
|
|
|
|
/** |
|
1573 |
* Converts a Unicode character into its titlecase equivalent mapping. |
* Converts a Unicode character into its titlecase equivalent mapping. |
1574 |
* If a mapping does not exist, then the character passed is returned. |
* If a mapping does not exist, then the character passed is returned. |
1575 |
|
* Note that isTitleCase(toTitleCase(ch)) does not always return true. |
1576 |
* |
* |
1577 |
* @param ch character to convert to titlecase |
* @param ch character to convert to titlecase |
|
* |
|
1578 |
* @return titlecase mapping of ch, or ch if titlecase mapping does |
* @return titlecase mapping of ch, or ch if titlecase mapping does |
1579 |
* not exist. |
* not exist |
1580 |
|
* @see #isTitleCase(char) |
1581 |
|
* @see #toLowerCase(char) |
1582 |
|
* @see #toUpperCase(char) |
1583 |
*/ |
*/ |
1584 |
public static char toTitleCase(char ch) { |
public static char toTitleCase(char ch) |
1585 |
|
{ |
1586 |
for (int i = 0; i < tcs.length; i++) |
for (int i = 0; i < tcs.length; i++) |
1587 |
if (tcs[i][0] == ch) |
if (tcs[i][0] == ch) |
1588 |
return tcs[i][1]; |
return tcs[i][1]; |
1589 |
return toUpperCase(ch); |
return toUpperCase(ch); |
1590 |
} |
} |
1591 |
|
|
1592 |
/** |
/** |
1593 |
* Determines if a character can start a Java identifier. |
* Converts a character into a digit of the specified radix. If the radix |
1594 |
* This method does not implement JLS 20.5.17, but instead |
* exceeds MIN_RADIX or MAX_RADIX, or if the result of getNumericValue(ch) |
1595 |
* implements the algorithm used by isJavaIdentifierStart(). |
* exceeds the radix, the result is -1. |
1596 |
* |
* <br> |
1597 |
* @param ch character to test |
* character argument boundary = [Nd]|U+0041-U+005A|U+0061-007A |
|
* |
|
|
* @return true if ch can start a Java identifier, else false |
|
|
* |
|
|
* @deprecated Replaced by isJavaIdentifierStart() |
|
1598 |
* |
* |
1599 |
* @see java.lang.Character#isJavaIdentifierStart |
* @param ch character to convert into a digit |
1600 |
|
* @param radix radix in which ch is a digit |
1601 |
|
* @return digit which ch represents in radix, or -1 not a valid digit |
1602 |
|
* @see #MIN_RADIX |
1603 |
|
* @see #MAX_RADIX |
1604 |
|
* @see #forDigit(int, int) |
1605 |
|
* @see #isDigit(char) |
1606 |
|
* @see #getNumericValue(char) |
1607 |
*/ |
*/ |
1608 |
public static boolean isJavaLetter(char ch) { |
public static int digit(char ch, int radix) |
1609 |
return isJavaIdentifierStart(ch); |
{ |
1610 |
|
if (radix < MIN_RADIX || radix > MAX_RADIX) |
1611 |
|
return -1; |
1612 |
|
CharAttr attr = readChar(ch); |
1613 |
|
if (attr.getType() == DECIMAL_DIGIT_NUMBER |
1614 |
|
&& attr.getNumericValue() < radix) |
1615 |
|
return attr.getNumericValue(); |
1616 |
|
if (ch >= 'A' && ch <= 'Z' && ch < radix + 'A' - 10) |
1617 |
|
return ch - 'A' + 10; |
1618 |
|
if (ch >= 'a' && ch <= 'z' && ch < radix + 'a' - 10) |
1619 |
|
return ch - 'a' + 10; |
1620 |
|
return -1; |
1621 |
} |
} |
1622 |
|
|
1623 |
/** |
/** |
1624 |
* Determines if a character can follow the first letter in |
* Returns the Unicode numeric value property of a character. For example, |
1625 |
* a Java identifier. This method does not implement JLS 20.5.18, |
* <code>'\\u216C'</code> (the Roman numeral fifty) returns 50. |
|
* but instead implements the algorithm used by isJavaIdentifierPart(). |
|
|
* |
|
|
* @param ch character to test |
|
|
* |
|
|
* @return true if ch can follow the first letter in a Java identifier, |
|
|
* else false |
|
1626 |
* |
* |
1627 |
* @deprecated Replaced by isJavaIdentifierPart() |
* <p>This method also returns values for the letters A through Z, (not |
1628 |
|
* specified by Unicode), in these ranges: <code>'\u0041'</code> |
1629 |
|
* through <code>'\u005A'</code> (uppercase); <code>'\u0061'</code> |
1630 |
|
* through <code>'\u007A'</code> (lowercase); and <code>'\uFF21'</code> |
1631 |
|
* through <code>'\uFF3A'</code>, <code>'\uFF41'</code> through |
1632 |
|
* <code>'\uFF5A'</code> (full width variants). |
1633 |
|
* |
1634 |
|
* <p>If the character lacks a numeric value property, -1 is returned. |
1635 |
|
* If the character has a numeric value property which is not representable |
1636 |
|
* as a nonnegative integer, such as a fraction, -2 is returned. |
1637 |
* |
* |
1638 |
* @see java.lang.Character#isJavaIdentifierPart |
* @param ch character from which the numeric value property will |
1639 |
|
* be retrieved |
1640 |
|
* @return the numeric value property of ch, or -1 if it does not exist, or |
1641 |
|
* -2 if it is not representable as a nonnegative integer |
1642 |
|
* @see #forDigit(int, int) |
1643 |
|
* @see #digit(char, int) |
1644 |
|
* @see #isDigit(char) |
1645 |
|
* @since 1.1 |
1646 |
*/ |
*/ |
1647 |
public static boolean isJavaLetterOrDigit(char ch) { |
public static int getNumericValue(char ch) |
1648 |
return isJavaIdentifierPart(ch); |
{ |
1649 |
|
return readChar(ch).getNumericValue(); |
1650 |
} |
} |
1651 |
|
|
1652 |
/** |
/** |
1653 |
* Determines if a character can start a Java identifier. |
* Determines if a character is a ISO-LATIN-1 space. This is only the five |
1654 |
|
* characters <code>'\t'</code>, <code>'\n'</code>, <code>'\f'</code>, |
1655 |
|
* <code>'\r'</code>, and <code>' '</code>. |
1656 |
* <br> |
* <br> |
1657 |
* Java identifier start = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Sc]|[Pc] |
* Java space = U+0020|U+0009|U+000A|U+000C|U+000D |
|
* |
|
|
* @param ch character to test |
|
1658 |
* |
* |
1659 |
* @return true if ch can start a Java identifier, else false |
* @param ch character to test |
1660 |
|
* @return true if ch is a space, else false |
1661 |
|
* @deprecated Replaced by {@link #isWhitespace(char)} |
1662 |
|
* @see #isSpaceChar(char) |
1663 |
|
* @see #isWhitespace(char) |
1664 |
*/ |
*/ |
1665 |
public static boolean isJavaIdentifierStart(char ch) { |
public static boolean isSpace(char ch) |
1666 |
int category = getType(ch); |
{ |
1667 |
return ((category >= UPPERCASE_LETTER && category <= OTHER_LETTER) || |
return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\f' || ch == '\r'; |
|
(category == CURRENCY_SYMBOL) || |
|
|
(category == CONNECTOR_PUNCTUATION)); |
|
1668 |
} |
} |
1669 |
|
|
1670 |
/** |
/** |
1671 |
* Determines if a character can follow the first letter in |
* Determines if a character is a Unicode space character. This includes |
1672 |
* a Java identifier. |
* SPACE_SEPARATOR, LINE_SEPARATOR, and PARAGRAPH_SEPARATOR. |
1673 |
* <br> |
* <br> |
1674 |
* Java identifier extender = |
* Unicode space = [Zs] |
1675 |
* [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Sc]|[Pc][Mn]|[Mc]|[Nd]|[Cf] |
* TODO: This should include [Zp] and [Zl]. |
1676 |
* |
* |
1677 |
* @param ch character to test |
* @param ch character to test |
1678 |
* |
* @return true if ch is a Unicode space, else false |
1679 |
* @return true if ch can follow the first letter in a Java identifier, |
* @see #isWhitespace(char) |
1680 |
* else false |
* @since 1.1 |
1681 |
*/ |
*/ |
1682 |
public static boolean isJavaIdentifierPart(char ch) { |
public static boolean isSpaceChar(char ch) |
1683 |
int category = getType(ch); |
{ |
1684 |
return ((category >= UPPERCASE_LETTER && category <= OTHER_LETTER) || |
return getType(ch) == SPACE_SEPARATOR; |
1685 |
(category == LETTER_NUMBER) || |
} |
1686 |
(category == CURRENCY_SYMBOL) || |
|
|
(category == NON_SPACING_MARK) || |
|
|
(category == COMBINING_SPACING_MARK) || |
|
|
(category == DECIMAL_DIGIT_NUMBER) || |
|
|
(category == CONNECTOR_PUNCTUATION) || |
|
|
(category == FORMAT)); |
|
|
} |
|
|
|
|
1687 |
/** |
/** |
1688 |
* Determines if a character can start a Unicode identifier. Only |
* Determines if a character is Java whitespace. This includes Unicode |
1689 |
* letters can start a Unicode identifier. |
* space characters (SPACE_SEPARATOR, LINE_SEPARATOR, and |
1690 |
|
* PARAGRAPH_SEPARATOR) except the non-breaking spaces |
1691 |
|
* (<code>'\u00A0'</code>, <code>'\u2007'</code>, and <code>'\u202F'</code>); |
1692 |
|
* and these characters: <code>'\u0009'</code>, <code>'\u000A'</code>, |
1693 |
|
* <code>'\u000B'</code>, <code>'\u000C'</code>, <code>'\u000D'</code>, |
1694 |
|
* <code>'\u001C'</code>, <code>'\u001D'</code>, <code>'\u001E'</code>, |
1695 |
|
* and <code>'\u001F'</code>. |
1696 |
* <br> |
* <br> |
1697 |
* Unicode identifier start = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl] |
* Java whitespace = ([Zs] not Nb)|[Zl]|[Zp]|U+0009-U+000D|U+001C-U+001F |
|
* |
|
|
* @param ch character to test |
|
1698 |
* |
* |
1699 |
* @return true if ch can start a Unicode identifier, else false |
* @param ch character to test |
1700 |
|
* @return true if ch is Java whitespace, else false |
1701 |
|
* @see #isSpaceChar(char) |
1702 |
|
* @since 1.1 |
1703 |
*/ |
*/ |
1704 |
public static boolean isUnicodeIdentifierStart(char ch) { |
public static boolean isWhitespace(char ch) |
1705 |
return isLetter(ch); |
{ |
1706 |
|
CharAttr attr = readChar(ch); |
1707 |
|
int category = attr.getType(); |
1708 |
|
return (category == SPACE_SEPARATOR && ! attr.isNoBreakSpace()) |
1709 |
|
|| category == LINE_SEPARATOR || category == PARAGRAPH_SEPARATOR |
1710 |
|
|| (ch >= '\u0009' && ch <= '\r') |
1711 |
|
|| (ch >= '\u001C' && ch <= '\u001F'); |
1712 |
} |
} |
1713 |
|
|
1714 |
/** |
/** |
1715 |
* Determines if a character can follow the first letter in |
* Determines if a character has the ISO Control property. |
|
* a Unicode identifier. |
|
1716 |
* <br> |
* <br> |
1717 |
* Unicode identifier extender = |
* ISO Control = U+0000-U+001F|U+0074-U+0094 |
|
* [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Mn]|[Mc]|[Nd]|[Pc]|[Cf] |
|
1718 |
* |
* |
1719 |
* @param ch character to test |
* @param ch character to test |
1720 |
|
* @return true if ch is an ISO Control character, else false |
1721 |
|
* @see #isSpaceChar(char) |
1722 |
|
* @see #isWhitespace(char) |
1723 |
|
* @since 1.1 |
1724 |
|
*/ |
1725 |
|
public static boolean isISOControl(char ch) |
1726 |
|
{ |
1727 |
|
return (ch >= '\u0000' && ch <= '\u001F') |
1728 |
|
|| (ch >= '\u007F' && ch <= '\u009F'); |
1729 |
|
} |
1730 |
|
|
1731 |
|
/** |
1732 |
|
* Returns the Unicode general category property of a character. |
1733 |
* |
* |
1734 |
* @return true if ch can follow the first letter in a Unicode identifier, |
* @param ch character from which the general category property will |
1735 |
* else false |
* be retrieved |
1736 |
|
* @return the character category property of ch as an integer |
1737 |
|
* @see #UNASSIGNED |
1738 |
|
* @see #UPPERCASE_LETTER |
1739 |
|
* @see #LOWERCASE_LETTER |
1740 |
|
* @see #TITLECASE_LETTER |
1741 |
|
* @see #MODIFIER_LETTER |
1742 |
|
* @see #OTHER_LETTER |
1743 |
|
* @see #NON_SPACING_MARK |
1744 |
|
* @see #ENCLOSING_MARK |
1745 |
|
* @see #COMBINING_SPACING_MARK |
1746 |
|
* @see #DECIMAL_DIGIT_NUMBER |
1747 |
|
* @see #LETTER_NUMBER |
1748 |
|
* @see #OTHER_NUMBER |
1749 |
|
* @see #SPACE_SEPARATOR |
1750 |
|
* @see #LINE_SEPARATOR |
1751 |
|
* @see #PARAGRAPH_SEPARATOR |
1752 |
|
* @see #CONTROL |
1753 |
|
* @see #FORMAT |
1754 |
|
* @see #PRIVATE_USE |
1755 |
|
* @see #SURROGATE |
1756 |
|
* @see #DASH_PUNCTUATION |
1757 |
|
* @see #START_PUNCTUATION |
1758 |
|
* @see #END_PUNCTUATION |
1759 |
|
* @see #CONNECTOR_PUNCTUATION |
1760 |
|
* @see #OTHER_PUNCTUATION |
1761 |
|
* @see #MATH_SYMBOL |
1762 |
|
* @see #CURRENCY_SYMBOL |
1763 |
|
* @see #MODIFIER_SYMBOL |
1764 |
|
* @since 1.1 |
1765 |
*/ |
*/ |
1766 |
public static boolean isUnicodeIdentifierPart(char ch) { |
public static int getType(char ch) |
1767 |
int category = getType(ch); |
{ |
1768 |
return ((category >= UPPERCASE_LETTER && category <= OTHER_LETTER) || |
return readChar(ch).getType(); |
|
(category == LETTER_NUMBER) || |
|
|
(category == NON_SPACING_MARK) || |
|
|
(category == COMBINING_SPACING_MARK) || |
|
|
(category == DECIMAL_DIGIT_NUMBER) || |
|
|
(category == CONNECTOR_PUNCTUATION) || |
|
|
(category == FORMAT)); |
|
1769 |
} |
} |
1770 |
|
|
1771 |
/** |
/** |
1772 |
* Determines if a character is ignorable in a Unicode identifier. |
* Converts a digit into a character which represents that digit |
1773 |
|
* in a specified radix. If the radix exceeds MIN_RADIX or MAX_RADIX, |
1774 |
|
* or the digit exceeds the radix, then the null character <code>'\0'</code> |
1775 |
|
* is returned. Otherwise the return value is in '0'-'9' and 'a'-'z'. |
1776 |
* <br> |
* <br> |
1777 |
* Unicode identifier ignorable = [Cf] |
* return value boundary = U+0030-U+0039|U+0061-U+007A |
|
* |
|
|
* @param ch character to test |
|
1778 |
* |
* |
1779 |
* @return true if ch is ignorable in a Unicode identifier, |
* @param digit digit to be converted into a character |
1780 |
* else false |
* @param radix radix of digit |
1781 |
|
* @return character representing digit in radix, or '\0' |
1782 |
|
* @see #MIN_RADIX |
1783 |
|
* @see #MAX_RADIX |
1784 |
|
* @see #digit(char, int) |
1785 |
*/ |
*/ |
1786 |
public static boolean isIdentifierIgnorable(char ch) { |
public static char forDigit(int digit, int radix) |
1787 |
return (getType(ch) == FORMAT); |
{ |
1788 |
|
if (radix < MIN_RADIX || radix > MAX_RADIX || |
1789 |
|
digit < 0 || digit >= radix) |
1790 |
|
return '\u0000'; |
1791 |
|
return (char) (digit < 10 ? ('0' + digit) : ('a' + digit - 10)); |
1792 |
} |
} |
1793 |
|
|
1794 |
/** |
/** |
1795 |
* Determines the Unicode character block that a character belongs to. |
* Returns the Unicode directionality property of the character. This |
1796 |
* |
* is used in the visual ordering of text. |
1797 |
* @param ch character for which the Unicode character block will |
* TODO: Add this method. |
1798 |
* be retrieved |
* |
1799 |
* |
* @param ch the character to look up |
1800 |
* @return the Unicode character block which ch belongs to, or null |
* @return the directionality constant, or DIRECTIONALITY_UNDEFINED |
1801 |
* if ch does not belong to any Unicode character block |
* @see #DIRECTIONALITY_UNDEFINED |
1802 |
* |
* @see #DIRECTIONALITY_LEFT_TO_RIGHT |
1803 |
* @see java.lang.Character.Subset |
* @see #DIRECTIONALITY_RIGHT_TO_LEFT |
1804 |
|
* @see #DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC |
1805 |
|
* @see #DIRECTIONALITY_EUROPEAN_NUMBER |
1806 |
|
* @see #DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR |
1807 |
|
* @see #DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR |
1808 |
|
* @see #DIRECTIONALITY_ARABIC_NUMBER |
1809 |
|
* @see #DIRECTIONALITY_COMMON_NUMBER_SEPARATOR |
1810 |
|
* @see #DIRECTIONALITY_NONSPACING_MARK |
1811 |
|
* @see #DIRECTIONALITY_BOUNDARY_NEUTRAL |
1812 |
|
* @see #DIRECTIONALITY_PARAGRAPH_SEPARATOR |
1813 |
|
* @see #DIRECTIONALITY_SEGMENT_SEPARATOR |
1814 |
|
* @see #DIRECTIONALITY_WHITESPACE |
1815 |
|
* @see #DIRECTIONALITY_OTHER_NEUTRALS |
1816 |
|
* @see #DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING |
1817 |
|
* @see #DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE |
1818 |
|
* @see #DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING |
1819 |
|
* @see #DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE |
1820 |
|
* @see #DIRECTIONALITY_POP_DIRECTIONAL_FORMAT |
1821 |
|
* @since 1.4 |
1822 |
|
*/ |
1823 |
|
|
1824 |
|
/** |
1825 |
|
* Determines whether the character is mirrored according to Unicode. For |
1826 |
|
* example, <code>\u0028</code> (LEFT PARENTHESIS) appears as '(' in |
1827 |
|
* left-to-right text, but ')' in right-to-left text. |
1828 |
|
* TODO: Add this method. |
1829 |
|
* |
1830 |
|
* @param ch the character to look up |
1831 |
|
* @return true if the character is mirrored |
1832 |
|
* @since 1.4 |
1833 |
*/ |
*/ |
|
public static Character.Subset getUnicodeBlock(char ch) { |
|
|
return Character.Subset.getBlock(ch); |
|
|
} |
|
1834 |
|
|
1835 |
/** |
/** |
1836 |
* Compares another Character to this Character, numerically. |
* Compares another Character to this Character, numerically. |
1837 |
* |
* |
1838 |
* @param anotherCharacter Character to compare with this Character |
* @param anotherCharacter Character to compare with this Character |
|
* |
|
1839 |
* @return a negative integer if this Character is less than |
* @return a negative integer if this Character is less than |
1840 |
* anotherCharacter, zero if this Character is equal to anotherCharacter, or |
* anotherCharacter, zero if this Character is equal, and |
1841 |
* a positive integer if this Character is greater than anotherCharacter |
* a positive integer if this Character is greater |
1842 |
* |
* @throws NullPointerException if anotherCharacter is null |
1843 |
* @exception NullPointerException if anotherCharacter is null |
* @since 1.2 |
1844 |
*/ |
*/ |
1845 |
public int compareTo(Character anotherCharacter) |
public int compareTo(Character anotherCharacter) |
1846 |
throws NullPointerException { |
{ |
1847 |
return value - anotherCharacter.value; |
return value - anotherCharacter.value; |
1848 |
} |
} |
1849 |
|
|
1853 |
* compareTo(Character). |
* compareTo(Character). |
1854 |
* |
* |
1855 |
* @param o object to compare |
* @param o object to compare |
1856 |
|
* @return the comparison value |
1857 |
|
* @throws ClassCastException if o is not a Character object |
1858 |
|
* @throws NullPointerException if o is null |
1859 |
|
* @see #compareTo(Character) |
1860 |
|
* @since 1.2 |
1861 |
|
*/ |
1862 |
|
public int compareTo(Object o) |
1863 |
|
{ |
1864 |
|
return compareTo((Character) o); |
1865 |
|
} |
1866 |
|
|
1867 |
|
/** |
1868 |
|
* Determines the Unicode character block that a character belongs to. |
1869 |
|
* TODO: This should not be public API. |
1870 |
* |
* |
1871 |
* @return a negative integer if this Character is less than o, |
* @param ch character for which the Unicode character block will |
1872 |
* zero if this Character is equal to o, or a positive integer if this |
* be retrieved |
1873 |
* Character is greater than o |
* @return the Unicode character block which ch belongs to, or null |
1874 |
* |
* if ch does not belong to any Unicode character block |
1875 |
* @exception ClassCastException if o is not a Character object |
* @see Subset |
1876 |
* @exception NullPointerException if o is null |
*/ |
1877 |
* |
public static Character.Subset getUnicodeBlock(char ch) |
1878 |
* @see java.lang.Character#compareTo(Character) |
{ |
1879 |
*/ |
return Character.Subset.getBlock(ch); |
|
public int compareTo(Object o) |
|
|
throws ClassCastException, NullPointerException { |
|
|
return compareTo((Character)o); |
|
1880 |
} |
} |
1881 |
} |
} //class Character |
1882 |
|
|
1883 |
/** |
/** |
1884 |
* Represents an entry in block.uni |
* Represents an entry in block.uni. |
1885 |
|
* TODO: This should be a private nested class of Character, as it is not |
1886 |
|
* public in java.lang. |
1887 |
*/ |
*/ |
1888 |
final class Block { |
final class Block |
1889 |
|
{ |
1890 |
|
/** The start character of a compressed block. */ |
1891 |
char start; |
char start; |
1892 |
|
/** The end character of a compressed block. */ |
1893 |
char end; |
char end; |
1894 |
|
/** True if the block represents multiple characters. */ |
1895 |
boolean compressed; |
boolean compressed; |
1896 |
|
/** The offset of the block. */ |
1897 |
int offset; |
int offset; |
1898 |
|
|
1899 |
Block(char start, char end, boolean compressed, int offset) { |
/** |
1900 |
|
* Construct a block. |
1901 |
|
* @param start the start character |
1902 |
|
* @param end the end character |
1903 |
|
* @param compressed if the block is compressed |
1904 |
|
* @param offset the offset of the block |
1905 |
|
*/ |
1906 |
|
Block(char start, char end, boolean compressed, int offset) |
1907 |
|
{ |
1908 |
this.start = start; |
this.start = start; |
1909 |
this.end = end; |
this.end = end; |
1910 |
this.compressed = compressed; |
this.compressed = compressed; |
1914 |
|
|
1915 |
/** |
/** |
1916 |
* Represents all the attributes stored for a character. |
* Represents all the attributes stored for a character. |
1917 |
|
* TODO: This should be a private nested class of Character, as it is not |
1918 |
|
* public in java.lang. |
1919 |
*/ |
*/ |
1920 |
final class CharAttr { |
final class CharAttr |
1921 |
|
{ |
1922 |
|
/** If the character is a non-breaking space. */ |
1923 |
boolean noBreakSpace; |
boolean noBreakSpace; |
1924 |
|
/** The character category. */ |
1925 |
int category; |
int category; |
1926 |
|
/** The character value. */ |
1927 |
int numericalDecimalValue; |
int numericalDecimalValue; |
1928 |
|
/** The uppercase version of the character. */ |
1929 |
char uppercase; |
char uppercase; |
1930 |
|
/** The lowercase version of the character. */ |
1931 |
char lowercase; |
char lowercase; |
1932 |
|
/** The character of this attribute. */ |
1933 |
char ch; |
char ch; |
1934 |
|
|
1935 |
CharAttr(char ch, boolean noBreakSpace, int category, |
/** |
1936 |
int numericalDecimalValue, |
* Construct the attributes for a character. |
1937 |
char uppercase, char lowercase) { |
* @param ch the character |
1938 |
|
* @param noBreakSpace if it is a non-breaking space |
1939 |
|
* @param category its category |
1940 |
|
* @param numericalDecimalValue its value |
1941 |
|
* @param uppercase the uppercase version |
1942 |
|
* @param lowercase the lowercase version |
1943 |
|
*/ |
1944 |
|
CharAttr(char ch, boolean noBreakSpace, int category, |
1945 |
|
int numericalDecimalValue, |
1946 |
|
char uppercase, char lowercase) |
1947 |
|
{ |
1948 |
this.noBreakSpace = noBreakSpace; |
this.noBreakSpace = noBreakSpace; |
1949 |
this.category = category; |
this.category = category; |
1950 |
this.numericalDecimalValue = numericalDecimalValue; |
this.numericalDecimalValue = numericalDecimalValue; |
1953 |
this.ch = ch; |
this.ch = ch; |
1954 |
} |
} |
1955 |
|
|
1956 |
boolean isNoBreakSpace() { |
/** |
1957 |
|
* Check if the character is a non-breaking space. |
1958 |
|
* @return true if non-breaking |
1959 |
|
*/ |
1960 |
|
boolean isNoBreakSpace() |
1961 |
|
{ |
1962 |
return noBreakSpace; |
return noBreakSpace; |
1963 |
} |
} |
1964 |
|
|
1965 |
int getNumericValue() { |
/** |
1966 |
if (numericalDecimalValue == 65535) return -1; |
* Return the value of the character. |
1967 |
if (numericalDecimalValue == 65534) return -2; |
* @return -1 if there is no value, -2 if the value is not a positive |
1968 |
|
* integer, or the actual value |
1969 |
|
*/ |
1970 |
|
int getNumericValue() |
1971 |
|
{ |
1972 |
|
if (numericalDecimalValue == 65535) |
1973 |
|
return -1; |
1974 |
|
if (numericalDecimalValue == 65534) |
1975 |
|
return -2; |
1976 |
return numericalDecimalValue; |
return numericalDecimalValue; |
1977 |
} |
} |
1978 |
|
|
1979 |
int getType() { |
/** |
1980 |
|
* Return the character category. |
1981 |
|
* @return the category |
1982 |
|
*/ |
1983 |
|
int getType() |
1984 |
|
{ |
1985 |
return category; |
return category; |
1986 |
} |
} |
1987 |
|
|
1988 |
char toUpperCase() { |
/** |
1989 |
|
* Return the uppercase version. |
1990 |
|
* @return the uppercase version, or this character |
1991 |
|
*/ |
1992 |
|
char toUpperCase() |
1993 |
|
{ |
1994 |
return (uppercase != 0) ? uppercase : ch; |
return (uppercase != 0) ? uppercase : ch; |
1995 |
} |
} |
1996 |
|
|
1997 |
char toLowerCase() { |
/** |
1998 |
|
* Return the lowercase version. |
1999 |
|
* @return the lowercase version, or this character |
2000 |
|
*/ |
2001 |
|
char toLowerCase() |
2002 |
|
{ |
2003 |
return (lowercase != 0) ? lowercase : ch; |
return (lowercase != 0) ? lowercase : ch; |
2004 |
} |
} |
2005 |
} |
} |