1. /*
  2. * @(#)Character.java 1.30 04/06/28
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.lang;
  8. import java.util.Map;
  9. import java.util.HashMap;
  10. import java.util.Locale;
  11. /**
  12. * The <code>Character</code> class wraps a value of the primitive
  13. * type <code>char</code> in an object. An object of type
  14. * <code>Character</code> contains a single field whose type is
  15. * <code>char</code>.
  16. * <p>
  17. * In addition, this class provides several methods for determining
  18. * a character's category (lowercase letter, digit, etc.) and for converting
  19. * characters from uppercase to lowercase and vice versa.
  20. * <p>
  21. * Character information is based on the Unicode Standard, version 4.0.
  22. * <p>
  23. * The methods and data of class <code>Character</code> are defined by
  24. * the information in the <i>UnicodeData</i> file that is part of the
  25. * Unicode Character Database maintained by the Unicode
  26. * Consortium. This file specifies various properties including name
  27. * and general category for every defined Unicode code point or
  28. * character range.
  29. * <p>
  30. * The file and its description are available from the Unicode Consortium at:
  31. * <ul>
  32. * <li><a href="http://www.unicode.org">http://www.unicode.org</a>
  33. * </ul>
  34. *
  35. * <h4><a name="unicode">Unicode Character Representations</a></h4>
  36. *
  37. * <p>The <code>char</code> data type (and therefore the value that a
  38. * <code>Character</code> object encapsulates) are based on the
  39. * original Unicode specification, which defined characters as
  40. * fixed-width 16-bit entities. The Unicode standard has since been
  41. * changed to allow for characters whose representation requires more
  42. * than 16 bits. The range of legal <em>code point</em>s is now
  43. * U+0000 to U+10FFFF, known as <em>Unicode scalar value</em>.
  44. * (Refer to the <a
  45. * href="http://www.unicode.org/reports/tr27/#notation"><i>
  46. * definition</i></a> of the U+<i>n</i> notation in the Unicode
  47. * standard.)
  48. *
  49. * <p>The set of characters from U+0000 to U+FFFF is sometimes
  50. * referred to as the <em>Basic Multilingual Plane (BMP)</em>. <a
  51. * name="supplementary">Characters</a> whose code points are greater
  52. * than U+FFFF are called <em>supplementary character</em>s. The Java
  53. * 2 platform uses the UTF-16 representation in <code>char</code>
  54. * arrays and in the <code>String</code> and <code>StringBuffer</code>
  55. * classes. In this representation, supplementary characters are
  56. * represented as a pair of <code>char</code> values, the first from
  57. * the <em>high-surrogates</em> range, (\uD800-\uDBFF), the
  58. * second from the <em>low-surrogates</em> range
  59. * (\uDC00-\uDFFF).
  60. *
  61. * <p>A <code>char</code> value, therefore, represents Basic
  62. * Multilingual Plane (BMP) code points, including the surrogate
  63. * code points, or code units of the UTF-16 encoding. An
  64. * <code>int</code> value represents all Unicode code points,
  65. * including supplementary code points. The lower (least significant)
  66. * 21 bits of <code>int</code> are used to represent Unicode code
  67. * points and the upper (most significant) 11 bits must be zero.
  68. * Unless otherwise specified, the behavior with respect to
  69. * supplementary characters and surrogate <code>char</code> values is
  70. * as follows:
  71. *
  72. * <ul>
  73. * <li>The methods that only accept a <code>char</code> value cannot support
  74. * supplementary characters. They treat <code>char</code> values from the
  75. * surrogate ranges as undefined characters. For example,
  76. * <code>Character.isLetter('\uD840')</code> returns <code>false</code>, even though
  77. * this specific value if followed by any low-surrogate value in a string
  78. * would represent a letter.
  79. *
  80. * <li>The methods that accept an <code>int</code> value support all
  81. * Unicode characters, including supplementary characters. For
  82. * example, <code>Character.isLetter(0x2F81A)</code> returns
  83. * <code>true</code> because the code point value represents a letter
  84. * (a CJK ideograph).
  85. * </ul>
  86. *
  87. * <p>In the J2SE API documentation, <em>Unicode code point</em> is
  88. * used for character values in the range between U+0000 and U+10FFFF,
  89. * and <em>Unicode code unit</em> is used for 16-bit
  90. * <code>char</code> values that are code units of the <em>UTF-16</em>
  91. * encoding. For more information on Unicode terminology, refer to the
  92. * <a href="http://www.unicode.org/glossary/">Unicode Glossary</a>.
  93. *
  94. * @author Lee Boynton
  95. * @author Guy Steele
  96. * @author Akira Tanaka
  97. * @since 1.0
  98. */
  99. public final
  100. class Character extends Object implements java.io.Serializable, Comparable<Character> {
  101. /**
  102. * The minimum radix available for conversion to and from strings.
  103. * The constant value of this field is the smallest value permitted
  104. * for the radix argument in radix-conversion methods such as the
  105. * <code>digit</code> method, the <code>forDigit</code>
  106. * method, and the <code>toString</code> method of class
  107. * <code>Integer</code>.
  108. *
  109. * @see java.lang.Character#digit(char, int)
  110. * @see java.lang.Character#forDigit(int, int)
  111. * @see java.lang.Integer#toString(int, int)
  112. * @see java.lang.Integer#valueOf(java.lang.String)
  113. */
  114. public static final int MIN_RADIX = 2;
  115. /**
  116. * The maximum radix available for conversion to and from strings.
  117. * The constant value of this field is the largest value permitted
  118. * for the radix argument in radix-conversion methods such as the
  119. * <code>digit</code> method, the <code>forDigit</code>
  120. * method, and the <code>toString</code> method of class
  121. * <code>Integer</code>.
  122. *
  123. * @see java.lang.Character#digit(char, int)
  124. * @see java.lang.Character#forDigit(int, int)
  125. * @see java.lang.Integer#toString(int, int)
  126. * @see java.lang.Integer#valueOf(java.lang.String)
  127. */
  128. public static final int MAX_RADIX = 36;
  129. /**
  130. * The constant value of this field is the smallest value of type
  131. * <code>char</code>, <code>'\u0000'</code>.
  132. *
  133. * @since 1.0.2
  134. */
  135. public static final char MIN_VALUE = '\u0000';
  136. /**
  137. * The constant value of this field is the largest value of type
  138. * <code>char</code>, <code>'\uFFFF'</code>.
  139. *
  140. * @since 1.0.2
  141. */
  142. public static final char MAX_VALUE = '\uffff';
  143. /**
  144. * The <code>Class</code> instance representing the primitive type
  145. * <code>char</code>.
  146. *
  147. * @since 1.1
  148. */
  149. public static final Class<Character> TYPE = Class.getPrimitiveClass("char");
  150. /*
  151. * Normative general types
  152. */
  153. /*
  154. * General character types
  155. */
  156. /**
  157. * General category "Cn" in the Unicode specification.
  158. * @since 1.1
  159. */
  160. public static final byte
  161. UNASSIGNED = 0;
  162. /**
  163. * General category "Lu" in the Unicode specification.
  164. * @since 1.1
  165. */
  166. public static final byte
  167. UPPERCASE_LETTER = 1;
  168. /**
  169. * General category "Ll" in the Unicode specification.
  170. * @since 1.1
  171. */
  172. public static final byte
  173. LOWERCASE_LETTER = 2;
  174. /**
  175. * General category "Lt" in the Unicode specification.
  176. * @since 1.1
  177. */
  178. public static final byte
  179. TITLECASE_LETTER = 3;
  180. /**
  181. * General category "Lm" in the Unicode specification.
  182. * @since 1.1
  183. */
  184. public static final byte
  185. MODIFIER_LETTER = 4;
  186. /**
  187. * General category "Lo" in the Unicode specification.
  188. * @since 1.1
  189. */
  190. public static final byte
  191. OTHER_LETTER = 5;
  192. /**
  193. * General category "Mn" in the Unicode specification.
  194. * @since 1.1
  195. */
  196. public static final byte
  197. NON_SPACING_MARK = 6;
  198. /**
  199. * General category "Me" in the Unicode specification.
  200. * @since 1.1
  201. */
  202. public static final byte
  203. ENCLOSING_MARK = 7;
  204. /**
  205. * General category "Mc" in the Unicode specification.
  206. * @since 1.1
  207. */
  208. public static final byte
  209. COMBINING_SPACING_MARK = 8;
  210. /**
  211. * General category "Nd" in the Unicode specification.
  212. * @since 1.1
  213. */
  214. public static final byte
  215. DECIMAL_DIGIT_NUMBER = 9;
  216. /**
  217. * General category "Nl" in the Unicode specification.
  218. * @since 1.1
  219. */
  220. public static final byte
  221. LETTER_NUMBER = 10;
  222. /**
  223. * General category "No" in the Unicode specification.
  224. * @since 1.1
  225. */
  226. public static final byte
  227. OTHER_NUMBER = 11;
  228. /**
  229. * General category "Zs" in the Unicode specification.
  230. * @since 1.1
  231. */
  232. public static final byte
  233. SPACE_SEPARATOR = 12;
  234. /**
  235. * General category "Zl" in the Unicode specification.
  236. * @since 1.1
  237. */
  238. public static final byte
  239. LINE_SEPARATOR = 13;
  240. /**
  241. * General category "Zp" in the Unicode specification.
  242. * @since 1.1
  243. */
  244. public static final byte
  245. PARAGRAPH_SEPARATOR = 14;
  246. /**
  247. * General category "Cc" in the Unicode specification.
  248. * @since 1.1
  249. */
  250. public static final byte
  251. CONTROL = 15;
  252. /**
  253. * General category "Cf" in the Unicode specification.
  254. * @since 1.1
  255. */
  256. public static final byte
  257. FORMAT = 16;
  258. /**
  259. * General category "Co" in the Unicode specification.
  260. * @since 1.1
  261. */
  262. public static final byte
  263. PRIVATE_USE = 18;
  264. /**
  265. * General category "Cs" in the Unicode specification.
  266. * @since 1.1
  267. */
  268. public static final byte
  269. SURROGATE = 19;
  270. /**
  271. * General category "Pd" in the Unicode specification.
  272. * @since 1.1
  273. */
  274. public static final byte
  275. DASH_PUNCTUATION = 20;
  276. /**
  277. * General category "Ps" in the Unicode specification.
  278. * @since 1.1
  279. */
  280. public static final byte
  281. START_PUNCTUATION = 21;
  282. /**
  283. * General category "Pe" in the Unicode specification.
  284. * @since 1.1
  285. */
  286. public static final byte
  287. END_PUNCTUATION = 22;
  288. /**
  289. * General category "Pc" in the Unicode specification.
  290. * @since 1.1
  291. */
  292. public static final byte
  293. CONNECTOR_PUNCTUATION = 23;
  294. /**
  295. * General category "Po" in the Unicode specification.
  296. * @since 1.1
  297. */
  298. public static final byte
  299. OTHER_PUNCTUATION = 24;
  300. /**
  301. * General category "Sm" in the Unicode specification.
  302. * @since 1.1
  303. */
  304. public static final byte
  305. MATH_SYMBOL = 25;
  306. /**
  307. * General category "Sc" in the Unicode specification.
  308. * @since 1.1
  309. */
  310. public static final byte
  311. CURRENCY_SYMBOL = 26;
  312. /**
  313. * General category "Sk" in the Unicode specification.
  314. * @since 1.1
  315. */
  316. public static final byte
  317. MODIFIER_SYMBOL = 27;
  318. /**
  319. * General category "So" in the Unicode specification.
  320. * @since 1.1
  321. */
  322. public static final byte
  323. OTHER_SYMBOL = 28;
  324. /**
  325. * General category "Pi" in the Unicode specification.
  326. * @since 1.4
  327. */
  328. public static final byte
  329. INITIAL_QUOTE_PUNCTUATION = 29;
  330. /**
  331. * General category "Pf" in the Unicode specification.
  332. * @since 1.4
  333. */
  334. public static final byte
  335. FINAL_QUOTE_PUNCTUATION = 30;
  336. /**
  337. * Error or non-char flag
  338. * @since 1.4
  339. */
  340. static final char CHAR_ERROR = '\uFFFF';
  341. /**
  342. * Undefined bidirectional character type. Undefined <code>char</code>
  343. * values have undefined directionality in the Unicode specification.
  344. * @since 1.4
  345. */
  346. public static final byte DIRECTIONALITY_UNDEFINED = -1;
  347. /**
  348. * Strong bidirectional character type "L" in the Unicode specification.
  349. * @since 1.4
  350. */
  351. public static final byte DIRECTIONALITY_LEFT_TO_RIGHT = 0;
  352. /**
  353. * Strong bidirectional character type "R" in the Unicode specification.
  354. * @since 1.4
  355. */
  356. public static final byte DIRECTIONALITY_RIGHT_TO_LEFT = 1;
  357. /**
  358. * Strong bidirectional character type "AL" in the Unicode specification.
  359. * @since 1.4
  360. */
  361. public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = 2;
  362. /**
  363. * Weak bidirectional character type "EN" in the Unicode specification.
  364. * @since 1.4
  365. */
  366. public static final byte DIRECTIONALITY_EUROPEAN_NUMBER = 3;
  367. /**
  368. * Weak bidirectional character type "ES" in the Unicode specification.
  369. * @since 1.4
  370. */
  371. public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = 4;
  372. /**
  373. * Weak bidirectional character type "ET" in the Unicode specification.
  374. * @since 1.4
  375. */
  376. public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR = 5;
  377. /**
  378. * Weak bidirectional character type "AN" in the Unicode specification.
  379. * @since 1.4
  380. */
  381. public static final byte DIRECTIONALITY_ARABIC_NUMBER = 6;
  382. /**
  383. * Weak bidirectional character type "CS" in the Unicode specification.
  384. * @since 1.4
  385. */
  386. public static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR = 7;
  387. /**
  388. * Weak bidirectional character type "NSM" in the Unicode specification.
  389. * @since 1.4
  390. */
  391. public static final byte DIRECTIONALITY_NONSPACING_MARK = 8;
  392. /**
  393. * Weak bidirectional character type "BN" in the Unicode specification.
  394. * @since 1.4
  395. */
  396. public static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL = 9;
  397. /**
  398. * Neutral bidirectional character type "B" in the Unicode specification.
  399. * @since 1.4
  400. */
  401. public static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR = 10;
  402. /**
  403. * Neutral bidirectional character type "S" in the Unicode specification.
  404. * @since 1.4
  405. */
  406. public static final byte DIRECTIONALITY_SEGMENT_SEPARATOR = 11;
  407. /**
  408. * Neutral bidirectional character type "WS" in the Unicode specification.
  409. * @since 1.4
  410. */
  411. public static final byte DIRECTIONALITY_WHITESPACE = 12;
  412. /**
  413. * Neutral bidirectional character type "ON" in the Unicode specification.
  414. * @since 1.4
  415. */
  416. public static final byte DIRECTIONALITY_OTHER_NEUTRALS = 13;
  417. /**
  418. * Strong bidirectional character type "LRE" in the Unicode specification.
  419. * @since 1.4
  420. */
  421. public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING = 14;
  422. /**
  423. * Strong bidirectional character type "LRO" in the Unicode specification.
  424. * @since 1.4
  425. */
  426. public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE = 15;
  427. /**
  428. * Strong bidirectional character type "RLE" in the Unicode specification.
  429. * @since 1.4
  430. */
  431. public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING = 16;
  432. /**
  433. * Strong bidirectional character type "RLO" in the Unicode specification.
  434. * @since 1.4
  435. */
  436. public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE = 17;
  437. /**
  438. * Weak bidirectional character type "PDF" in the Unicode specification.
  439. * @since 1.4
  440. */
  441. public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT = 18;
  442. /**
  443. * The minimum value of a Unicode high-surrogate code unit in the
  444. * UTF-16 encoding. A high-surrogate is also known as a
  445. * <i>leading-surrogate</i>.
  446. *
  447. * @since 1.5
  448. */
  449. public static final char MIN_HIGH_SURROGATE = '\uD800';
  450. /**
  451. * The maximum value of a Unicode high-surrogate code unit in the
  452. * UTF-16 encoding. A high-surrogate is also known as a
  453. * <i>leading-surrogate</i>.
  454. *
  455. * @since 1.5
  456. */
  457. public static final char MAX_HIGH_SURROGATE = '\uDBFF';
  458. /**
  459. * The minimum value of a Unicode low-surrogate code unit in the
  460. * UTF-16 encoding. A low-surrogate is also known as a
  461. * <i>trailing-surrogate</i>.
  462. *
  463. * @since 1.5
  464. */
  465. public static final char MIN_LOW_SURROGATE = '\uDC00';
  466. /**
  467. * The maximum value of a Unicode low-surrogate code unit in the
  468. * UTF-16 encoding. A low-surrogate is also known as a
  469. * <i>trailing-surrogate</i>.
  470. *
  471. * @since 1.5
  472. */
  473. public static final char MAX_LOW_SURROGATE = '\uDFFF';
  474. /**
  475. * The minimum value of a Unicode surrogate code unit in the UTF-16 encoding.
  476. *
  477. * @since 1.5
  478. */
  479. public static final char MIN_SURROGATE = MIN_HIGH_SURROGATE;
  480. /**
  481. * The maximum value of a Unicode surrogate code unit in the UTF-16 encoding.
  482. *
  483. * @since 1.5
  484. */
  485. public static final char MAX_SURROGATE = MAX_LOW_SURROGATE;
  486. /**
  487. * The minimum value of a supplementary code point.
  488. *
  489. * @since 1.5
  490. */
  491. public static final int MIN_SUPPLEMENTARY_CODE_POINT = 0x010000;
  492. /**
  493. * The minimum value of a Unicode code point.
  494. *
  495. * @since 1.5
  496. */
  497. public static final int MIN_CODE_POINT = 0x000000;
  498. /**
  499. * The maximum value of a Unicode code point.
  500. *
  501. * @since 1.5
  502. */
  503. public static final int MAX_CODE_POINT = 0x10ffff;
  504. /**
  505. * Instances of this class represent particular subsets of the Unicode
  506. * character set. The only family of subsets defined in the
  507. * <code>Character</code> class is <code>{@link Character.UnicodeBlock
  508. * UnicodeBlock}</code>. Other portions of the Java API may define other
  509. * subsets for their own purposes.
  510. *
  511. * @since 1.2
  512. */
  513. public static class Subset {
  514. private String name;
  515. /**
  516. * Constructs a new <code>Subset</code> instance.
  517. *
  518. * @exception NullPointerException if name is <code>null</code>
  519. * @param name The name of this subset
  520. */
  521. protected Subset(String name) {
  522. if (name == null) {
  523. throw new NullPointerException("name");
  524. }
  525. this.name = name;
  526. }
  527. /**
  528. * Compares two <code>Subset</code> objects for equality.
  529. * This method returns <code>true</code> if and only if
  530. * <code>this</code> and the argument refer to the same
  531. * object; since this method is <code>final</code>, this
  532. * guarantee holds for all subclasses.
  533. */
  534. public final boolean equals(Object obj) {
  535. return (this == obj);
  536. }
  537. /**
  538. * Returns the standard hash code as defined by the
  539. * <code>{@link Object#hashCode}</code> method. This method
  540. * is <code>final</code> in order to ensure that the
  541. * <code>equals</code> and <code>hashCode</code> methods will
  542. * be consistent in all subclasses.
  543. */
  544. public final int hashCode() {
  545. return super.hashCode();
  546. }
  547. /**
  548. * Returns the name of this subset.
  549. */
  550. public final String toString() {
  551. return name;
  552. }
  553. }
  554. /**
  555. * A family of character subsets representing the character blocks in the
  556. * Unicode specification. Character blocks generally define characters
  557. * used for a specific script or purpose. A character is contained by
  558. * at most one Unicode block.
  559. *
  560. * @since 1.2
  561. */
  562. public static final class UnicodeBlock extends Subset {
  563. private static Map map = new HashMap();
  564. /**
  565. * Create a UnicodeBlock with the given identifier name.
  566. * This name must be the same as the block identifier.
  567. */
  568. private UnicodeBlock(String idName) {
  569. super(idName);
  570. map.put(idName.toUpperCase(Locale.US), this);
  571. }
  572. /**
  573. * Create a UnicodeBlock with the given identifier name and
  574. * alias name.
  575. */
  576. private UnicodeBlock(String idName, String alias) {
  577. this(idName);
  578. map.put(alias.toUpperCase(Locale.US), this);
  579. }
  580. /**
  581. * Create a UnicodeBlock with the given identifier name and
  582. * alias names.
  583. */
  584. private UnicodeBlock(String idName, String[] aliasName) {
  585. this(idName);
  586. if (aliasName != null) {
  587. for(int x=0; x<aliasName.length; ++x) {
  588. map.put(aliasName[x].toUpperCase(Locale.US), this);
  589. }
  590. }
  591. }
  592. /**
  593. * Constant for the "Basic Latin" Unicode character block.
  594. * @since 1.2
  595. */
  596. public static final UnicodeBlock BASIC_LATIN =
  597. new UnicodeBlock("BASIC_LATIN", new String[] {"Basic Latin", "BasicLatin" });
  598. /**
  599. * Constant for the "Latin-1 Supplement" Unicode character block.
  600. * @since 1.2
  601. */
  602. public static final UnicodeBlock LATIN_1_SUPPLEMENT =
  603. new UnicodeBlock("LATIN_1_SUPPLEMENT", new String[]{ "Latin-1 Supplement", "Latin-1Supplement"});
  604. /**
  605. * Constant for the "Latin Extended-A" Unicode character block.
  606. * @since 1.2
  607. */
  608. public static final UnicodeBlock LATIN_EXTENDED_A =
  609. new UnicodeBlock("LATIN_EXTENDED_A", new String[]{ "Latin Extended-A", "LatinExtended-A"});
  610. /**
  611. * Constant for the "Latin Extended-B" Unicode character block.
  612. * @since 1.2
  613. */
  614. public static final UnicodeBlock LATIN_EXTENDED_B =
  615. new UnicodeBlock("LATIN_EXTENDED_B", new String[] {"Latin Extended-B", "LatinExtended-B"});
  616. /**
  617. * Constant for the "IPA Extensions" Unicode character block.
  618. * @since 1.2
  619. */
  620. public static final UnicodeBlock IPA_EXTENSIONS =
  621. new UnicodeBlock("IPA_EXTENSIONS", new String[] {"IPA Extensions", "IPAExtensions"});
  622. /**
  623. * Constant for the "Spacing Modifier Letters" Unicode character block.
  624. * @since 1.2
  625. */
  626. public static final UnicodeBlock SPACING_MODIFIER_LETTERS =
  627. new UnicodeBlock("SPACING_MODIFIER_LETTERS", new String[] { "Spacing Modifier Letters",
  628. "SpacingModifierLetters"});
  629. /**
  630. * Constant for the "Combining Diacritical Marks" Unicode character block.
  631. * @since 1.2
  632. */
  633. public static final UnicodeBlock COMBINING_DIACRITICAL_MARKS =
  634. new UnicodeBlock("COMBINING_DIACRITICAL_MARKS", new String[] {"Combining Diacritical Marks",
  635. "CombiningDiacriticalMarks" });
  636. /**
  637. * Constant for the "Greek and Coptic" Unicode character block.
  638. * <p>
  639. * This block was previously known as the "Greek" block.
  640. *
  641. * @since 1.2
  642. */
  643. public static final UnicodeBlock GREEK
  644. = new UnicodeBlock("GREEK", new String[] {"Greek and Coptic", "GreekandCoptic"});
  645. /**
  646. * Constant for the "Cyrillic" Unicode character block.
  647. * @since 1.2
  648. */
  649. public static final UnicodeBlock CYRILLIC =
  650. new UnicodeBlock("CYRILLIC");
  651. /**
  652. * Constant for the "Armenian" Unicode character block.
  653. * @since 1.2
  654. */
  655. public static final UnicodeBlock ARMENIAN =
  656. new UnicodeBlock("ARMENIAN");
  657. /**
  658. * Constant for the "Hebrew" Unicode character block.
  659. * @since 1.2
  660. */
  661. public static final UnicodeBlock HEBREW =
  662. new UnicodeBlock("HEBREW");
  663. /**
  664. * Constant for the "Arabic" Unicode character block.
  665. * @since 1.2
  666. */
  667. public static final UnicodeBlock ARABIC =
  668. new UnicodeBlock("ARABIC");
  669. /**
  670. * Constant for the "Devanagari" Unicode character block.
  671. * @since 1.2
  672. */
  673. public static final UnicodeBlock DEVANAGARI =
  674. new UnicodeBlock("DEVANAGARI");
  675. /**
  676. * Constant for the "Bengali" Unicode character block.
  677. * @since 1.2
  678. */
  679. public static final UnicodeBlock BENGALI =
  680. new UnicodeBlock("BENGALI");
  681. /**
  682. * Constant for the "Gurmukhi" Unicode character block.
  683. * @since 1.2
  684. */
  685. public static final UnicodeBlock GURMUKHI =
  686. new UnicodeBlock("GURMUKHI");
  687. /**
  688. * Constant for the "Gujarati" Unicode character block.
  689. * @since 1.2
  690. */
  691. public static final UnicodeBlock GUJARATI =
  692. new UnicodeBlock("GUJARATI");
  693. /**
  694. * Constant for the "Oriya" Unicode character block.
  695. * @since 1.2
  696. */
  697. public static final UnicodeBlock ORIYA =
  698. new UnicodeBlock("ORIYA");
  699. /**
  700. * Constant for the "Tamil" Unicode character block.
  701. * @since 1.2
  702. */
  703. public static final UnicodeBlock TAMIL =
  704. new UnicodeBlock("TAMIL");
  705. /**
  706. * Constant for the "Telugu" Unicode character block.
  707. * @since 1.2
  708. */
  709. public static final UnicodeBlock TELUGU =
  710. new UnicodeBlock("TELUGU");
  711. /**
  712. * Constant for the "Kannada" Unicode character block.
  713. * @since 1.2
  714. */
  715. public static final UnicodeBlock KANNADA =
  716. new UnicodeBlock("KANNADA");
  717. /**
  718. * Constant for the "Malayalam" Unicode character block.
  719. * @since 1.2
  720. */
  721. public static final UnicodeBlock MALAYALAM =
  722. new UnicodeBlock("MALAYALAM");
  723. /**
  724. * Constant for the "Thai" Unicode character block.
  725. * @since 1.2
  726. */
  727. public static final UnicodeBlock THAI =
  728. new UnicodeBlock("THAI");
  729. /**
  730. * Constant for the "Lao" Unicode character block.
  731. * @since 1.2
  732. */
  733. public static final UnicodeBlock LAO =
  734. new UnicodeBlock("LAO");
  735. /**
  736. * Constant for the "Tibetan" Unicode character block.
  737. * @since 1.2
  738. */
  739. public static final UnicodeBlock TIBETAN =
  740. new UnicodeBlock("TIBETAN");
  741. /**
  742. * Constant for the "Georgian" Unicode character block.
  743. * @since 1.2
  744. */
  745. public static final UnicodeBlock GEORGIAN =
  746. new UnicodeBlock("GEORGIAN");
  747. /**
  748. * Constant for the "Hangul Jamo" Unicode character block.
  749. * @since 1.2
  750. */
  751. public static final UnicodeBlock HANGUL_JAMO =
  752. new UnicodeBlock("HANGUL_JAMO", new String[] {"Hangul Jamo", "HangulJamo"});
  753. /**
  754. * Constant for the "Latin Extended Additional" Unicode character block.
  755. * @since 1.2
  756. */
  757. public static final UnicodeBlock LATIN_EXTENDED_ADDITIONAL =
  758. new UnicodeBlock("LATIN_EXTENDED_ADDITIONAL", new String[] {"Latin Extended Additional",
  759. "LatinExtendedAdditional"});
  760. /**
  761. * Constant for the "Greek Extended" Unicode character block.
  762. * @since 1.2
  763. */
  764. public static final UnicodeBlock GREEK_EXTENDED =
  765. new UnicodeBlock("GREEK_EXTENDED", new String[] {"Greek Extended", "GreekExtended"});
  766. /**
  767. * Constant for the "General Punctuation" Unicode character block.
  768. * @since 1.2
  769. */
  770. public static final UnicodeBlock GENERAL_PUNCTUATION =
  771. new UnicodeBlock("GENERAL_PUNCTUATION", new String[] {"General Punctuation", "GeneralPunctuation"});
  772. /**
  773. * Constant for the "Superscripts and Subscripts" Unicode character block.
  774. * @since 1.2
  775. */
  776. public static final UnicodeBlock SUPERSCRIPTS_AND_SUBSCRIPTS =
  777. new UnicodeBlock("SUPERSCRIPTS_AND_SUBSCRIPTS", new String[] {"Superscripts and Subscripts",
  778. "SuperscriptsandSubscripts" });
  779. /**
  780. * Constant for the "Currency Symbols" Unicode character block.
  781. * @since 1.2
  782. */
  783. public static final UnicodeBlock CURRENCY_SYMBOLS =
  784. new UnicodeBlock("CURRENCY_SYMBOLS", new String[] { "Currency Symbols", "CurrencySymbols"});
  785. /**
  786. * Constant for the "Combining Diacritical Marks for Symbols" Unicode character block.
  787. * <p>
  788. * This block was previously known as "Combining Marks for Symbols".
  789. * @since 1.2
  790. */
  791. public static final UnicodeBlock COMBINING_MARKS_FOR_SYMBOLS =
  792. new UnicodeBlock("COMBINING_MARKS_FOR_SYMBOLS", new String[] {"Combining Diacritical Marks for Symbols",
  793. "CombiningDiacriticalMarksforSymbols",
  794. "Combining Marks for Symbols",
  795. "CombiningMarksforSymbols" });
  796. /**
  797. * Constant for the "Letterlike Symbols" Unicode character block.
  798. * @since 1.2
  799. */
  800. public static final UnicodeBlock LETTERLIKE_SYMBOLS =
  801. new UnicodeBlock("LETTERLIKE_SYMBOLS", new String[] { "Letterlike Symbols", "LetterlikeSymbols"});
  802. /**
  803. * Constant for the "Number Forms" Unicode character block.
  804. * @since 1.2
  805. */
  806. public static final UnicodeBlock NUMBER_FORMS =
  807. new UnicodeBlock("NUMBER_FORMS", new String[] {"Number Forms", "NumberForms"});
  808. /**
  809. * Constant for the "Arrows" Unicode character block.
  810. * @since 1.2
  811. */
  812. public static final UnicodeBlock ARROWS =
  813. new UnicodeBlock("ARROWS");
  814. /**
  815. * Constant for the "Mathematical Operators" Unicode character block.
  816. * @since 1.2
  817. */
  818. public static final UnicodeBlock MATHEMATICAL_OPERATORS =
  819. new UnicodeBlock("MATHEMATICAL_OPERATORS", new String[] {"Mathematical Operators",
  820. "MathematicalOperators"});
  821. /**
  822. * Constant for the "Miscellaneous Technical" Unicode character block.
  823. * @since 1.2
  824. */
  825. public static final UnicodeBlock MISCELLANEOUS_TECHNICAL =
  826. new UnicodeBlock("MISCELLANEOUS_TECHNICAL", new String[] {"Miscellaneous Technical",
  827. "MiscellaneousTechnical"});
  828. /**
  829. * Constant for the "Control Pictures" Unicode character block.
  830. * @since 1.2
  831. */
  832. public static final UnicodeBlock CONTROL_PICTURES =
  833. new UnicodeBlock("CONTROL_PICTURES", new String[] {"Control Pictures", "ControlPictures"});
  834. /**
  835. * Constant for the "Optical Character Recognition" Unicode character block.
  836. * @since 1.2
  837. */
  838. public static final UnicodeBlock OPTICAL_CHARACTER_RECOGNITION =
  839. new UnicodeBlock("OPTICAL_CHARACTER_RECOGNITION", new String[] {"Optical Character Recognition",
  840. "OpticalCharacterRecognition"});
  841. /**
  842. * Constant for the "Enclosed Alphanumerics" Unicode character block.
  843. * @since 1.2
  844. */
  845. public static final UnicodeBlock ENCLOSED_ALPHANUMERICS =
  846. new UnicodeBlock("ENCLOSED_ALPHANUMERICS", new String[] {"Enclosed Alphanumerics",
  847. "EnclosedAlphanumerics"});
  848. /**
  849. * Constant for the "Box Drawing" Unicode character block.
  850. * @since 1.2
  851. */
  852. public static final UnicodeBlock BOX_DRAWING =
  853. new UnicodeBlock("BOX_DRAWING", new String[] {"Box Drawing", "BoxDrawing"});
  854. /**
  855. * Constant for the "Block Elements" Unicode character block.
  856. * @since 1.2
  857. */
  858. public static final UnicodeBlock BLOCK_ELEMENTS =
  859. new UnicodeBlock("BLOCK_ELEMENTS", new String[] {"Block Elements", "BlockElements"});
  860. /**
  861. * Constant for the "Geometric Shapes" Unicode character block.
  862. * @since 1.2
  863. */
  864. public static final UnicodeBlock GEOMETRIC_SHAPES =
  865. new UnicodeBlock("GEOMETRIC_SHAPES", new String[] {"Geometric Shapes", "GeometricShapes"});
  866. /**
  867. * Constant for the "Miscellaneous Symbols" Unicode character block.
  868. * @since 1.2
  869. */
  870. public static final UnicodeBlock MISCELLANEOUS_SYMBOLS =
  871. new UnicodeBlock("MISCELLANEOUS_SYMBOLS", new String[] {"Miscellaneous Symbols",
  872. "MiscellaneousSymbols"});
  873. /**
  874. * Constant for the "Dingbats" Unicode character block.
  875. * @since 1.2
  876. */
  877. public static final UnicodeBlock DINGBATS =
  878. new UnicodeBlock("DINGBATS");
  879. /**
  880. * Constant for the "CJK Symbols and Punctuation" Unicode character block.
  881. * @since 1.2
  882. */
  883. public static final UnicodeBlock CJK_SYMBOLS_AND_PUNCTUATION =
  884. new UnicodeBlock("CJK_SYMBOLS_AND_PUNCTUATION", new String[] {"CJK Symbols and Punctuation",
  885. "CJKSymbolsandPunctuation"});
  886. /**
  887. * Constant for the "Hiragana" Unicode character block.
  888. * @since 1.2
  889. */
  890. public static final UnicodeBlock HIRAGANA =
  891. new UnicodeBlock("HIRAGANA");
  892. /**
  893. * Constant for the "Katakana" Unicode character block.
  894. * @since 1.2
  895. */
  896. public static final UnicodeBlock KATAKANA =
  897. new UnicodeBlock("KATAKANA");
  898. /**
  899. * Constant for the "Bopomofo" Unicode character block.
  900. * @since 1.2
  901. */
  902. public static final UnicodeBlock BOPOMOFO =
  903. new UnicodeBlock("BOPOMOFO");
  904. /**
  905. * Constant for the "Hangul Compatibility Jamo" Unicode character block.
  906. * @since 1.2
  907. */
  908. public static final UnicodeBlock HANGUL_COMPATIBILITY_JAMO =
  909. new UnicodeBlock("HANGUL_COMPATIBILITY_JAMO", new String[] {"Hangul Compatibility Jamo",
  910. "HangulCompatibilityJamo"});
  911. /**
  912. * Constant for the "Kanbun" Unicode character block.
  913. * @since 1.2
  914. */
  915. public static final UnicodeBlock KANBUN =
  916. new UnicodeBlock("KANBUN");
  917. /**
  918. * Constant for the "Enclosed CJK Letters and Months" Unicode character block.
  919. * @since 1.2
  920. */
  921. public static final UnicodeBlock ENCLOSED_CJK_LETTERS_AND_MONTHS =
  922. new UnicodeBlock("ENCLOSED_CJK_LETTERS_AND_MONTHS", new String[] {"Enclosed CJK Letters and Months",
  923. "EnclosedCJKLettersandMonths"});
  924. /**
  925. * Constant for the "CJK Compatibility" Unicode character block.
  926. * @since 1.2
  927. */
  928. public static final UnicodeBlock CJK_COMPATIBILITY =
  929. new UnicodeBlock("CJK_COMPATIBILITY", new String[] {"CJK Compatibility", "CJKCompatibility"});
  930. /**
  931. * Constant for the "CJK Unified Ideographs" Unicode character block.
  932. * @since 1.2
  933. */
  934. public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS =
  935. new UnicodeBlock("CJK_UNIFIED_IDEOGRAPHS", new String[] {"CJK Unified Ideographs",
  936. "CJKUnifiedIdeographs"});
  937. /**
  938. * Constant for the "Hangul Syllables" Unicode character block.
  939. * @since 1.2
  940. */
  941. public static final UnicodeBlock HANGUL_SYLLABLES =
  942. new UnicodeBlock("HANGUL_SYLLABLES", new String[] {"Hangul Syllables", "HangulSyllables"});
  943. /**
  944. * Constant for the "Private Use Area" Unicode character block.
  945. * @since 1.2
  946. */
  947. public static final UnicodeBlock PRIVATE_USE_AREA =
  948. new UnicodeBlock("PRIVATE_USE_AREA", new String[] {"Private Use Area", "PrivateUseArea"});
  949. /**
  950. * Constant for the "CJK Compatibility Ideographs" Unicode character block.
  951. * @since 1.2
  952. */
  953. public static final UnicodeBlock CJK_COMPATIBILITY_IDEOGRAPHS =
  954. new UnicodeBlock("CJK_COMPATIBILITY_IDEOGRAPHS",
  955. new String[] {"CJK Compatibility Ideographs",
  956. "CJKCompatibilityIdeographs"});
  957. /**
  958. * Constant for the "Alphabetic Presentation Forms" Unicode character block.
  959. * @since 1.2
  960. */
  961. public static final UnicodeBlock ALPHABETIC_PRESENTATION_FORMS =
  962. new UnicodeBlock("ALPHABETIC_PRESENTATION_FORMS", new String[] {"Alphabetic Presentation Forms",
  963. "AlphabeticPresentationForms"});
  964. /**
  965. * Constant for the "Arabic Presentation Forms-A" Unicode character block.
  966. * @since 1.2
  967. */
  968. public static final UnicodeBlock ARABIC_PRESENTATION_FORMS_A =
  969. new UnicodeBlock("ARABIC_PRESENTATION_FORMS_A", new String[] {"Arabic Presentation Forms-A",
  970. "ArabicPresentationForms-A"});
  971. /**
  972. * Constant for the "Combining Half Marks" Unicode character block.
  973. * @since 1.2
  974. */
  975. public static final UnicodeBlock COMBINING_HALF_MARKS =
  976. new UnicodeBlock("COMBINING_HALF_MARKS", new String[] {"Combining Half Marks",
  977. "CombiningHalfMarks"});
  978. /**
  979. * Constant for the "CJK Compatibility Forms" Unicode character block.
  980. * @since 1.2
  981. */
  982. public static final UnicodeBlock CJK_COMPATIBILITY_FORMS =
  983. new UnicodeBlock("CJK_COMPATIBILITY_FORMS", new String[] {"CJK Compatibility Forms",
  984. "CJKCompatibilityForms"});
  985. /**
  986. * Constant for the "Small Form Variants" Unicode character block.
  987. * @since 1.2
  988. */
  989. public static final UnicodeBlock SMALL_FORM_VARIANTS =
  990. new UnicodeBlock("SMALL_FORM_VARIANTS", new String[] {"Small Form Variants",
  991. "SmallFormVariants"});
  992. /**
  993. * Constant for the "Arabic Presentation Forms-B" Unicode character block.
  994. * @since 1.2
  995. */
  996. public static final UnicodeBlock ARABIC_PRESENTATION_FORMS_B =
  997. new UnicodeBlock("ARABIC_PRESENTATION_FORMS_B", new String[] {"Arabic Presentation Forms-B",
  998. "ArabicPresentationForms-B"});
  999. /**
  1000. * Constant for the "Halfwidth and Fullwidth Forms" Unicode character block.
  1001. * @since 1.2
  1002. */
  1003. public static final UnicodeBlock HALFWIDTH_AND_FULLWIDTH_FORMS =
  1004. new UnicodeBlock("HALFWIDTH_AND_FULLWIDTH_FORMS",
  1005. new String[] {"Halfwidth and Fullwidth Forms",
  1006. "HalfwidthandFullwidthForms"});
  1007. /**
  1008. * Constant for the "Specials" Unicode character block.
  1009. * @since 1.2
  1010. */
  1011. public static final UnicodeBlock SPECIALS =
  1012. new UnicodeBlock("SPECIALS");
  1013. /**
  1014. * @deprecated As of J2SE 5, use {@link #HIGH_SURROGATES},
  1015. * {@link #HIGH_PRIVATE_USE_SURROGATES}, and
  1016. * {@link #LOW_SURROGATES}. These new constants match
  1017. * the block definitions of the Unicode Standard.
  1018. * The {@link #of(char)} and {@link #of(int)} methods
  1019. * return the new constants, not SURROGATES_AREA.
  1020. */
  1021. @Deprecated
  1022. public static final UnicodeBlock SURROGATES_AREA =
  1023. new UnicodeBlock("SURROGATES_AREA");
  1024. /**
  1025. * Constant for the "Syriac" Unicode character block.
  1026. * @since 1.4
  1027. */
  1028. public static final UnicodeBlock SYRIAC =
  1029. new UnicodeBlock("SYRIAC");
  1030. /**
  1031. * Constant for the "Thaana" Unicode character block.
  1032. * @since 1.4
  1033. */
  1034. public static final UnicodeBlock THAANA =
  1035. new UnicodeBlock("THAANA");
  1036. /**
  1037. * Constant for the "Sinhala" Unicode character block.
  1038. * @since 1.4
  1039. */
  1040. public static final UnicodeBlock SINHALA =
  1041. new UnicodeBlock("SINHALA");
  1042. /**
  1043. * Constant for the "Myanmar" Unicode character block.
  1044. * @since 1.4
  1045. */
  1046. public static final UnicodeBlock MYANMAR =
  1047. new UnicodeBlock("MYANMAR");
  1048. /**
  1049. * Constant for the "Ethiopic" Unicode character block.
  1050. * @since 1.4
  1051. */
  1052. public static final UnicodeBlock ETHIOPIC =
  1053. new UnicodeBlock("ETHIOPIC");
  1054. /**
  1055. * Constant for the "Cherokee" Unicode character block.
  1056. * @since 1.4
  1057. */
  1058. public static final UnicodeBlock CHEROKEE =
  1059. new UnicodeBlock("CHEROKEE");
  1060. /**
  1061. * Constant for the "Unified Canadian Aboriginal Syllabics" Unicode character block.
  1062. * @since 1.4
  1063. */
  1064. public static final UnicodeBlock UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS =
  1065. new UnicodeBlock("UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS",
  1066. new String[] {"Unified Canadian Aboriginal Syllabics",
  1067. "UnifiedCanadianAboriginalSyllabics"});
  1068. /**
  1069. * Constant for the "Ogham" Unicode character block.
  1070. * @since 1.4
  1071. */
  1072. public static final UnicodeBlock OGHAM =
  1073. new UnicodeBlock("OGHAM");
  1074. /**
  1075. * Constant for the "Runic" Unicode character block.
  1076. * @since 1.4
  1077. */
  1078. public static final UnicodeBlock RUNIC =
  1079. new UnicodeBlock("RUNIC");
  1080. /**
  1081. * Constant for the "Khmer" Unicode character block.
  1082. * @since 1.4
  1083. */
  1084. public static final UnicodeBlock KHMER =
  1085. new UnicodeBlock("KHMER");
  1086. /**
  1087. * Constant for the "Mongolian" Unicode character block.
  1088. * @since 1.4
  1089. */
  1090. public static final UnicodeBlock MONGOLIAN =
  1091. new UnicodeBlock("MONGOLIAN");
  1092. /**
  1093. * Constant for the "Braille Patterns" Unicode character block.
  1094. * @since 1.4
  1095. */
  1096. public static final UnicodeBlock BRAILLE_PATTERNS =
  1097. new UnicodeBlock("BRAILLE_PATTERNS", new String[] {"Braille Patterns",
  1098. "BraillePatterns"});
  1099. /**
  1100. * Constant for the "CJK Radicals Supplement" Unicode character block.
  1101. * @since 1.4
  1102. */
  1103. public static final UnicodeBlock CJK_RADICALS_SUPPLEMENT =
  1104. new UnicodeBlock("CJK_RADICALS_SUPPLEMENT", new String[] {"CJK Radicals Supplement",
  1105. "CJKRadicalsSupplement"});
  1106. /**
  1107. * Constant for the "Kangxi Radicals" Unicode character block.
  1108. * @since 1.4
  1109. */
  1110. public static final UnicodeBlock KANGXI_RADICALS =
  1111. new UnicodeBlock("KANGXI_RADICALS", new String[] {"Kangxi Radicals", "KangxiRadicals"});
  1112. /**
  1113. * Constant for the "Ideographic Description Characters" Unicode character block.
  1114. * @since 1.4
  1115. */
  1116. public static final UnicodeBlock IDEOGRAPHIC_DESCRIPTION_CHARACTERS =
  1117. new UnicodeBlock("IDEOGRAPHIC_DESCRIPTION_CHARACTERS", new String[] {"Ideographic Description Characters",
  1118. "IdeographicDescriptionCharacters"});
  1119. /**
  1120. * Constant for the "Bopomofo Extended" Unicode character block.
  1121. * @since 1.4
  1122. */
  1123. public static final UnicodeBlock BOPOMOFO_EXTENDED =
  1124. new UnicodeBlock("BOPOMOFO_EXTENDED", new String[] {"Bopomofo Extended",
  1125. "BopomofoExtended"});
  1126. /**
  1127. * Constant for the "CJK Unified Ideographs Extension A" Unicode character block.
  1128. * @since 1.4
  1129. */
  1130. public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A =
  1131. new UnicodeBlock("CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A", new String[] {"CJK Unified Ideographs Extension A",
  1132. "CJKUnifiedIdeographsExtensionA"});
  1133. /**
  1134. * Constant for the "Yi Syllables" Unicode character block.
  1135. * @since 1.4
  1136. */
  1137. public static final UnicodeBlock YI_SYLLABLES =
  1138. new UnicodeBlock("YI_SYLLABLES", new String[] {"Yi Syllables", "YiSyllables"});
  1139. /**
  1140. * Constant for the "Yi Radicals" Unicode character block.
  1141. * @since 1.4
  1142. */
  1143. public static final UnicodeBlock YI_RADICALS =
  1144. new UnicodeBlock("YI_RADICALS", new String[] {"Yi Radicals", "YiRadicals"});
  1145. /**
  1146. * Constant for the "Cyrillic Supplementary" Unicode character block.
  1147. * @since 1.5
  1148. */
  1149. public static final UnicodeBlock CYRILLIC_SUPPLEMENTARY =
  1150. new UnicodeBlock("CYRILLIC_SUPPLEMENTARY", new String[] {"Cyrillic Supplementary",
  1151. "CyrillicSupplementary"});
  1152. /**
  1153. * Constant for the "Tagalog" Unicode character block.
  1154. * @since 1.5
  1155. */
  1156. public static final UnicodeBlock TAGALOG =
  1157. new UnicodeBlock("TAGALOG");
  1158. /**
  1159. * Constant for the "Hanunoo" Unicode character block.
  1160. * @since 1.5
  1161. */
  1162. public static final UnicodeBlock HANUNOO =
  1163. new UnicodeBlock("HANUNOO");
  1164. /**
  1165. * Constant for the "Buhid" Unicode character block.
  1166. * @since 1.5
  1167. */
  1168. public static final UnicodeBlock BUHID =
  1169. new UnicodeBlock("BUHID");
  1170. /**
  1171. * Constant for the "Tagbanwa" Unicode character block.
  1172. * @since 1.5
  1173. */
  1174. public static final UnicodeBlock TAGBANWA =
  1175. new UnicodeBlock("TAGBANWA");
  1176. /**
  1177. * Constant for the "Limbu" Unicode character block.
  1178. * @since 1.5
  1179. */
  1180. public static final UnicodeBlock LIMBU =
  1181. new UnicodeBlock("LIMBU");
  1182. /**
  1183. * Constant for the "Tai Le" Unicode character block.
  1184. * @since 1.5
  1185. */
  1186. public static final UnicodeBlock TAI_LE =
  1187. new UnicodeBlock("TAI_LE", new String[] {"Tai Le", "TaiLe"});
  1188. /**
  1189. * Constant for the "Khmer Symbols" Unicode character block.
  1190. * @since 1.5
  1191. */
  1192. public static final UnicodeBlock KHMER_SYMBOLS =
  1193. new UnicodeBlock("KHMER_SYMBOLS", new String[] {"Khmer Symbols", "KhmerSymbols"});
  1194. /**
  1195. * Constant for the "Phonetic Extensions" Unicode character block.
  1196. * @since 1.5
  1197. */
  1198. public static final UnicodeBlock PHONETIC_EXTENSIONS =
  1199. new UnicodeBlock("PHONETIC_EXTENSIONS", new String[] {"Phonetic Extensions", "PhoneticExtensions"});
  1200. /**
  1201. * Constant for the "Miscellaneous Mathematical Symbols-A" Unicode character block.
  1202. * @since 1.5
  1203. */
  1204. public static final UnicodeBlock MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A =
  1205. new UnicodeBlock("MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A",
  1206. new String[]{"Miscellaneous Mathematical Symbols-A",
  1207. "MiscellaneousMathematicalSymbols-A"});
  1208. /**
  1209. * Constant for the "Supplemental Arrows-A" Unicode character block.
  1210. * @since 1.5
  1211. */
  1212. public static final UnicodeBlock SUPPLEMENTAL_ARROWS_A =
  1213. new UnicodeBlock("SUPPLEMENTAL_ARROWS_A", new String[] {"Supplemental Arrows-A",
  1214. "SupplementalArrows-A"});
  1215. /**
  1216. * Constant for the "Supplemental Arrows-B" Unicode character block.
  1217. * @since 1.5
  1218. */
  1219. public static final UnicodeBlock SUPPLEMENTAL_ARROWS_B =
  1220. new UnicodeBlock("SUPPLEMENTAL_ARROWS_B", new String[] {"Supplemental Arrows-B",
  1221. "SupplementalArrows-B"});
  1222. /**
  1223. * Constant for the "Miscellaneous Mathematical Symbols-B" Unicode character block.
  1224. * @since 1.5
  1225. */
  1226. public static final UnicodeBlock MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B
  1227. = new UnicodeBlock("MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B",
  1228. new String[] {"Miscellaneous Mathematical Symbols-B",
  1229. "MiscellaneousMathematicalSymbols-B"});
  1230. /**
  1231. * Constant for the "Supplemental Mathematical Operators" Unicode character block.
  1232. * @since 1.5
  1233. */
  1234. public static final UnicodeBlock SUPPLEMENTAL_MATHEMATICAL_OPERATORS =
  1235. new UnicodeBlock("SUPPLEMENTAL_MATHEMATICAL_OPERATORS",
  1236. new String[]{"Supplemental Mathematical Operators",
  1237. "SupplementalMathematicalOperators"} );
  1238. /**
  1239. * Constant for the "Miscellaneous Symbols and Arrows" Unicode character block.
  1240. * @since 1.5
  1241. */
  1242. public static final UnicodeBlock MISCELLANEOUS_SYMBOLS_AND_ARROWS =
  1243. new UnicodeBlock("MISCELLANEOUS_SYMBOLS_AND_ARROWS", new String[] {"Miscellaneous Symbols and Arrows",
  1244. "MiscellaneousSymbolsandArrows"});
  1245. /**
  1246. * Constant for the "Katakana Phonetic Extensions" Unicode character block.
  1247. * @since 1.5
  1248. */
  1249. public static final UnicodeBlock KATAKANA_PHONETIC_EXTENSIONS =
  1250. new UnicodeBlock("KATAKANA_PHONETIC_EXTENSIONS", new String[] {"Katakana Phonetic Extensions",
  1251. "KatakanaPhoneticExtensions"});
  1252. /**
  1253. * Constant for the "Yijing Hexagram Symbols" Unicode character block.
  1254. * @since 1.5
  1255. */
  1256. public static final UnicodeBlock YIJING_HEXAGRAM_SYMBOLS =
  1257. new UnicodeBlock("YIJING_HEXAGRAM_SYMBOLS", new String[] {"Yijing Hexagram Symbols",
  1258. "YijingHexagramSymbols"});
  1259. /**
  1260. * Constant for the "Variation Selectors" Unicode character block.
  1261. * @since 1.5
  1262. */
  1263. public static final UnicodeBlock VARIATION_SELECTORS =
  1264. new UnicodeBlock("VARIATION_SELECTORS", new String[] {"Variation Selectors", "VariationSelectors"});
  1265. /**
  1266. * Constant for the "Linear B Syllabary" Unicode character block.
  1267. * @since 1.5
  1268. */
  1269. public static final UnicodeBlock LINEAR_B_SYLLABARY =
  1270. new UnicodeBlock("LINEAR_B_SYLLABARY", new String[] {"Linear B Syllabary", "LinearBSyllabary"});
  1271. /**
  1272. * Constant for the "Linear B Ideograms" Unicode character block.
  1273. * @since 1.5
  1274. */
  1275. public static final UnicodeBlock LINEAR_B_IDEOGRAMS =
  1276. new UnicodeBlock("LINEAR_B_IDEOGRAMS", new String[] {"Linear B Ideograms", "LinearBIdeograms"});
  1277. /**
  1278. * Constant for the "Aegean Numbers" Unicode character block.
  1279. * @since 1.5
  1280. */
  1281. public static final UnicodeBlock AEGEAN_NUMBERS =
  1282. new UnicodeBlock("AEGEAN_NUMBERS", new String[] {"Aegean Numbers", "AegeanNumbers"});
  1283. /**
  1284. * Constant for the "Old Italic" Unicode character block.
  1285. * @since 1.5
  1286. */
  1287. public static final UnicodeBlock OLD_ITALIC =
  1288. new UnicodeBlock("OLD_ITALIC", new String[] {"Old Italic", "OldItalic"});
  1289. /**
  1290. * Constant for the "Gothic" Unicode character block.
  1291. * @since 1.5
  1292. */
  1293. public static final UnicodeBlock GOTHIC = new UnicodeBlock("GOTHIC");
  1294. /**
  1295. * Constant for the "Ugaritic" Unicode character block.
  1296. * @since 1.5
  1297. */
  1298. public static final UnicodeBlock UGARITIC = new UnicodeBlock("UGARITIC");
  1299. /**
  1300. * Constant for the "Deseret" Unicode character block.
  1301. * @since 1.5
  1302. */
  1303. public static final UnicodeBlock DESERET = new UnicodeBlock("DESERET");
  1304. /**
  1305. * Constant for the "Shavian" Unicode character block.
  1306. * @since 1.5
  1307. */
  1308. public static final UnicodeBlock SHAVIAN = new UnicodeBlock("SHAVIAN");
  1309. /**
  1310. * Constant for the "Osmanya" Unicode character block.
  1311. * @since 1.5
  1312. */
  1313. public static final UnicodeBlock OSMANYA = new UnicodeBlock("OSMANYA");
  1314. /**
  1315. * Constant for the "Cypriot Syllabary" Unicode character block.
  1316. * @since 1.5
  1317. */
  1318. public static final UnicodeBlock CYPRIOT_SYLLABARY =
  1319. new UnicodeBlock("CYPRIOT_SYLLABARY", new String[] {"Cypriot Syllabary", "CypriotSyllabary"});
  1320. /**
  1321. * Constant for the "Byzantine Musical Symbols" Unicode character block.
  1322. * @since 1.5
  1323. */
  1324. public static final UnicodeBlock BYZANTINE_MUSICAL_SYMBOLS =
  1325. new UnicodeBlock("BYZANTINE_MUSICAL_SYMBOLS", new String[] {"Byzantine Musical Symbols",
  1326. "ByzantineMusicalSymbols"});
  1327. /**
  1328. * Constant for the "Musical Symbols" Unicode character block.
  1329. * @since 1.5
  1330. */
  1331. public static final UnicodeBlock MUSICAL_SYMBOLS =
  1332. new UnicodeBlock("MUSICAL_SYMBOLS", new String[] {"Musical Symbols", "MusicalSymbols"});
  1333. /**
  1334. * Constant for the "Tai Xuan Jing Symbols" Unicode character block.
  1335. * @since 1.5
  1336. */
  1337. public static final UnicodeBlock TAI_XUAN_JING_SYMBOLS =
  1338. new UnicodeBlock("TAI_XUAN_JING_SYMBOLS", new String[] {"Tai Xuan Jing Symbols",
  1339. "TaiXuanJingSymbols"});
  1340. /**
  1341. * Constant for the "Mathematical Alphanumeric Symbols" Unicode character block.
  1342. * @since 1.5
  1343. */
  1344. public static final UnicodeBlock MATHEMATICAL_ALPHANUMERIC_SYMBOLS =
  1345. new UnicodeBlock("MATHEMATICAL_ALPHANUMERIC_SYMBOLS",
  1346. new String[] {"Mathematical Alphanumeric Symbols", "MathematicalAlphanumericSymbols"});
  1347. /**
  1348. * Constant for the "CJK Unified Ideographs Extension B" Unicode character block.
  1349. * @since 1.5
  1350. */
  1351. public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B =
  1352. new UnicodeBlock("CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B",
  1353. new String[] {"CJK Unified Ideographs Extension B", "CJKUnifiedIdeographsExtensionB"});
  1354. /**
  1355. * Constant for the "CJK Compatibility Ideographs Supplement" Unicode character block.
  1356. * @since 1.5
  1357. */
  1358. public static final UnicodeBlock CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT =
  1359. new UnicodeBlock("CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT",
  1360. new String[]{"CJK Compatibility Ideographs Supplement",
  1361. "CJKCompatibilityIdeographsSupplement"});
  1362. /**
  1363. * Constant for the "Tags" Unicode character block.
  1364. * @since 1.5
  1365. */
  1366. public static final UnicodeBlock TAGS = new UnicodeBlock("TAGS");
  1367. /**
  1368. * Constant for the "Variation Selectors Supplement" Unicode character block.
  1369. * @since 1.5
  1370. */
  1371. public static final UnicodeBlock VARIATION_SELECTORS_SUPPLEMENT =
  1372. new UnicodeBlock("VARIATION_SELECTORS_SUPPLEMENT", new String[] {"Variation Selectors Supplement",
  1373. "VariationSelectorsSupplement"});
  1374. /**
  1375. * Constant for the "Supplementary Private Use Area-A" Unicode character block.
  1376. * @since 1.5
  1377. */
  1378. public static final UnicodeBlock SUPPLEMENTARY_PRIVATE_USE_AREA_A =
  1379. new UnicodeBlock("SUPPLEMENTARY_PRIVATE_USE_AREA_A",
  1380. new String[] {"Supplementary Private Use Area-A",
  1381. "SupplementaryPrivateUseArea-A"});
  1382. /**
  1383. * Constant for the "Supplementary Private Use Area-B" Unicode character block.
  1384. * @since 1.5
  1385. */
  1386. public static final UnicodeBlock SUPPLEMENTARY_PRIVATE_USE_AREA_B =
  1387. new UnicodeBlock("SUPPLEMENTARY_PRIVATE_USE_AREA_B",
  1388. new String[] {"Supplementary Private Use Area-B",
  1389. "SupplementaryPrivateUseArea-B"});
  1390. /**
  1391. * Constant for the "High Surrogates" Unicode character block.
  1392. * This block represents codepoint values in the high surrogate
  1393. * range: 0xD800 through 0xDB7F
  1394. *
  1395. * @since 1.5
  1396. */
  1397. public static final UnicodeBlock HIGH_SURROGATES =
  1398. new UnicodeBlock("HIGH_SURROGATES", new String[] {"High Surrogates", "HighSurrogates"});
  1399. /**
  1400. * Constant for the "High Private Use Surrogates" Unicode character block.
  1401. * This block represents codepoint values in the high surrogate
  1402. * range: 0xDB80 through 0xDBFF
  1403. *
  1404. * @since 1.5
  1405. */
  1406. public static final UnicodeBlock HIGH_PRIVATE_USE_SURROGATES =
  1407. new UnicodeBlock("HIGH_PRIVATE_USE_SURROGATES", new String[] { "High Private Use Surrogates",
  1408. "HighPrivateUseSurrogates"});
  1409. /**
  1410. * Constant for the "Low Surrogates" Unicode character block.
  1411. * This block represents codepoint values in the high surrogate
  1412. * range: 0xDC00 through 0xDFFF
  1413. *
  1414. * @since 1.5
  1415. */
  1416. public static final UnicodeBlock LOW_SURROGATES =
  1417. new UnicodeBlock("LOW_SURROGATES", new String[] {"Low Surrogates", "LowSurrogates"});
  1418. private static final int blockStarts[] = {
  1419. 0x0000, // Basic Latin
  1420. 0x0080, // Latin-1 Supplement
  1421. 0x0100, // Latin Extended-A
  1422. 0x0180, // Latin Extended-B
  1423. 0x0250, // IPA Extensions
  1424. 0x02B0, // Spacing Modifier Letters
  1425. 0x0300, // Combining Diacritical Marks
  1426. 0x0370, // Greek and Coptic
  1427. 0x0400, // Cyrillic
  1428. 0x0500, // Cyrillic Supplementary
  1429. 0x0530, // Armenian
  1430. 0x0590, // Hebrew
  1431. 0x0600, // Arabic
  1432. 0x0700, // Syriac
  1433. 0x0750, // unassigned
  1434. 0x0780, // Thaana
  1435. 0x07C0, // unassigned
  1436. 0x0900, // Devanagari
  1437. 0x0980, // Bengali
  1438. 0x0A00, // Gurmukhi
  1439. 0x0A80, // Gujarati
  1440. 0x0B00, // Oriya
  1441. 0x0B80, // Tamil
  1442. 0x0C00, // Telugu
  1443. 0x0C80, // Kannada
  1444. 0x0D00, // Malayalam
  1445. 0x0D80, // Sinhala
  1446. 0x0E00, // Thai
  1447. 0x0E80, // Lao
  1448. 0x0F00, // Tibetan
  1449. 0x1000, // Myanmar
  1450. 0x10A0, // Georgian
  1451. 0x1100, // Hangul Jamo
  1452. 0x1200, // Ethiopic
  1453. 0x1380, // unassigned
  1454. 0x13A0, // Cherokee
  1455. 0x1400, // Unified Canadian Aboriginal Syllabics
  1456. 0x1680, // Ogham
  1457. 0x16A0, // Runic
  1458. 0x1700, // Tagalog
  1459. 0x1720, // Hanunoo
  1460. 0x1740, // Buhid
  1461. 0x1760, // Tagbanwa
  1462. 0x1780, // Khmer
  1463. 0x1800, // Mongolian
  1464. 0x18B0, // unassigned
  1465. 0x1900, // Limbu
  1466. 0x1950, // Tai Le
  1467. 0x1980, // unassigned
  1468. 0x19E0, // Khmer Symbols
  1469. 0x1A00, // unassigned
  1470. 0x1D00, // Phonetic Extensions
  1471. 0x1D80, // unassigned
  1472. 0x1E00, // Latin Extended Additional
  1473. 0x1F00, // Greek Extended
  1474. 0x2000, // General Punctuation
  1475. 0x2070, // Superscripts and Subscripts
  1476. 0x20A0, // Currency Symbols
  1477. 0x20D0, // Combining Diacritical Marks for Symbols
  1478. 0x2100, // Letterlike Symbols
  1479. 0x2150, // Number Forms
  1480. 0x2190, // Arrows
  1481. 0x2200, // Mathematical Operators
  1482. 0x2300, // Miscellaneous Technical
  1483. 0x2400, // Control Pictures
  1484. 0x2440, // Optical Character Recognition
  1485. 0x2460, // Enclosed Alphanumerics
  1486. 0x2500, // Box Drawing
  1487. 0x2580, // Block Elements
  1488. 0x25A0, // Geometric Shapes
  1489. 0x2600, // Miscellaneous Symbols
  1490. 0x2700, // Dingbats
  1491. 0x27C0, // Miscellaneous Mathematical Symbols-A
  1492. 0x27F0, // Supplemental Arrows-A
  1493. 0x2800, // Braille Patterns
  1494. 0x2900, // Supplemental Arrows-B
  1495. 0x2980, // Miscellaneous Mathematical Symbols-B
  1496. 0x2A00, // Supplemental Mathematical Operators
  1497. 0x2B00, // Miscellaneous Symbols and Arrows
  1498. 0x2C00, // unassigned
  1499. 0x2E80, // CJK Radicals Supplement
  1500. 0x2F00, // Kangxi Radicals
  1501. 0x2FE0, // unassigned
  1502. 0x2FF0, // Ideographic Description Characters
  1503. 0x3000, // CJK Symbols and Punctuation
  1504. 0x3040, // Hiragana
  1505. 0x30A0, // Katakana
  1506. 0x3100, // Bopomofo
  1507. 0x3130, // Hangul Compatibility Jamo
  1508. 0x3190, // Kanbun
  1509. 0x31A0, // Bopomofo Extended
  1510. 0x31C0, // unassigned
  1511. 0x31F0, // Katakana Phonetic Extensions
  1512. 0x3200, // Enclosed CJK Letters and Months
  1513. 0x3300, // CJK Compatibility
  1514. 0x3400, // CJK Unified Ideographs Extension A
  1515. 0x4DC0, // Yijing Hexagram Symbols
  1516. 0x4E00, // CJK Unified Ideographs
  1517. 0xA000, // Yi Syllables
  1518. 0xA490, // Yi Radicals
  1519. 0xA4D0, // unassigned
  1520. 0xAC00, // Hangul Syllables
  1521. 0xD7B0, // unassigned
  1522. 0xD800, // High Surrogates
  1523. 0xDB80, // High Private Use Surrogates
  1524. 0xDC00, // Low Surrogates
  1525. 0xE000, // Private Use
  1526. 0xF900, // CJK Compatibility Ideographs
  1527. 0xFB00, // Alphabetic Presentation Forms
  1528. 0xFB50, // Arabic Presentation Forms-A
  1529. 0xFE00, // Variation Selectors
  1530. 0xFE10, // unassigned
  1531. 0xFE20, // Combining Half Marks
  1532. 0xFE30, // CJK Compatibility Forms
  1533. 0xFE50, // Small Form Variants
  1534. 0xFE70, // Arabic Presentation Forms-B
  1535. 0xFF00, // Halfwidth and Fullwidth Forms
  1536. 0xFFF0, // Specials
  1537. 0x10000, // Linear B Syllabary
  1538. 0x10080, // Linear B Ideograms
  1539. 0x10100, // Aegean Numbers
  1540. 0x10140, // unassigned
  1541. 0x10300, // Old Italic
  1542. 0x10330, // Gothic
  1543. 0x10350, // unassigned
  1544. 0x10380, // Ugaritic
  1545. 0x103A0, // unassigned
  1546. 0x10400, // Deseret
  1547. 0x10450, // Shavian
  1548. 0x10480, // Osmanya
  1549. 0x104B0, // unassigned
  1550. 0x10800, // Cypriot Syllabary
  1551. 0x10840, // unassigned
  1552. 0x1D000, // Byzantine Musical Symbols
  1553. 0x1D100, // Musical Symbols
  1554. 0x1D200, // unassigned
  1555. 0x1D300, // Tai Xuan Jing Symbols
  1556. 0x1D360, // unassigned
  1557. 0x1D400, // Mathematical Alphanumeric Symbols
  1558. 0x1D800, // unassigned
  1559. 0x20000, // CJK Unified Ideographs Extension B
  1560. 0x2A6E0, // unassigned
  1561. 0x2F800, // CJK Compatibility Ideographs Supplement
  1562. 0x2FA20, // unassigned
  1563. 0xE0000, // Tags
  1564. 0xE0080, // unassigned
  1565. 0xE0100, // Variation Selectors Supplement
  1566. 0xE01F0, // unassigned
  1567. 0xF0000, // Supplementary Private Use Area-A
  1568. 0x100000, // Supplementary Private Use Area-B
  1569. };
  1570. private static final UnicodeBlock[] blocks = {
  1571. BASIC_LATIN,
  1572. LATIN_1_SUPPLEMENT,
  1573. LATIN_EXTENDED_A,
  1574. LATIN_EXTENDED_B,
  1575. IPA_EXTENSIONS,
  1576. SPACING_MODIFIER_LETTERS,
  1577. COMBINING_DIACRITICAL_MARKS,
  1578. GREEK,
  1579. CYRILLIC,
  1580. CYRILLIC_SUPPLEMENTARY,
  1581. ARMENIAN,
  1582. HEBREW,
  1583. ARABIC,
  1584. SYRIAC,
  1585. null,
  1586. THAANA,
  1587. null,
  1588. DEVANAGARI,
  1589. BENGALI,
  1590. GURMUKHI,
  1591. GUJARATI,
  1592. ORIYA,
  1593. TAMIL,
  1594. TELUGU,
  1595. KANNADA,
  1596. MALAYALAM,
  1597. SINHALA,
  1598. THAI,
  1599. LAO,
  1600. TIBETAN,
  1601. MYANMAR,
  1602. GEORGIAN,
  1603. HANGUL_JAMO,
  1604. ETHIOPIC,
  1605. null,
  1606. CHEROKEE,
  1607. UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS,
  1608. OGHAM,
  1609. RUNIC,
  1610. TAGALOG,
  1611. HANUNOO,
  1612. BUHID,
  1613. TAGBANWA,
  1614. KHMER,
  1615. MONGOLIAN,
  1616. null,
  1617. LIMBU,
  1618. TAI_LE,
  1619. null,
  1620. KHMER_SYMBOLS,
  1621. null,
  1622. PHONETIC_EXTENSIONS,
  1623. null,
  1624. LATIN_EXTENDED_ADDITIONAL,
  1625. GREEK_EXTENDED,
  1626. GENERAL_PUNCTUATION,
  1627. SUPERSCRIPTS_AND_SUBSCRIPTS,
  1628. CURRENCY_SYMBOLS,
  1629. COMBINING_MARKS_FOR_SYMBOLS,
  1630. LETTERLIKE_SYMBOLS,
  1631. NUMBER_FORMS,
  1632. ARROWS,
  1633. MATHEMATICAL_OPERATORS,
  1634. MISCELLANEOUS_TECHNICAL,
  1635. CONTROL_PICTURES,
  1636. OPTICAL_CHARACTER_RECOGNITION,
  1637. ENCLOSED_ALPHANUMERICS,
  1638. BOX_DRAWING,
  1639. BLOCK_ELEMENTS,
  1640. GEOMETRIC_SHAPES,
  1641. MISCELLANEOUS_SYMBOLS,
  1642. DINGBATS,
  1643. MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A,
  1644. SUPPLEMENTAL_ARROWS_A,
  1645. BRAILLE_PATTERNS,
  1646. SUPPLEMENTAL_ARROWS_B,
  1647. MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B,
  1648. SUPPLEMENTAL_MATHEMATICAL_OPERATORS,
  1649. MISCELLANEOUS_SYMBOLS_AND_ARROWS,
  1650. null,
  1651. CJK_RADICALS_SUPPLEMENT,
  1652. KANGXI_RADICALS,
  1653. null,
  1654. IDEOGRAPHIC_DESCRIPTION_CHARACTERS,
  1655. CJK_SYMBOLS_AND_PUNCTUATION,
  1656. HIRAGANA,
  1657. KATAKANA,
  1658. BOPOMOFO,
  1659. HANGUL_COMPATIBILITY_JAMO,
  1660. KANBUN,
  1661. BOPOMOFO_EXTENDED,
  1662. null,
  1663. KATAKANA_PHONETIC_EXTENSIONS,
  1664. ENCLOSED_CJK_LETTERS_AND_MONTHS,
  1665. CJK_COMPATIBILITY,
  1666. CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A,
  1667. YIJING_HEXAGRAM_SYMBOLS,
  1668. CJK_UNIFIED_IDEOGRAPHS,
  1669. YI_SYLLABLES,
  1670. YI_RADICALS,
  1671. null,
  1672. HANGUL_SYLLABLES,
  1673. null,
  1674. HIGH_SURROGATES,
  1675. HIGH_PRIVATE_USE_SURROGATES,
  1676. LOW_SURROGATES,
  1677. PRIVATE_USE_AREA,
  1678. CJK_COMPATIBILITY_IDEOGRAPHS,
  1679. ALPHABETIC_PRESENTATION_FORMS,
  1680. ARABIC_PRESENTATION_FORMS_A,
  1681. VARIATION_SELECTORS,
  1682. null,
  1683. COMBINING_HALF_MARKS,
  1684. CJK_COMPATIBILITY_FORMS,
  1685. SMALL_FORM_VARIANTS,
  1686. ARABIC_PRESENTATION_FORMS_B,
  1687. HALFWIDTH_AND_FULLWIDTH_FORMS,
  1688. SPECIALS,
  1689. LINEAR_B_SYLLABARY,
  1690. LINEAR_B_IDEOGRAMS,
  1691. AEGEAN_NUMBERS,
  1692. null,
  1693. OLD_ITALIC,
  1694. GOTHIC,
  1695. null,
  1696. UGARITIC,
  1697. null,
  1698. DESERET,
  1699. SHAVIAN,
  1700. OSMANYA,
  1701. null,
  1702. CYPRIOT_SYLLABARY,
  1703. null,
  1704. BYZANTINE_MUSICAL_SYMBOLS,
  1705. MUSICAL_SYMBOLS,
  1706. null,
  1707. TAI_XUAN_JING_SYMBOLS,
  1708. null,
  1709. MATHEMATICAL_ALPHANUMERIC_SYMBOLS,
  1710. null,
  1711. CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B,
  1712. null,
  1713. CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT,
  1714. null,
  1715. TAGS,
  1716. null,
  1717. VARIATION_SELECTORS_SUPPLEMENT,
  1718. null,
  1719. SUPPLEMENTARY_PRIVATE_USE_AREA_A,
  1720. SUPPLEMENTARY_PRIVATE_USE_AREA_B
  1721. };
  1722. /**
  1723. * Returns the object representing the Unicode block containing the
  1724. * given character, or <code>null</code> if the character is not a
  1725. * member of a defined block.
  1726. *
  1727. * <p><b>Note:</b> This method cannot handle <a
  1728. * href="Character.html#supplementary"> supplementary
  1729. * characters</a>. To support all Unicode characters,
  1730. * including supplementary characters, use the {@link
  1731. * #of(int)} method.
  1732. *
  1733. * @param c The character in question
  1734. * @return The <code>UnicodeBlock</code> instance representing the
  1735. * Unicode block of which this character is a member, or
  1736. * <code>null</code> if the character is not a member of any
  1737. * Unicode block
  1738. */
  1739. public static UnicodeBlock of(char c) {
  1740. return of((int)c);
  1741. }
  1742. /**
  1743. * Returns the object representing the Unicode block
  1744. * containing the given character (Unicode code point), or
  1745. * <code>null</code> if the character is not a member of a
  1746. * defined block.
  1747. *
  1748. * @param codePoint the character (Unicode code point) in question.
  1749. * @return The <code>UnicodeBlock</code> instance representing the
  1750. * Unicode block of which this character is a member, or
  1751. * <code>null</code> if the character is not a member of any
  1752. * Unicode block
  1753. * @exception IllegalArgumentException if the specified
  1754. * <code>codePoint</code> is an invalid Unicode code point.
  1755. * @see Character#isValidCodePoint(int)
  1756. * @since 1.5
  1757. */
  1758. public static UnicodeBlock of(int codePoint) {
  1759. if (!isValidCodePoint(codePoint)) {
  1760. throw new IllegalArgumentException();
  1761. }
  1762. int top, bottom, current;
  1763. bottom = 0;
  1764. top = blockStarts.length;
  1765. current = top2;
  1766. // invariant: top > current >= bottom && codePoint >= unicodeBlockStarts[bottom]
  1767. while (top - bottom > 1) {
  1768. if (codePoint >= blockStarts[current]) {
  1769. bottom = current;
  1770. } else {
  1771. top = current;
  1772. }
  1773. current = (top + bottom) / 2;
  1774. }
  1775. return blocks[current];
  1776. }
  1777. /**
  1778. * Returns the UnicodeBlock with the given name. Block
  1779. * names are determined by The Unicode Standard. The file
  1780. * Blocks-<version>.txt defines blocks for a particular
  1781. * version of the standard. The {@link Character} class specifies
  1782. * the version of the standard that it supports.
  1783. * <p>
  1784. * This method accepts block names in the following forms:
  1785. * <ol>
  1786. * <li> Canonical block names as defined by the Unicode Standard.
  1787. * For example, the standard defines a "Basic Latin" block. Therefore, this
  1788. * method accepts "Basic Latin" as a valid block name. The documentation of
  1789. * each UnicodeBlock provides the canonical name.
  1790. * <li>Canonical block names with all spaces removed. For example, "BasicLatin"
  1791. * is a valid block name for the "Basic Latin" block.
  1792. * <li>The text representation of each constant UnicodeBlock identifier.
  1793. * For example, this method will return the {@link #BASIC_LATIN} block if
  1794. * provided with the "BASIC_LATIN" name. This form replaces all spaces and
  1795. * hyphens in the canonical name with underscores.
  1796. * </ol>
  1797. * Finally, character case is ignored for all of the valid block name forms.
  1798. * For example, "BASIC_LATIN" and "basic_latin" are both valid block names.
  1799. * The en_US locale's case mapping rules are used to provide case-insensitive
  1800. * string comparisons for block name validation.
  1801. * <p>
  1802. * If the Unicode Standard changes block names, both the previous and
  1803. * current names will be accepted.
  1804. *
  1805. * @param blockName A <code>UnicodeBlock</code> name.
  1806. * @return The <code>UnicodeBlock</code> instance identified
  1807. * by <code>blockName</code>
  1808. * @throws IllegalArgumentException if <code>blockName</code> is an
  1809. * invalid name
  1810. * @throws NullPointerException if <code>blockName</code> is null
  1811. * @since 1.5
  1812. */
  1813. public static final UnicodeBlock forName(String blockName) {
  1814. UnicodeBlock block = (UnicodeBlock)map.get(blockName.toUpperCase(Locale.US));
  1815. if (block == null) {
  1816. throw new IllegalArgumentException();
  1817. }
  1818. return block;
  1819. }
  1820. }
  1821. /**
  1822. * The value of the <code>Character</code>.
  1823. *
  1824. * @serial
  1825. */
  1826. private final char value;
  1827. /** use serialVersionUID from JDK 1.0.2 for interoperability */
  1828. private static final long serialVersionUID = 3786198910865385080L;
  1829. /**
  1830. * Constructs a newly allocated <code>Character</code> object that
  1831. * represents the specified <code>char</code> value.
  1832. *
  1833. * @param value the value to be represented by the
  1834. * <code>Character</code> object.
  1835. */
  1836. public Character(char value) {
  1837. this.value = value;
  1838. }
  1839. private static class CharacterCache {
  1840. private CharacterCache(){}
  1841. static final Character cache[] = new Character[127 + 1];
  1842. static {
  1843. for(int i = 0; i < cache.length; i++)
  1844. cache[i] = new Character((char)i);
  1845. }
  1846. }
  1847. /**
  1848. * Returns a <tt>Character</tt> instance representing the specified
  1849. * <tt>char</tt> value.
  1850. * If a new <tt>Character</tt> instance is not required, this method
  1851. * should generally be used in preference to the constructor
  1852. * {@link #Character(char)}, as this method is likely to yield
  1853. * significantly better space and time performance by caching
  1854. * frequently requested values.
  1855. *
  1856. * @param c a char value.
  1857. * @return a <tt>Character</tt> instance representing <tt>c</tt>.
  1858. * @since 1.5
  1859. */
  1860. public static Character valueOf(char c) {
  1861. if(c <= 127) { // must cache
  1862. return CharacterCache.cache[(int)c];
  1863. }
  1864. return new Character(c);
  1865. }
  1866. /**
  1867. * Returns the value of this <code>Character</code> object.
  1868. * @return the primitive <code>char</code> value represented by
  1869. * this object.
  1870. */
  1871. public char charValue() {
  1872. return value;
  1873. }
  1874. /**
  1875. * Returns a hash code for this <code>Character</code>.
  1876. * @return a hash code value for this object.
  1877. */
  1878. public int hashCode() {
  1879. return (int)value;
  1880. }
  1881. /**
  1882. * Compares this object against the specified object.
  1883. * The result is <code>true</code> if and only if the argument is not
  1884. * <code>null</code> and is a <code>Character</code> object that
  1885. * represents the same <code>char</code> value as this object.
  1886. *
  1887. * @param obj the object to compare with.
  1888. * @return <code>true</code> if the objects are the same;
  1889. * <code>false</code> otherwise.
  1890. */
  1891. public boolean equals(Object obj) {
  1892. if (obj instanceof Character) {
  1893. return value == ((Character)obj).charValue();
  1894. }
  1895. return false;
  1896. }
  1897. /**
  1898. * Returns a <code>String</code> object representing this
  1899. * <code>Character</code>'s value. The result is a string of
  1900. * length 1 whose sole component is the primitive
  1901. * <code>char</code> value represented by this
  1902. * <code>Character</code> object.
  1903. *
  1904. * @return a string representation of this object.
  1905. */
  1906. public String toString() {
  1907. char buf[] = {value};
  1908. return String.valueOf(buf);
  1909. }
  1910. /**
  1911. * Returns a <code>String</code> object representing the
  1912. * specified <code>char</code>. The result is a string of length
  1913. * 1 consisting solely of the specified <code>char</code>.
  1914. *
  1915. * @param c the <code>char</code> to be converted
  1916. * @return the string representation of the specified <code>char</code>
  1917. * @since 1.4
  1918. */
  1919. public static String toString(char c) {
  1920. return String.valueOf(c);
  1921. }
  1922. // Maximum character handled by internal fast-path code which
  1923. // avoids initializing large tables.
  1924. // Note: performance of this "fast-path" code may be sub-optimal
  1925. // in negative cases for some accessors due to complicated ranges.
  1926. // Should revisit after optimization of table initialization.
  1927. private static final int FAST_PATH_MAX = 255;
  1928. /**
  1929. * Provide the character plane to which this codepoint belongs.
  1930. *
  1931. * @param ch the codepoint
  1932. * @return the plane of the codepoint argument
  1933. * @since 1.5
  1934. */
  1935. private static int getPlane(int ch) {
  1936. return (ch >>> 16);
  1937. }
  1938. /**
  1939. * Determines whether the specified code point is a valid Unicode
  1940. * code point value in the range of <code>0x0000</code> to
  1941. * <code>0x10FFFF</code> inclusive. This method is equivalent to
  1942. * the expression:
  1943. *
  1944. * <blockquote><pre>
  1945. * codePoint >= 0x0000 && codePoint <= 0x10FFFF
  1946. * </pre></blockquote>
  1947. *
  1948. * @param codePoint the Unicode code point to be tested
  1949. * @return <code>true</code> if the specified code point value
  1950. * is a valid code point value;
  1951. * <code>false</code> otherwise.
  1952. * @since 1.5
  1953. */
  1954. public static boolean isValidCodePoint(int codePoint) {
  1955. return codePoint >= MIN_CODE_POINT && codePoint <= MAX_CODE_POINT;
  1956. }
  1957. /**
  1958. * Determines whether the specified character (Unicode code point)
  1959. * is in the supplementary character range. The method call is
  1960. * equivalent to the expression:
  1961. * <blockquote><pre>
  1962. * codePoint >= 0x10000 && codePoint <= 0x10ffff
  1963. * </pre></blockquote>
  1964. *
  1965. * @param codePoint the character (Unicode code point) to be tested
  1966. * @return <code>true</code> if the specified character is in the Unicode
  1967. * supplementary character range; <code>false</code> otherwise.
  1968. * @since 1.5
  1969. */
  1970. public static boolean isSupplementaryCodePoint(int codePoint) {
  1971. return codePoint >= MIN_SUPPLEMENTARY_CODE_POINT
  1972. && codePoint <= MAX_CODE_POINT;
  1973. }
  1974. /**
  1975. * Determines if the given <code>char</code> value is a
  1976. * high-surrogate code unit (also known as <i>leading-surrogate
  1977. * code unit</i>). Such values do not represent characters by
  1978. * themselves, but are used in the representation of <a
  1979. * href="#supplementary">supplementary characters</a> in the
  1980. * UTF-16 encoding.
  1981. *
  1982. * <p>This method returns <code>true</code> if and only if
  1983. * <blockquote><pre>ch >= '\uD800' && ch <= '\uDBFF'
  1984. * </pre></blockquote>
  1985. * is <code>true</code>.
  1986. *
  1987. * @param ch the <code>char</code> value to be tested.
  1988. * @return <code>true</code> if the <code>char</code> value
  1989. * is between '\uD800' and '\uDBFF' inclusive;
  1990. * <code>false</code> otherwise.
  1991. * @see java.lang.Character#isLowSurrogate(char)
  1992. * @see Character.UnicodeBlock#of(int)
  1993. * @since 1.5
  1994. */
  1995. public static boolean isHighSurrogate(char ch) {
  1996. return ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE;
  1997. }
  1998. /**
  1999. * Determines if the given <code>char</code> value is a
  2000. * low-surrogate code unit (also known as <i>trailing-surrogate code
  2001. * unit</i>). Such values do not represent characters by themselves,
  2002. * but are used in the representation of <a
  2003. * href="#supplementary">supplementary characters</a> in the UTF-16 encoding.
  2004. *
  2005. * <p> This method returns <code>true</code> if and only if
  2006. * <blockquote><pre>ch >= '\uDC00' && ch <= '\uDFFF'
  2007. * </pre></blockquote> is <code>true</code>.
  2008. *
  2009. * @param ch the <code>char</code> value to be tested.
  2010. * @return <code>true</code> if the <code>char</code> value
  2011. * is between '\uDC00' and '\uDFFF' inclusive;
  2012. * <code>false</code> otherwise.
  2013. * @see java.lang.Character#isHighSurrogate(char)
  2014. * @since 1.5
  2015. */
  2016. public static boolean isLowSurrogate(char ch) {
  2017. return ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE;
  2018. }
  2019. /**
  2020. * Determines whether the specified pair of <code>char</code>
  2021. * values is a valid surrogate pair. This method is equivalent to
  2022. * the expression:
  2023. * <blockquote><pre>
  2024. * isHighSurrogate(high) && isLowSurrogate(low)
  2025. * </pre></blockquote>
  2026. *
  2027. * @param high the high-surrogate code value to be tested
  2028. * @param low the low-surrogate code value to be tested
  2029. * @return <code>true</code> if the specified high and
  2030. * low-surrogate code values represent a valid surrogate pair;
  2031. * <code>false</code> otherwise.
  2032. * @since 1.5
  2033. */
  2034. public static boolean isSurrogatePair(char high, char low) {
  2035. return isHighSurrogate(high) && isLowSurrogate(low);
  2036. }
  2037. /**
  2038. * Determines the number of <code>char</code> values needed to
  2039. * represent the specified character (Unicode code point). If the
  2040. * specified character is equal to or greater than 0x10000, then
  2041. * the method returns 2. Otherwise, the method returns 1.
  2042. *
  2043. * <p>This method doesn't validate the specified character to be a
  2044. * valid Unicode code point. The caller must validate the
  2045. * character value using {@link #isValidCodePoint(int) isValidCodePoint}
  2046. * if necessary.
  2047. *
  2048. * @param codePoint the character (Unicode code point) to be tested.
  2049. * @return 2 if the character is a valid supplementary character; 1 otherwise.
  2050. * @see #isSupplementaryCodePoint(int)
  2051. * @since 1.5
  2052. */
  2053. public static int charCount(int codePoint) {
  2054. return codePoint >= MIN_SUPPLEMENTARY_CODE_POINT? 2 : 1;
  2055. }
  2056. /**
  2057. * Converts the specified surrogate pair to its supplementary code
  2058. * point value. This method does not validate the specified
  2059. * surrogate pair. The caller must validate it using {@link
  2060. * #isSurrogatePair(char, char) isSurrogatePair} if necessary.
  2061. *
  2062. * @param high the high-surrogate code unit
  2063. * @param low the low-surrogate code unit
  2064. * @return the supplementary code point composed from the
  2065. * specified surrogate pair.
  2066. * @since 1.5
  2067. */
  2068. public static int toCodePoint(char high, char low) {
  2069. return ((high - MIN_HIGH_SURROGATE) << 10)
  2070. + (low - MIN_LOW_SURROGATE) + MIN_SUPPLEMENTARY_CODE_POINT;
  2071. }
  2072. /**
  2073. * Returns the code point at the given index of the
  2074. * <code>CharSequence</code>. If the <code>char</code> value at
  2075. * the given index in the <code>CharSequence</code> is in the
  2076. * high-surrogate range, the following index is less than the
  2077. * length of the <code>CharSequence</code>, and the
  2078. * <code>char</code> value at the following index is in the
  2079. * low-surrogate range, then the supplementary code point
  2080. * corresponding to this surrogate pair is returned. Otherwise,
  2081. * the <code>char</code> value at the given index is returned.
  2082. *
  2083. * @param seq a sequence of <code>char</code> values (Unicode code
  2084. * units)
  2085. * @param index the index to the <code>char</code> values (Unicode
  2086. * code units) in <code>seq</code> to be converted
  2087. * @return the Unicode code point at the given index
  2088. * @exception NullPointerException if <code>seq</code> is null.
  2089. * @exception IndexOutOfBoundsException if the value
  2090. * <code>index</code> is negative or not less than
  2091. * {@link CharSequence#length() seq.length()}.
  2092. * @since 1.5
  2093. */
  2094. public static int codePointAt(CharSequence seq, int index) {
  2095. char c1 = seq.charAt(index++);
  2096. if (isHighSurrogate(c1)) {
  2097. if (index < seq.length()) {
  2098. char c2 = seq.charAt(index);
  2099. if (isLowSurrogate(c2)) {
  2100. return toCodePoint(c1, c2);
  2101. }
  2102. }
  2103. }
  2104. return c1;
  2105. }
  2106. /**
  2107. * Returns the code point at the given index of the
  2108. * <code>char</code> array. If the <code>char</code> value at
  2109. * the given index in the <code>char</code> array is in the
  2110. * high-surrogate range, the following index is less than the
  2111. * length of the <code>char</code> array, and the
  2112. * <code>char</code> value at the following index is in the
  2113. * low-surrogate range, then the supplementary code point
  2114. * corresponding to this surrogate pair is returned. Otherwise,
  2115. * the <code>char</code> value at the given index is returned.
  2116. *
  2117. * @param a the <code>char</code> array
  2118. * @param index the index to the <code>char</code> values (Unicode
  2119. * code units) in the <code>char</code> array to be converted
  2120. * @return the Unicode code point at the given index
  2121. * @exception NullPointerException if <code>a</code> is null.
  2122. * @exception IndexOutOfBoundsException if the value
  2123. * <code>index</code> is negative or not less than
  2124. * the length of the <code>char</code> array.
  2125. * @since 1.5
  2126. */
  2127. public static int codePointAt(char[] a, int index) {
  2128. return codePointAtImpl(a, index, a.length);
  2129. }
  2130. /**
  2131. * Returns the code point at the given index of the
  2132. * <code>char</code> array, where only array elements with
  2133. * <code>index</code> less than <code>limit</code> can be used. If
  2134. * the <code>char</code> value at the given index in the
  2135. * <code>char</code> array is in the high-surrogate range, the
  2136. * following index is less than the <code>limit</code>, and the
  2137. * <code>char</code> value at the following index is in the
  2138. * low-surrogate range, then the supplementary code point
  2139. * corresponding to this surrogate pair is returned. Otherwise,
  2140. * the <code>char</code> value at the given index is returned.
  2141. *
  2142. * @param a the <code>char</code> array
  2143. * @param index the index to the <code>char</code> values (Unicode
  2144. * code units) in the <code>char</code> array to be converted
  2145. * @param limit the index after the last array element that can be used in the
  2146. * <code>char</code> array
  2147. * @return the Unicode code point at the given index
  2148. * @exception NullPointerException if <code>a</code> is null.
  2149. * @exception IndexOutOfBoundsException if the <code>index</code>
  2150. * argument is negative or not less than the <code>limit</code>
  2151. * argument, or if the <code>limit</code> argument is negative or
  2152. * greater than the length of the <code>char</code> array.
  2153. * @since 1.5
  2154. */
  2155. public static int codePointAt(char[] a, int index, int limit) {
  2156. if (index >= limit || limit < 0 || limit > a.length) {
  2157. throw new IndexOutOfBoundsException();
  2158. }
  2159. return codePointAtImpl(a, index, limit);
  2160. }
  2161. static int codePointAtImpl(char[] a, int index, int limit) {
  2162. char c1 = a[index++];
  2163. if (isHighSurrogate(c1)) {
  2164. if (index < limit) {
  2165. char c2 = a[index];
  2166. if (isLowSurrogate(c2)) {
  2167. return toCodePoint(c1, c2);
  2168. }
  2169. }
  2170. }
  2171. return c1;
  2172. }
  2173. /**
  2174. * Returns the code point preceding the given index of the
  2175. * <code>CharSequence</code>. If the <code>char</code> value at
  2176. * <code>(index - 1)</code> in the <code>CharSequence</code> is in
  2177. * the low-surrogate range, <code>(index - 2)</code> is not
  2178. * negative, and the <code>char</code> value at <code>(index -
  2179. * 2)</code> in the <code>CharSequence</code> is in the
  2180. * high-surrogate range, then the supplementary code point
  2181. * corresponding to this surrogate pair is returned. Otherwise,
  2182. * the <code>char</code> value at <code>(index - 1)</code> is
  2183. * returned.
  2184. *
  2185. * @param seq the <code>CharSequence</code> instance
  2186. * @param index the index following the code point that should be returned
  2187. * @return the Unicode code point value before the given index.
  2188. * @exception NullPointerException if <code>seq</code> is null.
  2189. * @exception IndexOutOfBoundsException if the <code>index</code>
  2190. * argument is less than 1 or greater than {@link
  2191. * CharSequence#length() seq.length()}.
  2192. * @since 1.5
  2193. */
  2194. public static int codePointBefore(CharSequence seq, int index) {
  2195. char c2 = seq.charAt(--index);
  2196. if (isLowSurrogate(c2)) {
  2197. if (index > 0) {
  2198. char c1 = seq.charAt(--index);
  2199. if (isHighSurrogate(c1)) {
  2200. return toCodePoint(c1, c2);
  2201. }
  2202. }
  2203. }
  2204. return c2;
  2205. }
  2206. /**
  2207. * Returns the code point preceding the given index of the
  2208. * <code>char</code> array. If the <code>char</code> value at
  2209. * <code>(index - 1)</code> in the <code>char</code> array is in
  2210. * the low-surrogate range, <code>(index - 2)</code> is not
  2211. * negative, and the <code>char</code> value at <code>(index -
  2212. * 2)</code> in the <code>char</code> array is in the
  2213. * high-surrogate range, then the supplementary code point
  2214. * corresponding to this surrogate pair is returned. Otherwise,
  2215. * the <code>char</code> value at <code>(index - 1)</code> is
  2216. * returned.
  2217. *
  2218. * @param a the <code>char</code> array
  2219. * @param index the index following the code point that should be returned
  2220. * @return the Unicode code point value before the given index.
  2221. * @exception NullPointerException if <code>a</code> is null.
  2222. * @exception IndexOutOfBoundsException if the <code>index</code>
  2223. * argument is less than 1 or greater than the length of the
  2224. * <code>char</code> array
  2225. * @since 1.5
  2226. */
  2227. public static int codePointBefore(char[] a, int index) {
  2228. return codePointBeforeImpl(a, index, 0);
  2229. }
  2230. /**
  2231. * Returns the code point preceding the given index of the
  2232. * <code>char</code> array, where only array elements with
  2233. * <code>index</code> greater than or equal to <code>start</code>
  2234. * can be used. If the <code>char</code> value at <code>(index -
  2235. * 1)</code> in the <code>char</code> array is in the
  2236. * low-surrogate range, <code>(index - 2)</code> is not less than
  2237. * <code>start</code>, and the <code>char</code> value at
  2238. * <code>(index - 2)</code> in the <code>char</code> array is in
  2239. * the high-surrogate range, then the supplementary code point
  2240. * corresponding to this surrogate pair is returned. Otherwise,
  2241. * the <code>char</code> value at <code>(index - 1)</code> is
  2242. * returned.
  2243. *
  2244. * @param a the <code>char</code> array
  2245. * @param index the index following the code point that should be returned
  2246. * @param start the index of the first array element in the
  2247. * <code>char</code> array
  2248. * @return the Unicode code point value before the given index.
  2249. * @exception NullPointerException if <code>a</code> is null.
  2250. * @exception IndexOutOfBoundsException if the <code>index</code>
  2251. * argument is not greater than the <code>start</code> argument or
  2252. * is greater than the length of the <code>char</code> array, or
  2253. * if the <code>start</code> argument is negative or not less than
  2254. * the length of the <code>char</code> array.
  2255. * @since 1.5
  2256. */
  2257. public static int codePointBefore(char[] a, int index, int start) {
  2258. if (index <= start || start < 0 || start >= a.length) {
  2259. throw new IndexOutOfBoundsException();
  2260. }
  2261. return codePointBeforeImpl(a, index, start);
  2262. }
  2263. static int codePointBeforeImpl(char[] a, int index, int start) {
  2264. char c2 = a[--index];
  2265. if (isLowSurrogate(c2)) {
  2266. if (index > start) {
  2267. char c1 = a[--index];
  2268. if (isHighSurrogate(c1)) {
  2269. return toCodePoint(c1, c2);
  2270. }
  2271. }
  2272. }
  2273. return c2;
  2274. }
  2275. /**
  2276. * Converts the specified character (Unicode code point) to its
  2277. * UTF-16 representation. If the specified code point is a BMP
  2278. * (Basic Multilingual Plane or Plane 0) value, the same value is
  2279. * stored in <code>dst[dstIndex]</code>, and 1 is returned. If the
  2280. * specified code point is a supplementary character, its
  2281. * surrogate values are stored in <code>dst[dstIndex]</code>
  2282. * (high-surrogate) and <code>dst[dstIndex+1]</code>
  2283. * (low-surrogate), and 2 is returned.
  2284. *
  2285. * @param codePoint the character (Unicode code point) to be converted.
  2286. * @param dst an array of <code>char</code> in which the
  2287. * <code>codePoint</code>'s UTF-16 value is stored.
  2288. * @param dstIndex the start index into the <code>dst</code>
  2289. * array where the converted value is stored.
  2290. * @return 1 if the code point is a BMP code point, 2 if the
  2291. * code point is a supplementary code point.
  2292. * @exception IllegalArgumentException if the specified
  2293. * <code>codePoint</code> is not a valid Unicode code point.
  2294. * @exception NullPointerException if the specified <code>dst</code> is null.
  2295. * @exception IndexOutOfBoundsException if <code>dstIndex</code>
  2296. * is negative or not less than <code>dst.length</code>, or if
  2297. * <code>dst</code> at <code>dstIndex</code> doesn't have enough
  2298. * array element(s) to store the resulting <code>char</code>
  2299. * value(s). (If <code>dstIndex</code> is equal to
  2300. * <code>dst.length-1</code> and the specified
  2301. * <code>codePoint</code> is a supplementary character, the
  2302. * high-surrogate value is not stored in
  2303. * <code>dst[dstIndex]</code>.)
  2304. * @since 1.5
  2305. */
  2306. public static int toChars(int codePoint, char[] dst, int dstIndex) {
  2307. if (codePoint < 0 || codePoint > MAX_CODE_POINT) {
  2308. throw new IllegalArgumentException();
  2309. }
  2310. if (codePoint < MIN_SUPPLEMENTARY_CODE_POINT) {
  2311. dst[dstIndex] = (char) codePoint;
  2312. return 1;
  2313. }
  2314. toSurrogates(codePoint, dst, dstIndex);
  2315. return 2;
  2316. }
  2317. /**
  2318. * Converts the specified character (Unicode code point) to its
  2319. * UTF-16 representation stored in a <code>char</code> array. If
  2320. * the specified code point is a BMP (Basic Multilingual Plane or
  2321. * Plane 0) value, the resulting <code>char</code> array has
  2322. * the same value as <code>codePoint</code>. If the specified code
  2323. * point is a supplementary code point, the resulting
  2324. * <code>char</code> array has the corresponding surrogate pair.
  2325. *
  2326. * @param codePoint a Unicode code point
  2327. * @return a <code>char</code> array having
  2328. * <code>codePoint</code>'s UTF-16 representation.
  2329. * @exception IllegalArgumentException if the specified
  2330. * <code>codePoint</code> is not a valid Unicode code point.
  2331. * @since 1.5
  2332. */
  2333. public static char[] toChars(int codePoint) {
  2334. if (codePoint < 0 || codePoint > MAX_CODE_POINT) {
  2335. throw new IllegalArgumentException();
  2336. }
  2337. if (codePoint < MIN_SUPPLEMENTARY_CODE_POINT) {
  2338. return new char[] { (char) codePoint };
  2339. }
  2340. char[] result = new char[2];
  2341. toSurrogates(codePoint, result, 0);
  2342. return result;
  2343. }
  2344. static void toSurrogates(int codePoint, char[] dst, int index) {
  2345. int offset = codePoint - MIN_SUPPLEMENTARY_CODE_POINT;
  2346. dst[index+1] = (char)((offset & 0x3ff) + MIN_LOW_SURROGATE);
  2347. dst[index] = (char)((offset >>> 10) + MIN_HIGH_SURROGATE);
  2348. }
  2349. /**
  2350. * Returns the number of Unicode code points in the text range of
  2351. * the specified char sequence. The text range begins at the
  2352. * specified <code>beginIndex</code> and extends to the
  2353. * <code>char</code> at index <code>endIndex - 1</code>. Thus the
  2354. * length (in <code>char</code>s) of the text range is
  2355. * <code>endIndex-beginIndex</code>. Unpaired surrogates within
  2356. * the text range count as one code point each.
  2357. *
  2358. * @param seq the char sequence
  2359. * @param beginIndex the index to the first <code>char</code> of
  2360. * the text range.
  2361. * @param endIndex the index after the last <code>char</code> of
  2362. * the text range.
  2363. * @return the number of Unicode code points in the specified text
  2364. * range
  2365. * @exception NullPointerException if <code>seq</code> is null.
  2366. * @exception IndexOutOfBoundsException if the
  2367. * <code>beginIndex</code> is negative, or <code>endIndex</code>
  2368. * is larger than the length of the given sequence, or
  2369. * <code>beginIndex</code> is larger than <code>endIndex</code>.
  2370. * @since 1.5
  2371. */
  2372. public static int codePointCount(CharSequence seq, int beginIndex, int endIndex) {
  2373. int length = seq.length();
  2374. if (beginIndex < 0 || endIndex > length || beginIndex > endIndex) {
  2375. throw new IndexOutOfBoundsException();
  2376. }
  2377. int n = 0;
  2378. for (int i = beginIndex; i < endIndex; ) {
  2379. n++;
  2380. if (isHighSurrogate(seq.charAt(i++))) {
  2381. if (i < endIndex && isLowSurrogate(seq.charAt(i))) {
  2382. i++;
  2383. }
  2384. }
  2385. }
  2386. return n;
  2387. }
  2388. /**
  2389. * Returns the number of Unicode code points in a subarray of the
  2390. * <code>char</code> array argument. The <code>offset</code>
  2391. * argument is the index of the first <code>char</code> of the
  2392. * subarray and the <code>count</code> argument specifies the
  2393. * length of the subarray in <code>char</code>s. Unpaired
  2394. * surrogates within the subarray count as one code point each.
  2395. *
  2396. * @param a the <code>char</code> array
  2397. * @param offset the index of the first <code>char</code> in the
  2398. * given <code>char</code> array
  2399. * @param count the length of the subarray in <code>char</code>s
  2400. * @return the number of Unicode code points in the specified subarray
  2401. * @exception NullPointerException if <code>a</code> is null.
  2402. * @exception IndexOutOfBoundsException if <code>offset</code> or
  2403. * <code>count</code> is negative, or if <code>offset +
  2404. * count</code> is larger than the length of the given array.
  2405. * @since 1.5
  2406. */
  2407. public static int codePointCount(char[] a, int offset, int count) {
  2408. if (count > a.length - offset || offset < 0 || count < 0) {
  2409. throw new IndexOutOfBoundsException();
  2410. }
  2411. return codePointCountImpl(a, offset, count);
  2412. }
  2413. static int codePointCountImpl(char[] a, int offset, int count) {
  2414. int endIndex = offset + count;
  2415. int n = 0;
  2416. for (int i = offset; i < endIndex; ) {
  2417. n++;
  2418. if (isHighSurrogate(a[i++])) {
  2419. if (i < endIndex && isLowSurrogate(a[i])) {
  2420. i++;
  2421. }
  2422. }
  2423. }
  2424. return n;
  2425. }
  2426. /**
  2427. * Returns the index within the given char sequence that is offset
  2428. * from the given <code>index</code> by <code>codePointOffset</code>
  2429. * code points. Unpaired surrogates within the text range given by
  2430. * <code>index</code> and <code>codePointOffset</code> count as
  2431. * one code point each.
  2432. *
  2433. * @param seq the char sequence
  2434. * @param index the index to be offset
  2435. * @param codePointOffset the offset in code points
  2436. * @return the index within the char sequence
  2437. * @exception NullPointerException if <code>seq</code> is null.
  2438. * @exception IndexOutOfBoundsException if <code>index</code>
  2439. * is negative or larger then the length of the char sequence,
  2440. * or if <code>codePointOffset</code> is positive and the
  2441. * subsequence starting with <code>index</code> has fewer than
  2442. * <code>codePointOffset</code> code points, or if
  2443. * <code>codePointOffset</code> is negative and the subsequence
  2444. * before <code>index</code> has fewer than the absolute value
  2445. * of <code>codePointOffset</code> code points.
  2446. * @since 1.5
  2447. */
  2448. public static int offsetByCodePoints(CharSequence seq, int index,
  2449. int codePointOffset) {
  2450. int length = seq.length();
  2451. if (index < 0 || index > length) {
  2452. throw new IndexOutOfBoundsException();
  2453. }
  2454. int x = index;
  2455. if (codePointOffset >= 0) {
  2456. int i;
  2457. for (i = 0; x < length && i < codePointOffset; i++) {
  2458. if (isHighSurrogate(seq.charAt(x++))) {
  2459. if (x < length && isLowSurrogate(seq.charAt(x))) {
  2460. x++;
  2461. }
  2462. }
  2463. }
  2464. if (i < codePointOffset) {
  2465. throw new IndexOutOfBoundsException();
  2466. }
  2467. } else {
  2468. int i;
  2469. for (i = codePointOffset; x > 0 && i < 0; i++) {
  2470. if (isLowSurrogate(seq.charAt(--x))) {
  2471. if (x > 0 && isHighSurrogate(seq.charAt(x-1))) {
  2472. x--;
  2473. }
  2474. }
  2475. }
  2476. if (i < 0) {
  2477. throw new IndexOutOfBoundsException();
  2478. }
  2479. }
  2480. return x;
  2481. }
  2482. /**
  2483. * Returns the index within the given <code>char</code> subarray
  2484. * that is offset from the given <code>index</code> by
  2485. * <code>codePointOffset</code> code points. The
  2486. * <code>start</code> and <code>count</code> arguments specify a
  2487. * subarray of the <code>char</code> array. Unpaired surrogates
  2488. * within the text range given by <code>index</code> and
  2489. * <code>codePointOffset</code> count as one code point each.
  2490. *
  2491. * @param a the <code>char</code> array
  2492. * @param start the index of the first <code>char</code> of the
  2493. * subarray
  2494. * @param count the length of the subarray in <code>char</code>s
  2495. * @param index the index to be offset
  2496. * @param codePointOffset the offset in code points
  2497. * @return the index within the subarray
  2498. * @exception NullPointerException if <code>a</code> is null.
  2499. * @exception IndexOutOfBoundsException
  2500. * if <code>start</code> or <code>count</code> is negative,
  2501. * or if <code>start + count</code> is larger than the length of
  2502. * the given array,
  2503. * or if <code>index</code> is less than <code>start</code> or
  2504. * larger then <code>start + count</code>,
  2505. * or if <code>codePointOffset</code> is positive and the text range
  2506. * starting with <code>index</code> and ending with <code>start
  2507. * + count - 1</code> has fewer than <code>codePointOffset</code> code
  2508. * points,
  2509. * or if <code>codePointOffset</code> is negative and the text range
  2510. * starting with <code>start</code> and ending with <code>index
  2511. * - 1</code> has fewer than the absolute value of
  2512. * <code>codePointOffset</code> code points.
  2513. * @since 1.5
  2514. */
  2515. public static int offsetByCodePoints(char[] a, int start, int count,
  2516. int index, int codePointOffset) {
  2517. if (count > a.length-start || start < 0 || count < 0
  2518. || index < start || index > start+count) {
  2519. throw new IndexOutOfBoundsException();
  2520. }
  2521. return offsetByCodePointsImpl(a, start, count, index, codePointOffset);
  2522. }
  2523. static int offsetByCodePointsImpl(char[]a, int start, int count,
  2524. int index, int codePointOffset) {
  2525. int x = index;
  2526. if (codePointOffset >= 0) {
  2527. int limit = start + count;
  2528. int i;
  2529. for (i = 0; x < limit && i < codePointOffset; i++) {
  2530. if (isHighSurrogate(a[x++])) {
  2531. if (x < limit && isLowSurrogate(a[x])) {
  2532. x++;
  2533. }
  2534. }
  2535. }
  2536. if (i < codePointOffset) {
  2537. throw new IndexOutOfBoundsException();
  2538. }
  2539. } else {
  2540. int i;
  2541. for (i = codePointOffset; x > start && i < 0; i++) {
  2542. if (isLowSurrogate(a[--x])) {
  2543. if (x > start && isHighSurrogate(a[x-1])) {
  2544. x--;
  2545. }
  2546. }
  2547. }
  2548. if (i < 0) {
  2549. throw new IndexOutOfBoundsException();
  2550. }
  2551. }
  2552. return x;
  2553. }
  2554. /**
  2555. * Determines if the specified character is a lowercase character.
  2556. * <p>
  2557. * A character is lowercase if its general category type, provided
  2558. * by <code>Character.getType(ch)</code>, is
  2559. * <code>LOWERCASE_LETTER</code>.
  2560. * <p>
  2561. * The following are examples of lowercase characters:
  2562. * <p><blockquote><pre>
  2563. * a b c d e f g h i j k l m n o p q r s t u v w x y z
  2564. * '\u00DF' '\u00E0' '\u00E1' '\u00E2' '\u00E3' '\u00E4' '\u00E5' '\u00E6'
  2565. * '\u00E7' '\u00E8' '\u00E9' '\u00EA' '\u00EB' '\u00EC' '\u00ED' '\u00EE'
  2566. * '\u00EF' '\u00F0' '\u00F1' '\u00F2' '\u00F3' '\u00F4' '\u00F5' '\u00F6'
  2567. * '\u00F8' '\u00F9' '\u00FA' '\u00FB' '\u00FC' '\u00FD' '\u00FE' '\u00FF'
  2568. * </pre></blockquote>
  2569. * <p> Many other Unicode characters are lowercase too.
  2570. *
  2571. * <p><b>Note:</b> This method cannot handle <a
  2572. * href="#supplementary"> supplementary characters</a>. To support
  2573. * all Unicode characters, including supplementary characters, use
  2574. * the {@link #isLowerCase(int)} method.
  2575. *
  2576. * @param ch the character to be tested.
  2577. * @return <code>true</code> if the character is lowercase;
  2578. * <code>false</code> otherwise.
  2579. * @see java.lang.Character#isLowerCase(char)
  2580. * @see java.lang.Character#isTitleCase(char)
  2581. * @see java.lang.Character#toLowerCase(char)
  2582. * @see java.lang.Character#getType(char)
  2583. */
  2584. public static boolean isLowerCase(char ch) {
  2585. return isLowerCase((int)ch);
  2586. }
  2587. /**
  2588. * Determines if the specified character (Unicode code point) is a
  2589. * lowercase character.
  2590. * <p>
  2591. * A character is lowercase if its general category type, provided
  2592. * by {@link Character#getType getType(codePoint)}, is
  2593. * <code>LOWERCASE_LETTER</code>.
  2594. * <p>
  2595. * The following are examples of lowercase characters:
  2596. * <p><blockquote><pre>
  2597. * a b c d e f g h i j k l m n o p q r s t u v w x y z
  2598. * '\u00DF' '\u00E0' '\u00E1' '\u00E2' '\u00E3' '\u00E4' '\u00E5' '\u00E6'
  2599. * '\u00E7' '\u00E8' '\u00E9' '\u00EA' '\u00EB' '\u00EC' '\u00ED' '\u00EE'
  2600. * '\u00EF' '\u00F0' '\u00F1' '\u00F2' '\u00F3' '\u00F4' '\u00F5' '\u00F6'
  2601. * '\u00F8' '\u00F9' '\u00FA' '\u00FB' '\u00FC' '\u00FD' '\u00FE' '\u00FF'
  2602. * </pre></blockquote>
  2603. * <p> Many other Unicode characters are lowercase too.
  2604. *
  2605. * @param codePoint the character (Unicode code point) to be tested.
  2606. * @return <code>true</code> if the character is lowercase;
  2607. * <code>false</code> otherwise.
  2608. * @see java.lang.Character#isLowerCase(int)
  2609. * @see java.lang.Character#isTitleCase(int)
  2610. * @see java.lang.Character#toLowerCase(int)
  2611. * @see java.lang.Character#getType(int)
  2612. * @since 1.5
  2613. */
  2614. public static boolean isLowerCase(int codePoint) {
  2615. boolean bLowerCase = false;
  2616. // codePoint must be in the valid range of codepoints
  2617. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  2618. bLowerCase = CharacterDataLatin1.isLowerCase(codePoint);
  2619. } else {
  2620. int plane = getPlane(codePoint);
  2621. switch(plane) {
  2622. case(0):
  2623. bLowerCase = CharacterData00.isLowerCase(codePoint);
  2624. break;
  2625. case(1):
  2626. bLowerCase = CharacterData01.isLowerCase(codePoint);
  2627. break;
  2628. case(2):
  2629. bLowerCase = CharacterData02.isLowerCase(codePoint);
  2630. break;
  2631. case(3): // Undefined
  2632. case(4): // Undefined
  2633. case(5): // Undefined
  2634. case(6): // Undefined
  2635. case(7): // Undefined
  2636. case(8): // Undefined
  2637. case(9): // Undefined
  2638. case(10): // Undefined
  2639. case(11): // Undefined
  2640. case(12): // Undefined
  2641. case(13): // Undefined
  2642. bLowerCase = CharacterDataUndefined.isLowerCase(codePoint);
  2643. break;
  2644. case(14):
  2645. bLowerCase = CharacterData0E.isLowerCase(codePoint);
  2646. break;
  2647. case(15): // Private Use
  2648. case(16): // Private Use
  2649. bLowerCase = CharacterDataPrivateUse.isLowerCase(codePoint);
  2650. break;
  2651. default:
  2652. // the argument's plane is invalid, and thus is an invalid codepoint
  2653. // bLowerCase remains false
  2654. break;
  2655. }
  2656. }
  2657. return bLowerCase;
  2658. }
  2659. /**
  2660. * Determines if the specified character is an uppercase character.
  2661. * <p>
  2662. * A character is uppercase if its general category type, provided by
  2663. * <code>Character.getType(ch)</code>, is <code>UPPERCASE_LETTER</code>.
  2664. * <p>
  2665. * The following are examples of uppercase characters:
  2666. * <p><blockquote><pre>
  2667. * A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
  2668. * '\u00C0' '\u00C1' '\u00C2' '\u00C3' '\u00C4' '\u00C5' '\u00C6' '\u00C7'
  2669. * '\u00C8' '\u00C9' '\u00CA' '\u00CB' '\u00CC' '\u00CD' '\u00CE' '\u00CF'
  2670. * '\u00D0' '\u00D1' '\u00D2' '\u00D3' '\u00D4' '\u00D5' '\u00D6' '\u00D8'
  2671. * '\u00D9' '\u00DA' '\u00DB' '\u00DC' '\u00DD' '\u00DE'
  2672. * </pre></blockquote>
  2673. * <p> Many other Unicode characters are uppercase too.<p>
  2674. *
  2675. * <p><b>Note:</b> This method cannot handle <a
  2676. * href="#supplementary"> supplementary characters</a>. To support
  2677. * all Unicode characters, including supplementary characters, use
  2678. * the {@link #isUpperCase(int)} method.
  2679. *
  2680. * @param ch the character to be tested.
  2681. * @return <code>true</code> if the character is uppercase;
  2682. * <code>false</code> otherwise.
  2683. * @see java.lang.Character#isLowerCase(char)
  2684. * @see java.lang.Character#isTitleCase(char)
  2685. * @see java.lang.Character#toUpperCase(char)
  2686. * @see java.lang.Character#getType(char)
  2687. * @since 1.0
  2688. */
  2689. public static boolean isUpperCase(char ch) {
  2690. return isUpperCase((int)ch);
  2691. }
  2692. /**
  2693. * Determines if the specified character (Unicode code point) is an uppercase character.
  2694. * <p>
  2695. * A character is uppercase if its general category type, provided by
  2696. * {@link Character#getType(int) getType(codePoint)}, is <code>UPPERCASE_LETTER</code>.
  2697. * <p>
  2698. * The following are examples of uppercase characters:
  2699. * <p><blockquote><pre>
  2700. * A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
  2701. * '\u00C0' '\u00C1' '\u00C2' '\u00C3' '\u00C4' '\u00C5' '\u00C6' '\u00C7'
  2702. * '\u00C8' '\u00C9' '\u00CA' '\u00CB' '\u00CC' '\u00CD' '\u00CE' '\u00CF'
  2703. * '\u00D0' '\u00D1' '\u00D2' '\u00D3' '\u00D4' '\u00D5' '\u00D6' '\u00D8'
  2704. * '\u00D9' '\u00DA' '\u00DB' '\u00DC' '\u00DD' '\u00DE'
  2705. * </pre></blockquote>
  2706. * <p> Many other Unicode characters are uppercase too.<p>
  2707. *
  2708. * @param codePoint the character (Unicode code point) to be tested.
  2709. * @return <code>true</code> if the character is uppercase;
  2710. * <code>false</code> otherwise.
  2711. * @see java.lang.Character#isLowerCase(int)
  2712. * @see java.lang.Character#isTitleCase(int)
  2713. * @see java.lang.Character#toUpperCase(int)
  2714. * @see java.lang.Character#getType(int)
  2715. * @since 1.5
  2716. */
  2717. public static boolean isUpperCase(int codePoint) {
  2718. boolean bUpperCase = false;
  2719. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  2720. bUpperCase = CharacterDataLatin1.isUpperCase(codePoint);
  2721. } else {
  2722. int plane = getPlane(codePoint);
  2723. switch(plane) {
  2724. case(0):
  2725. bUpperCase = CharacterData00.isUpperCase(codePoint);
  2726. break;
  2727. case(1):
  2728. bUpperCase = CharacterData01.isUpperCase(codePoint);
  2729. break;
  2730. case(2):
  2731. bUpperCase = CharacterData02.isUpperCase(codePoint);
  2732. break;
  2733. case(3): // Undefined
  2734. case(4): // Undefined
  2735. case(5): // Undefined
  2736. case(6): // Undefined
  2737. case(7): // Undefined
  2738. case(8): // Undefined
  2739. case(9): // Undefined
  2740. case(10): // Undefined
  2741. case(11): // Undefined
  2742. case(12): // Undefined
  2743. case(13): // Undefined
  2744. bUpperCase = CharacterDataUndefined.isUpperCase(codePoint);
  2745. break;
  2746. case(14):
  2747. bUpperCase = CharacterData0E.isUpperCase(codePoint);
  2748. break;
  2749. case(15): // Private Use
  2750. case(16): // Private Use
  2751. bUpperCase = CharacterDataPrivateUse.isUpperCase(codePoint);
  2752. break;
  2753. default:
  2754. // the argument's plane is invalid, and thus is an invalid codepoint
  2755. // bUpperCase remains false;
  2756. break;
  2757. }
  2758. }
  2759. return bUpperCase;
  2760. }
  2761. /**
  2762. * Determines if the specified character is a titlecase character.
  2763. * <p>
  2764. * A character is a titlecase character if its general
  2765. * category type, provided by <code>Character.getType(ch)</code>,
  2766. * is <code>TITLECASE_LETTER</code>.
  2767. * <p>
  2768. * Some characters look like pairs of Latin letters. For example, there
  2769. * is an uppercase letter that looks like "LJ" and has a corresponding
  2770. * lowercase letter that looks like "lj". A third form, which looks like "Lj",
  2771. * is the appropriate form to use when rendering a word in lowercase
  2772. * with initial capitals, as for a book title.
  2773. * <p>
  2774. * These are some of the Unicode characters for which this method returns
  2775. * <code>true</code>:
  2776. * <ul>
  2777. * <li><code>LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON</code>
  2778. * <li><code>LATIN CAPITAL LETTER L WITH SMALL LETTER J</code>
  2779. * <li><code>LATIN CAPITAL LETTER N WITH SMALL LETTER J</code>
  2780. * <li><code>LATIN CAPITAL LETTER D WITH SMALL LETTER Z</code>
  2781. * </ul>
  2782. * <p> Many other Unicode characters are titlecase too.<p>
  2783. *
  2784. * <p><b>Note:</b> This method cannot handle <a
  2785. * href="#supplementary"> supplementary characters</a>. To support
  2786. * all Unicode characters, including supplementary characters, use
  2787. * the {@link #isTitleCase(int)} method.
  2788. *
  2789. * @param ch the character to be tested.
  2790. * @return <code>true</code> if the character is titlecase;
  2791. * <code>false</code> otherwise.
  2792. * @see java.lang.Character#isLowerCase(char)
  2793. * @see java.lang.Character#isUpperCase(char)
  2794. * @see java.lang.Character#toTitleCase(char)
  2795. * @see java.lang.Character#getType(char)
  2796. * @since 1.0.2
  2797. */
  2798. public static boolean isTitleCase(char ch) {
  2799. return isTitleCase((int)ch);
  2800. }
  2801. /**
  2802. * Determines if the specified character (Unicode code point) is a titlecase character.
  2803. * <p>
  2804. * A character is a titlecase character if its general
  2805. * category type, provided by {@link Character#getType(int) getType(codePoint)},
  2806. * is <code>TITLECASE_LETTER</code>.
  2807. * <p>
  2808. * Some characters look like pairs of Latin letters. For example, there
  2809. * is an uppercase letter that looks like "LJ" and has a corresponding
  2810. * lowercase letter that looks like "lj". A third form, which looks like "Lj",
  2811. * is the appropriate form to use when rendering a word in lowercase
  2812. * with initial capitals, as for a book title.
  2813. * <p>
  2814. * These are some of the Unicode characters for which this method returns
  2815. * <code>true</code>:
  2816. * <ul>
  2817. * <li><code>LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON</code>
  2818. * <li><code>LATIN CAPITAL LETTER L WITH SMALL LETTER J</code>
  2819. * <li><code>LATIN CAPITAL LETTER N WITH SMALL LETTER J</code>
  2820. * <li><code>LATIN CAPITAL LETTER D WITH SMALL LETTER Z</code>
  2821. * </ul>
  2822. * <p> Many other Unicode characters are titlecase too.<p>
  2823. *
  2824. * @param codePoint the character (Unicode code point) to be tested.
  2825. * @return <code>true</code> if the character is titlecase;
  2826. * <code>false</code> otherwise.
  2827. * @see java.lang.Character#isLowerCase(int)
  2828. * @see java.lang.Character#isUpperCase(int)
  2829. * @see java.lang.Character#toTitleCase(int)
  2830. * @see java.lang.Character#getType(int)
  2831. * @since 1.5
  2832. */
  2833. public static boolean isTitleCase(int codePoint) {
  2834. boolean bTitleCase = false;
  2835. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  2836. bTitleCase = CharacterDataLatin1.isTitleCase(codePoint);
  2837. } else {
  2838. int plane = getPlane(codePoint);
  2839. switch(plane) {
  2840. case(0):
  2841. bTitleCase = CharacterData00.isTitleCase(codePoint);
  2842. break;
  2843. case(1):
  2844. bTitleCase = CharacterData01.isTitleCase(codePoint);
  2845. break;
  2846. case(2):
  2847. bTitleCase = CharacterData02.isTitleCase(codePoint);
  2848. break;
  2849. case(3): // Undefined
  2850. case(4): // Undefined
  2851. case(5): // Undefined
  2852. case(6): // Undefined
  2853. case(7): // Undefined
  2854. case(8): // Undefined
  2855. case(9): // Undefined
  2856. case(10): // Undefined
  2857. case(11): // Undefined
  2858. case(12): // Undefined
  2859. case(13): // Undefined
  2860. bTitleCase = CharacterDataUndefined.isTitleCase(codePoint);
  2861. break;
  2862. case(14):
  2863. bTitleCase = CharacterData0E.isTitleCase(codePoint);
  2864. break;
  2865. case(15): // Private Use
  2866. case(16): // Private Use
  2867. bTitleCase = CharacterDataPrivateUse.isTitleCase(codePoint);
  2868. break;
  2869. default:
  2870. // the argument's plane is invalid, and thus is an invalid codepoint
  2871. // bTitleCase remains false;
  2872. break;
  2873. }
  2874. }
  2875. return bTitleCase;
  2876. }
  2877. /**
  2878. * Determines if the specified character is a digit.
  2879. * <p>
  2880. * A character is a digit if its general category type, provided
  2881. * by <code>Character.getType(ch)</code>, is
  2882. * <code>DECIMAL_DIGIT_NUMBER</code>.
  2883. * <p>
  2884. * Some Unicode character ranges that contain digits:
  2885. * <ul>
  2886. * <li><code>'\u0030'</code> through <code>'\u0039'</code>,
  2887. * ISO-LATIN-1 digits (<code>'0'</code> through <code>'9'</code>)
  2888. * <li><code>'\u0660'</code> through <code>'\u0669'</code>,
  2889. * Arabic-Indic digits
  2890. * <li><code>'\u06F0'</code> through <code>'\u06F9'</code>,
  2891. * Extended Arabic-Indic digits
  2892. * <li><code>'\u0966'</code> through <code>'\u096F'</code>,
  2893. * Devanagari digits
  2894. * <li><code>'\uFF10'</code> through <code>'\uFF19'</code>,
  2895. * Fullwidth digits
  2896. * </ul>
  2897. *
  2898. * Many other character ranges contain digits as well.
  2899. *
  2900. * <p><b>Note:</b> This method cannot handle <a
  2901. * href="#supplementary"> supplementary characters</a>. To support
  2902. * all Unicode characters, including supplementary characters, use
  2903. * the {@link #isDigit(int)} method.
  2904. *
  2905. * @param ch the character to be tested.
  2906. * @return <code>true</code> if the character is a digit;
  2907. * <code>false</code> otherwise.
  2908. * @see java.lang.Character#digit(char, int)
  2909. * @see java.lang.Character#forDigit(int, int)
  2910. * @see java.lang.Character#getType(char)
  2911. */
  2912. public static boolean isDigit(char ch) {
  2913. return isDigit((int)ch);
  2914. }
  2915. /**
  2916. * Determines if the specified character (Unicode code point) is a digit.
  2917. * <p>
  2918. * A character is a digit if its general category type, provided
  2919. * by {@link Character#getType(int) getType(codePoint)}, is
  2920. * <code>DECIMAL_DIGIT_NUMBER</code>.
  2921. * <p>
  2922. * Some Unicode character ranges that contain digits:
  2923. * <ul>
  2924. * <li><code>'\u0030'</code> through <code>'\u0039'</code>,
  2925. * ISO-LATIN-1 digits (<code>'0'</code> through <code>'9'</code>)
  2926. * <li><code>'\u0660'</code> through <code>'\u0669'</code>,
  2927. * Arabic-Indic digits
  2928. * <li><code>'\u06F0'</code> through <code>'\u06F9'</code>,
  2929. * Extended Arabic-Indic digits
  2930. * <li><code>'\u0966'</code> through <code>'\u096F'</code>,
  2931. * Devanagari digits
  2932. * <li><code>'\uFF10'</code> through <code>'\uFF19'</code>,
  2933. * Fullwidth digits
  2934. * </ul>
  2935. *
  2936. * Many other character ranges contain digits as well.
  2937. *
  2938. * @param codePoint the character (Unicode code point) to be tested.
  2939. * @return <code>true</code> if the character is a digit;
  2940. * <code>false</code> otherwise.
  2941. * @see java.lang.Character#forDigit(int, int)
  2942. * @see java.lang.Character#getType(int)
  2943. * @since 1.5
  2944. */
  2945. public static boolean isDigit(int codePoint) {
  2946. boolean bDigit = false;
  2947. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  2948. bDigit = CharacterDataLatin1.isDigit(codePoint);
  2949. } else {
  2950. int plane = getPlane(codePoint);
  2951. switch(plane) {
  2952. case(0):
  2953. bDigit = CharacterData00.isDigit(codePoint);
  2954. break;
  2955. case(1):
  2956. bDigit = CharacterData01.isDigit(codePoint);
  2957. break;
  2958. case(2):
  2959. bDigit = CharacterData02.isDigit(codePoint);
  2960. break;
  2961. case(3): // Undefined
  2962. case(4): // Undefined
  2963. case(5): // Undefined
  2964. case(6): // Undefined
  2965. case(7): // Undefined
  2966. case(8): // Undefined
  2967. case(9): // Undefined
  2968. case(10): // Undefined
  2969. case(11): // Undefined
  2970. case(12): // Undefined
  2971. case(13): // Undefined
  2972. bDigit = CharacterDataUndefined.isDigit(codePoint);
  2973. break;
  2974. case(14):
  2975. bDigit = CharacterData0E.isDigit(codePoint);
  2976. break;
  2977. case(15): // Private Use
  2978. case(16): // Private Use
  2979. bDigit = CharacterDataPrivateUse.isDigit(codePoint);
  2980. break;
  2981. default:
  2982. // the argument's plane is invalid, and thus is an invalid codepoint
  2983. // bDigit remains false;
  2984. break;
  2985. }
  2986. }
  2987. return bDigit;
  2988. }
  2989. /**
  2990. * Determines if a character is defined in Unicode.
  2991. * <p>
  2992. * A character is defined if at least one of the following is true:
  2993. * <ul>
  2994. * <li>It has an entry in the UnicodeData file.
  2995. * <li>It has a value in a range defined by the UnicodeData file.
  2996. * </ul>
  2997. *
  2998. * <p><b>Note:</b> This method cannot handle <a
  2999. * href="#supplementary"> supplementary characters</a>. To support
  3000. * all Unicode characters, including supplementary characters, use
  3001. * the {@link #isDefined(int)} method.
  3002. *
  3003. * @param ch the character to be tested
  3004. * @return <code>true</code> if the character has a defined meaning
  3005. * in Unicode; <code>false</code> otherwise.
  3006. * @see java.lang.Character#isDigit(char)
  3007. * @see java.lang.Character#isLetter(char)
  3008. * @see java.lang.Character#isLetterOrDigit(char)
  3009. * @see java.lang.Character#isLowerCase(char)
  3010. * @see java.lang.Character#isTitleCase(char)
  3011. * @see java.lang.Character#isUpperCase(char)
  3012. * @since 1.0.2
  3013. */
  3014. public static boolean isDefined(char ch) {
  3015. return isDefined((int)ch);
  3016. }
  3017. /**
  3018. * Determines if a character (Unicode code point) is defined in Unicode.
  3019. * <p>
  3020. * A character is defined if at least one of the following is true:
  3021. * <ul>
  3022. * <li>It has an entry in the UnicodeData file.
  3023. * <li>It has a value in a range defined by the UnicodeData file.
  3024. * </ul>
  3025. *
  3026. * @param codePoint the character (Unicode code point) to be tested.
  3027. * @return <code>true</code> if the character has a defined meaning
  3028. * in Unicode; <code>false</code> otherwise.
  3029. * @see java.lang.Character#isDigit(int)
  3030. * @see java.lang.Character#isLetter(int)
  3031. * @see java.lang.Character#isLetterOrDigit(int)
  3032. * @see java.lang.Character#isLowerCase(int)
  3033. * @see java.lang.Character#isTitleCase(int)
  3034. * @see java.lang.Character#isUpperCase(int)
  3035. * @since 1.5
  3036. */
  3037. public static boolean isDefined(int codePoint) {
  3038. boolean bDefined = false;
  3039. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  3040. bDefined = CharacterDataLatin1.isDefined(codePoint);
  3041. } else {
  3042. int plane = getPlane(codePoint);
  3043. switch(plane) {
  3044. case(0):
  3045. bDefined = CharacterData00.isDefined(codePoint);
  3046. break;
  3047. case(1):
  3048. bDefined = CharacterData01.isDefined(codePoint);
  3049. break;
  3050. case(2):
  3051. bDefined = CharacterData02.isDefined(codePoint);
  3052. break;
  3053. case(3): // Undefined
  3054. case(4): // Undefined
  3055. case(5): // Undefined
  3056. case(6): // Undefined
  3057. case(7): // Undefined
  3058. case(8): // Undefined
  3059. case(9): // Undefined
  3060. case(10): // Undefined
  3061. case(11): // Undefined
  3062. case(12): // Undefined
  3063. case(13): // Undefined
  3064. bDefined = CharacterDataUndefined.isDefined(codePoint);
  3065. break;
  3066. case(14):
  3067. bDefined = CharacterData0E.isDefined(codePoint);
  3068. break;
  3069. case(15): // Private Use
  3070. case(16): // Private Use
  3071. bDefined = CharacterDataPrivateUse.isDefined(codePoint);
  3072. break;
  3073. default:
  3074. // the argument's plane is invalid, and thus is an invalid codepoint
  3075. // bDefined remains false;
  3076. break;
  3077. }
  3078. }
  3079. return bDefined;
  3080. }
  3081. /**
  3082. * Determines if the specified character is a letter.
  3083. * <p>
  3084. * A character is considered to be a letter if its general
  3085. * category type, provided by <code>Character.getType(ch)</code>,
  3086. * is any of the following:
  3087. * <ul>
  3088. * <li> <code>UPPERCASE_LETTER</code>
  3089. * <li> <code>LOWERCASE_LETTER</code>
  3090. * <li> <code>TITLECASE_LETTER</code>
  3091. * <li> <code>MODIFIER_LETTER</code>
  3092. * <li> <code>OTHER_LETTER</code>
  3093. * </ul>
  3094. *
  3095. * Not all letters have case. Many characters are
  3096. * letters but are neither uppercase nor lowercase nor titlecase.
  3097. *
  3098. * <p><b>Note:</b> This method cannot handle <a
  3099. * href="#supplementary"> supplementary characters</a>. To support
  3100. * all Unicode characters, including supplementary characters, use
  3101. * the {@link #isLetter(int)} method.
  3102. *
  3103. * @param ch the character to be tested.
  3104. * @return <code>true</code> if the character is a letter;
  3105. * <code>false</code> otherwise.
  3106. * @see java.lang.Character#isDigit(char)
  3107. * @see java.lang.Character#isJavaIdentifierStart(char)
  3108. * @see java.lang.Character#isJavaLetter(char)
  3109. * @see java.lang.Character#isJavaLetterOrDigit(char)
  3110. * @see java.lang.Character#isLetterOrDigit(char)
  3111. * @see java.lang.Character#isLowerCase(char)
  3112. * @see java.lang.Character#isTitleCase(char)
  3113. * @see java.lang.Character#isUnicodeIdentifierStart(char)
  3114. * @see java.lang.Character#isUpperCase(char)
  3115. */
  3116. public static boolean isLetter(char ch) {
  3117. return isLetter((int)ch);
  3118. }
  3119. /**
  3120. * Determines if the specified character (Unicode code point) is a letter.
  3121. * <p>
  3122. * A character is considered to be a letter if its general
  3123. * category type, provided by {@link Character#getType(int) getType(codePoint)},
  3124. * is any of the following:
  3125. * <ul>
  3126. * <li> <code>UPPERCASE_LETTER</code>
  3127. * <li> <code>LOWERCASE_LETTER</code>
  3128. * <li> <code>TITLECASE_LETTER</code>
  3129. * <li> <code>MODIFIER_LETTER</code>
  3130. * <li> <code>OTHER_LETTER</code>
  3131. * </ul>
  3132. *
  3133. * Not all letters have case. Many characters are
  3134. * letters but are neither uppercase nor lowercase nor titlecase.
  3135. *
  3136. * @param codePoint the character (Unicode code point) to be tested.
  3137. * @return <code>true</code> if the character is a letter;
  3138. * <code>false</code> otherwise.
  3139. * @see java.lang.Character#isDigit(int)
  3140. * @see java.lang.Character#isJavaIdentifierStart(int)
  3141. * @see java.lang.Character#isLetterOrDigit(int)
  3142. * @see java.lang.Character#isLowerCase(int)
  3143. * @see java.lang.Character#isTitleCase(int)
  3144. * @see java.lang.Character#isUnicodeIdentifierStart(int)
  3145. * @see java.lang.Character#isUpperCase(int)
  3146. * @since 1.5
  3147. */
  3148. public static boolean isLetter(int codePoint) {
  3149. boolean bLetter = false;
  3150. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  3151. bLetter = CharacterDataLatin1.isLetter(codePoint);
  3152. } else {
  3153. int plane = getPlane(codePoint);
  3154. switch(plane) {
  3155. case(0):
  3156. bLetter = CharacterData00.isLetter(codePoint);
  3157. break;
  3158. case(1):
  3159. bLetter = CharacterData01.isLetter(codePoint);
  3160. break;
  3161. case(2):
  3162. bLetter = CharacterData02.isLetter(codePoint);
  3163. break;
  3164. case(3): // Undefined
  3165. case(4): // Undefined
  3166. case(5): // Undefined
  3167. case(6): // Undefined
  3168. case(7): // Undefined
  3169. case(8): // Undefined
  3170. case(9): // Undefined
  3171. case(10): // Undefined
  3172. case(11): // Undefined
  3173. case(12): // Undefined
  3174. case(13): // Undefined
  3175. bLetter = CharacterDataUndefined.isLetter(codePoint);
  3176. break;
  3177. case(14):
  3178. bLetter = CharacterData0E.isLetter(codePoint);
  3179. break;
  3180. case(15): // Private Use
  3181. case(16): // Private Use
  3182. bLetter = CharacterDataPrivateUse.isLetter(codePoint);
  3183. break;
  3184. default:
  3185. // the argument's plane is invalid, and thus is an invalid codepoint
  3186. // bLetter remains false;
  3187. break;
  3188. }
  3189. }
  3190. return bLetter;
  3191. }
  3192. /**
  3193. * Determines if the specified character is a letter or digit.
  3194. * <p>
  3195. * A character is considered to be a letter or digit if either
  3196. * <code>Character.isLetter(char ch)</code> or
  3197. * <code>Character.isDigit(char ch)</code> returns
  3198. * <code>true</code> for the character.
  3199. *
  3200. * <p><b>Note:</b> This method cannot handle <a
  3201. * href="#supplementary"> supplementary characters</a>. To support
  3202. * all Unicode characters, including supplementary characters, use
  3203. * the {@link #isLetterOrDigit(int)} method.
  3204. *
  3205. * @param ch the character to be tested.
  3206. * @return <code>true</code> if the character is a letter or digit;
  3207. * <code>false</code> otherwise.
  3208. * @see java.lang.Character#isDigit(char)
  3209. * @see java.lang.Character#isJavaIdentifierPart(char)
  3210. * @see java.lang.Character#isJavaLetter(char)
  3211. * @see java.lang.Character#isJavaLetterOrDigit(char)
  3212. * @see java.lang.Character#isLetter(char)
  3213. * @see java.lang.Character#isUnicodeIdentifierPart(char)
  3214. * @since 1.0.2
  3215. */
  3216. public static boolean isLetterOrDigit(char ch) {
  3217. return isLetterOrDigit((int)ch);
  3218. }
  3219. /**
  3220. * Determines if the specified character (Unicode code point) is a letter or digit.
  3221. * <p>
  3222. * A character is considered to be a letter or digit if either
  3223. * {@link #isLetter(int) isLetter(codePoint)} or
  3224. * {@link #isDigit(int) isDigit(codePoint)} returns
  3225. * <code>true</code> for the character.
  3226. *
  3227. * @param codePoint the character (Unicode code point) to be tested.
  3228. * @return <code>true</code> if the character is a letter or digit;
  3229. * <code>false</code> otherwise.
  3230. * @see java.lang.Character#isDigit(int)
  3231. * @see java.lang.Character#isJavaIdentifierPart(int)
  3232. * @see java.lang.Character#isLetter(int)
  3233. * @see java.lang.Character#isUnicodeIdentifierPart(int)
  3234. * @since 1.5
  3235. */
  3236. public static boolean isLetterOrDigit(int codePoint) {
  3237. boolean bLetterOrDigit = false;
  3238. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  3239. bLetterOrDigit = CharacterDataLatin1.isLetterOrDigit(codePoint);
  3240. } else {
  3241. int plane = getPlane(codePoint);
  3242. switch(plane) {
  3243. case(0):
  3244. bLetterOrDigit = CharacterData00.isLetterOrDigit(codePoint);
  3245. break;
  3246. case(1):
  3247. bLetterOrDigit = CharacterData01.isLetterOrDigit(codePoint);
  3248. break;
  3249. case(2):
  3250. bLetterOrDigit = CharacterData02.isLetterOrDigit(codePoint);
  3251. break;
  3252. case(3): // Undefined
  3253. case(4): // Undefined
  3254. case(5): // Undefined
  3255. case(6): // Undefined
  3256. case(7): // Undefined
  3257. case(8): // Undefined
  3258. case(9): // Undefined
  3259. case(10): // Undefined
  3260. case(11): // Undefined
  3261. case(12): // Undefined
  3262. case(13): // Undefined
  3263. bLetterOrDigit = CharacterDataUndefined.isLetterOrDigit(codePoint);
  3264. break;
  3265. case(14): // Undefined
  3266. bLetterOrDigit = CharacterData0E.isLetterOrDigit(codePoint);
  3267. break;
  3268. case(15): // Private Use
  3269. case(16): // Private Use
  3270. bLetterOrDigit = CharacterDataPrivateUse.isLetterOrDigit(codePoint);
  3271. break;
  3272. default:
  3273. // the argument's plane is invalid, and thus is an invalid codepoint
  3274. // bLetterOrDigit remains false;
  3275. break;
  3276. }
  3277. }
  3278. return bLetterOrDigit;
  3279. }
  3280. /**
  3281. * Determines if the specified character is permissible as the first
  3282. * character in a Java identifier.
  3283. * <p>
  3284. * A character may start a Java identifier if and only if
  3285. * one of the following is true:
  3286. * <ul>
  3287. * <li> {@link #isLetter(char) isLetter(ch)} returns <code>true</code>
  3288. * <li> {@link #getType(char) getType(ch)} returns <code>LETTER_NUMBER</code>
  3289. * <li> ch is a currency symbol (such as "$")
  3290. * <li> ch is a connecting punctuation character (such as "_").
  3291. * </ul>
  3292. *
  3293. * @param ch the character to be tested.
  3294. * @return <code>true</code> if the character may start a Java
  3295. * identifier; <code>false</code> otherwise.
  3296. * @see java.lang.Character#isJavaLetterOrDigit(char)
  3297. * @see java.lang.Character#isJavaIdentifierStart(char)
  3298. * @see java.lang.Character#isJavaIdentifierPart(char)
  3299. * @see java.lang.Character#isLetter(char)
  3300. * @see java.lang.Character#isLetterOrDigit(char)
  3301. * @see java.lang.Character#isUnicodeIdentifierStart(char)
  3302. * @since 1.02
  3303. * @deprecated Replaced by isJavaIdentifierStart(char).
  3304. */
  3305. @Deprecated
  3306. public static boolean isJavaLetter(char ch) {
  3307. return isJavaIdentifierStart(ch);
  3308. }
  3309. /**
  3310. * Determines if the specified character may be part of a Java
  3311. * identifier as other than the first character.
  3312. * <p>
  3313. * A character may be part of a Java identifier if and only if any
  3314. * of the following are true:
  3315. * <ul>
  3316. * <li> it is a letter
  3317. * <li> it is a currency symbol (such as <code>'$'</code>)
  3318. * <li> it is a connecting punctuation character (such as <code>'_'</code>)
  3319. * <li> it is a digit
  3320. * <li> it is a numeric letter (such as a Roman numeral character)
  3321. * <li> it is a combining mark
  3322. * <li> it is a non-spacing mark
  3323. * <li> <code>isIdentifierIgnorable</code> returns
  3324. * <code>true</code> for the character.
  3325. * </ul>
  3326. *
  3327. * @param ch the character to be tested.
  3328. * @return <code>true</code> if the character may be part of a
  3329. * Java identifier; <code>false</code> otherwise.
  3330. * @see java.lang.Character#isJavaLetter(char)
  3331. * @see java.lang.Character#isJavaIdentifierStart(char)
  3332. * @see java.lang.Character#isJavaIdentifierPart(char)
  3333. * @see java.lang.Character#isLetter(char)
  3334. * @see java.lang.Character#isLetterOrDigit(char)
  3335. * @see java.lang.Character#isUnicodeIdentifierPart(char)
  3336. * @see java.lang.Character#isIdentifierIgnorable(char)
  3337. * @since 1.02
  3338. * @deprecated Replaced by isJavaIdentifierPart(char).
  3339. */
  3340. @Deprecated
  3341. public static boolean isJavaLetterOrDigit(char ch) {
  3342. return isJavaIdentifierPart(ch);
  3343. }
  3344. /**
  3345. * Determines if the specified character is
  3346. * permissible as the first character in a Java identifier.
  3347. * <p>
  3348. * A character may start a Java identifier if and only if
  3349. * one of the following conditions is true:
  3350. * <ul>
  3351. * <li> {@link #isLetter(char) isLetter(ch)} returns <code>true</code>
  3352. * <li> {@link #getType(char) getType(ch)} returns <code>LETTER_NUMBER</code>
  3353. * <li> ch is a currency symbol (such as "$")
  3354. * <li> ch is a connecting punctuation character (such as "_").
  3355. * </ul>
  3356. *
  3357. * <p><b>Note:</b> This method cannot handle <a
  3358. * href="#supplementary"> supplementary characters</a>. To support
  3359. * all Unicode characters, including supplementary characters, use
  3360. * the {@link #isJavaIdentifierStart(int)} method.
  3361. *
  3362. * @param ch the character to be tested.
  3363. * @return <code>true</code> if the character may start a Java identifier;
  3364. * <code>false</code> otherwise.
  3365. * @see java.lang.Character#isJavaIdentifierPart(char)
  3366. * @see java.lang.Character#isLetter(char)
  3367. * @see java.lang.Character#isUnicodeIdentifierStart(char)
  3368. * @since 1.1
  3369. */
  3370. public static boolean isJavaIdentifierStart(char ch) {
  3371. return isJavaIdentifierStart((int)ch);
  3372. }
  3373. /**
  3374. * Determines if the character (Unicode code point) is
  3375. * permissible as the first character in a Java identifier.
  3376. * <p>
  3377. * A character may start a Java identifier if and only if
  3378. * one of the following conditions is true:
  3379. * <ul>
  3380. * <li> {@link #isLetter(int) isLetter(codePoint)}
  3381. * returns <code>true</code>
  3382. * <li> {@link #getType(int) getType(codePoint)}
  3383. * returns <code>LETTER_NUMBER</code>
  3384. * <li> the referenced character is a currency symbol (such as "$")
  3385. * <li> the referenced character is a connecting punctuation character
  3386. * (such as "_").
  3387. * </ul>
  3388. *
  3389. * @param codePoint the character (Unicode code point) to be tested.
  3390. * @return <code>true</code> if the character may start a Java identifier;
  3391. * <code>false</code> otherwise.
  3392. * @see java.lang.Character#isJavaIdentifierPart(int)
  3393. * @see java.lang.Character#isLetter(int)
  3394. * @see java.lang.Character#isUnicodeIdentifierStart(int)
  3395. * @since 1.5
  3396. */
  3397. public static boolean isJavaIdentifierStart(int codePoint) {
  3398. boolean bJavaStart = false;
  3399. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  3400. bJavaStart = CharacterDataLatin1.isJavaIdentifierStart(codePoint);
  3401. } else {
  3402. int plane = getPlane(codePoint);
  3403. switch(plane) {
  3404. case(0):
  3405. bJavaStart = CharacterData00.isJavaIdentifierStart(codePoint);
  3406. break;
  3407. case(1):
  3408. bJavaStart = CharacterData01.isJavaIdentifierStart(codePoint);
  3409. break;
  3410. case(2):
  3411. bJavaStart = CharacterData02.isJavaIdentifierStart(codePoint);
  3412. break;
  3413. case(3): // Undefined
  3414. case(4): // Undefined
  3415. case(5): // Undefined
  3416. case(6): // Undefined
  3417. case(7): // Undefined
  3418. case(8): // Undefined
  3419. case(9): // Undefined
  3420. case(10): // Undefined
  3421. case(11): // Undefined
  3422. case(12): // Undefined
  3423. case(13): // Undefined
  3424. bJavaStart = CharacterDataUndefined.isJavaIdentifierStart(codePoint);
  3425. break;
  3426. case(14):
  3427. bJavaStart = CharacterData0E.isJavaIdentifierStart(codePoint);
  3428. break;
  3429. case(15): // Private Use
  3430. case(16): // Private Use
  3431. bJavaStart = CharacterDataPrivateUse.isJavaIdentifierStart(codePoint);
  3432. break;
  3433. default:
  3434. // the argument's plane is invalid, and thus is an invalid codepoint
  3435. // bJavaStart remains false;
  3436. break;
  3437. }
  3438. }
  3439. return bJavaStart;
  3440. }
  3441. /**
  3442. * Determines if the specified character may be part of a Java
  3443. * identifier as other than the first character.
  3444. * <p>
  3445. * A character may be part of a Java identifier if any of the following
  3446. * are true:
  3447. * <ul>
  3448. * <li> it is a letter
  3449. * <li> it is a currency symbol (such as <code>'$'</code>)
  3450. * <li> it is a connecting punctuation character (such as <code>'_'</code>)
  3451. * <li> it is a digit
  3452. * <li> it is a numeric letter (such as a Roman numeral character)
  3453. * <li> it is a combining mark
  3454. * <li> it is a non-spacing mark
  3455. * <li> <code>isIdentifierIgnorable</code> returns
  3456. * <code>true</code> for the character
  3457. * </ul>
  3458. *
  3459. * <p><b>Note:</b> This method cannot handle <a
  3460. * href="#supplementary"> supplementary characters</a>. To support
  3461. * all Unicode characters, including supplementary characters, use
  3462. * the {@link #isJavaIdentifierPart(int)} method.
  3463. *
  3464. * @param ch the character to be tested.
  3465. * @return <code>true</code> if the character may be part of a
  3466. * Java identifier; <code>false</code> otherwise.
  3467. * @see java.lang.Character#isIdentifierIgnorable(char)
  3468. * @see java.lang.Character#isJavaIdentifierStart(char)
  3469. * @see java.lang.Character#isLetterOrDigit(char)
  3470. * @see java.lang.Character#isUnicodeIdentifierPart(char)
  3471. * @since 1.1
  3472. */
  3473. public static boolean isJavaIdentifierPart(char ch) {
  3474. return isJavaIdentifierPart((int)ch);
  3475. }
  3476. /**
  3477. * Determines if the character (Unicode code point) may be part of a Java
  3478. * identifier as other than the first character.
  3479. * <p>
  3480. * A character may be part of a Java identifier if any of the following
  3481. * are true:
  3482. * <ul>
  3483. * <li> it is a letter
  3484. * <li> it is a currency symbol (such as <code>'$'</code>)
  3485. * <li> it is a connecting punctuation character (such as <code>'_'</code>)
  3486. * <li> it is a digit
  3487. * <li> it is a numeric letter (such as a Roman numeral character)
  3488. * <li> it is a combining mark
  3489. * <li> it is a non-spacing mark
  3490. * <li> {@link #isIdentifierIgnorable(int)
  3491. * isIdentifierIgnorable(codePoint)} returns <code>true</code> for
  3492. * the character
  3493. * </ul>
  3494. *
  3495. * @param codePoint the character (Unicode code point) to be tested.
  3496. * @return <code>true</code> if the character may be part of a
  3497. * Java identifier; <code>false</code> otherwise.
  3498. * @see java.lang.Character#isIdentifierIgnorable(int)
  3499. * @see java.lang.Character#isJavaIdentifierStart(int)
  3500. * @see java.lang.Character#isLetterOrDigit(int)
  3501. * @see java.lang.Character#isUnicodeIdentifierPart(int)
  3502. * @since 1.5
  3503. */
  3504. public static boolean isJavaIdentifierPart(int codePoint) {
  3505. boolean bJavaPart = false;
  3506. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  3507. bJavaPart = CharacterDataLatin1.isJavaIdentifierPart(codePoint);
  3508. } else {
  3509. int plane = getPlane(codePoint);
  3510. switch(plane) {
  3511. case(0):
  3512. bJavaPart = CharacterData00.isJavaIdentifierPart(codePoint);
  3513. break;
  3514. case(1):
  3515. bJavaPart = CharacterData01.isJavaIdentifierPart(codePoint);
  3516. break;
  3517. case(2):
  3518. bJavaPart = CharacterData02.isJavaIdentifierPart(codePoint);
  3519. break;
  3520. case(3): // Undefined
  3521. case(4): // Undefined
  3522. case(5): // Undefined
  3523. case(6): // Undefined
  3524. case(7): // Undefined
  3525. case(8): // Undefined
  3526. case(9): // Undefined
  3527. case(10): // Undefined
  3528. case(11): // Undefined
  3529. case(12): // Undefined
  3530. case(13): // Undefined
  3531. bJavaPart = CharacterDataUndefined.isJavaIdentifierPart(codePoint);
  3532. break;
  3533. case(14):
  3534. bJavaPart = CharacterData0E.isJavaIdentifierPart(codePoint);
  3535. break;
  3536. case(15): // Private Use
  3537. case(16): // Private Use
  3538. bJavaPart = CharacterDataPrivateUse.isJavaIdentifierPart(codePoint);
  3539. break;
  3540. default:
  3541. // the argument's plane is invalid, and thus is an invalid codepoint
  3542. // bJavaPart remains false;
  3543. break;
  3544. }
  3545. }
  3546. return bJavaPart;
  3547. }
  3548. /**
  3549. * Determines if the specified character is permissible as the
  3550. * first character in a Unicode identifier.
  3551. * <p>
  3552. * A character may start a Unicode identifier if and only if
  3553. * one of the following conditions is true:
  3554. * <ul>
  3555. * <li> {@link #isLetter(char) isLetter(ch)} returns <code>true</code>
  3556. * <li> {@link #getType(char) getType(ch)} returns
  3557. * <code>LETTER_NUMBER</code>.
  3558. * </ul>
  3559. *
  3560. * <p><b>Note:</b> This method cannot handle <a
  3561. * href="#supplementary"> supplementary characters</a>. To support
  3562. * all Unicode characters, including supplementary characters, use
  3563. * the {@link #isUnicodeIdentifierStart(int)} method.
  3564. *
  3565. * @param ch the character to be tested.
  3566. * @return <code>true</code> if the character may start a Unicode
  3567. * identifier; <code>false</code> otherwise.
  3568. * @see java.lang.Character#isJavaIdentifierStart(char)
  3569. * @see java.lang.Character#isLetter(char)
  3570. * @see java.lang.Character#isUnicodeIdentifierPart(char)
  3571. * @since 1.1
  3572. */
  3573. public static boolean isUnicodeIdentifierStart(char ch) {
  3574. return isUnicodeIdentifierStart((int)ch);
  3575. }
  3576. /**
  3577. * Determines if the specified character (Unicode code point) is permissible as the
  3578. * first character in a Unicode identifier.
  3579. * <p>
  3580. * A character may start a Unicode identifier if and only if
  3581. * one of the following conditions is true:
  3582. * <ul>
  3583. * <li> {@link #isLetter(int) isLetter(codePoint)}
  3584. * returns <code>true</code>
  3585. * <li> {@link #getType(int) getType(codePoint)}
  3586. * returns <code>LETTER_NUMBER</code>.
  3587. * </ul>
  3588. * @param codePoint the character (Unicode code point) to be tested.
  3589. * @return <code>true</code> if the character may start a Unicode
  3590. * identifier; <code>false</code> otherwise.
  3591. * @see java.lang.Character#isJavaIdentifierStart(int)
  3592. * @see java.lang.Character#isLetter(int)
  3593. * @see java.lang.Character#isUnicodeIdentifierPart(int)
  3594. * @since 1.5
  3595. */
  3596. public static boolean isUnicodeIdentifierStart(int codePoint) {
  3597. boolean bUnicodeStart = false;
  3598. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  3599. bUnicodeStart = CharacterDataLatin1.isUnicodeIdentifierStart(codePoint);
  3600. } else {
  3601. int plane = getPlane(codePoint);
  3602. switch(plane) {
  3603. case(0):
  3604. bUnicodeStart = CharacterData00.isUnicodeIdentifierStart(codePoint);
  3605. break;
  3606. case(1):
  3607. bUnicodeStart = CharacterData01.isUnicodeIdentifierStart(codePoint);
  3608. break;
  3609. case(2):
  3610. bUnicodeStart = CharacterData02.isUnicodeIdentifierStart(codePoint);
  3611. break;
  3612. case(3): // Undefined
  3613. case(4): // Undefined
  3614. case(5): // Undefined
  3615. case(6): // Undefined
  3616. case(7): // Undefined
  3617. case(8): // Undefined
  3618. case(9): // Undefined
  3619. case(10): // Undefined
  3620. case(11): // Undefined
  3621. case(12): // Undefined
  3622. case(13): // Undefined
  3623. bUnicodeStart = CharacterDataUndefined.isUnicodeIdentifierStart(codePoint);
  3624. break;
  3625. case(14):
  3626. bUnicodeStart = CharacterData0E.isUnicodeIdentifierStart(codePoint);
  3627. break;
  3628. case(15): // Private Use
  3629. case(16): // Private Use
  3630. bUnicodeStart = CharacterDataPrivateUse.isUnicodeIdentifierStart(codePoint);
  3631. break;
  3632. default:
  3633. // the argument's plane is invalid, and thus is an invalid codepoint
  3634. // bUnicodeStart remains false;
  3635. break;
  3636. }
  3637. }
  3638. return bUnicodeStart;
  3639. }
  3640. /**
  3641. * Determines if the specified character may be part of a Unicode
  3642. * identifier as other than the first character.
  3643. * <p>
  3644. * A character may be part of a Unicode identifier if and only if
  3645. * one of the following statements is true:
  3646. * <ul>
  3647. * <li> it is a letter
  3648. * <li> it is a connecting punctuation character (such as <code>'_'</code>)
  3649. * <li> it is a digit
  3650. * <li> it is a numeric letter (such as a Roman numeral character)
  3651. * <li> it is a combining mark
  3652. * <li> it is a non-spacing mark
  3653. * <li> <code>isIdentifierIgnorable</code> returns
  3654. * <code>true</code> for this character.
  3655. * </ul>
  3656. *
  3657. * <p><b>Note:</b> This method cannot handle <a
  3658. * href="#supplementary"> supplementary characters</a>. To support
  3659. * all Unicode characters, including supplementary characters, use
  3660. * the {@link #isUnicodeIdentifierPart(int)} method.
  3661. *
  3662. * @param ch the character to be tested.
  3663. * @return <code>true</code> if the character may be part of a
  3664. * Unicode identifier; <code>false</code> otherwise.
  3665. * @see java.lang.Character#isIdentifierIgnorable(char)
  3666. * @see java.lang.Character#isJavaIdentifierPart(char)
  3667. * @see java.lang.Character#isLetterOrDigit(char)
  3668. * @see java.lang.Character#isUnicodeIdentifierStart(char)
  3669. * @since 1.1
  3670. */
  3671. public static boolean isUnicodeIdentifierPart(char ch) {
  3672. return isUnicodeIdentifierPart((int)ch);
  3673. }
  3674. /**
  3675. * Determines if the specified character (Unicode code point) may be part of a Unicode
  3676. * identifier as other than the first character.
  3677. * <p>
  3678. * A character may be part of a Unicode identifier if and only if
  3679. * one of the following statements is true:
  3680. * <ul>
  3681. * <li> it is a letter
  3682. * <li> it is a connecting punctuation character (such as <code>'_'</code>)
  3683. * <li> it is a digit
  3684. * <li> it is a numeric letter (such as a Roman numeral character)
  3685. * <li> it is a combining mark
  3686. * <li> it is a non-spacing mark
  3687. * <li> <code>isIdentifierIgnorable</code> returns
  3688. * <code>true</code> for this character.
  3689. * </ul>
  3690. * @param codePoint the character (Unicode code point) to be tested.
  3691. * @return <code>true</code> if the character may be part of a
  3692. * Unicode identifier; <code>false</code> otherwise.
  3693. * @see java.lang.Character#isIdentifierIgnorable(int)
  3694. * @see java.lang.Character#isJavaIdentifierPart(int)
  3695. * @see java.lang.Character#isLetterOrDigit(int)
  3696. * @see java.lang.Character#isUnicodeIdentifierStart(int)
  3697. * @since 1.5
  3698. */
  3699. public static boolean isUnicodeIdentifierPart(int codePoint) {
  3700. boolean bUnicodePart = false;
  3701. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  3702. bUnicodePart = CharacterDataLatin1.isUnicodeIdentifierPart(codePoint);
  3703. } else {
  3704. int plane = getPlane(codePoint);
  3705. switch(plane) {
  3706. case(0):
  3707. bUnicodePart = CharacterData00.isUnicodeIdentifierPart(codePoint);
  3708. break;
  3709. case(1):
  3710. bUnicodePart = CharacterData01.isUnicodeIdentifierPart(codePoint);
  3711. break;
  3712. case(2):
  3713. bUnicodePart = CharacterData02.isUnicodeIdentifierPart(codePoint);
  3714. break;
  3715. case(3): // Undefined
  3716. case(4): // Undefined
  3717. case(5): // Undefined
  3718. case(6): // Undefined
  3719. case(7): // Undefined
  3720. case(8): // Undefined
  3721. case(9): // Undefined
  3722. case(10): // Undefined
  3723. case(11): // Undefined
  3724. case(12): // Undefined
  3725. case(13): // Undefined
  3726. bUnicodePart = CharacterDataUndefined.isUnicodeIdentifierPart(codePoint);
  3727. break;
  3728. case(14):
  3729. bUnicodePart = CharacterData0E.isUnicodeIdentifierPart(codePoint);
  3730. break;
  3731. case(15): // Private Use
  3732. case(16): // Private Use
  3733. bUnicodePart = CharacterDataPrivateUse.isUnicodeIdentifierPart(codePoint);
  3734. break;
  3735. default:
  3736. // the argument's plane is invalid, and thus is an invalid codepoint
  3737. //bUnicodePart remains false;
  3738. break;
  3739. }
  3740. }
  3741. return bUnicodePart;
  3742. }
  3743. /**
  3744. * Determines if the specified character should be regarded as
  3745. * an ignorable character in a Java identifier or a Unicode identifier.
  3746. * <p>
  3747. * The following Unicode characters are ignorable in a Java identifier
  3748. * or a Unicode identifier:
  3749. * <ul>
  3750. * <li>ISO control characters that are not whitespace
  3751. * <ul>
  3752. * <li><code>'\u0000'</code> through <code>'\u0008'</code>
  3753. * <li><code>'\u000E'</code> through <code>'\u001B'</code>
  3754. * <li><code>'\u007F'</code> through <code>'\u009F'</code>
  3755. * </ul>
  3756. *
  3757. * <li>all characters that have the <code>FORMAT</code> general
  3758. * category value
  3759. * </ul>
  3760. *
  3761. * <p><b>Note:</b> This method cannot handle <a
  3762. * href="#supplementary"> supplementary characters</a>. To support
  3763. * all Unicode characters, including supplementary characters, use
  3764. * the {@link #isIdentifierIgnorable(int)} method.
  3765. *
  3766. * @param ch the character to be tested.
  3767. * @return <code>true</code> if the character is an ignorable control
  3768. * character that may be part of a Java or Unicode identifier;
  3769. * <code>false</code> otherwise.
  3770. * @see java.lang.Character#isJavaIdentifierPart(char)
  3771. * @see java.lang.Character#isUnicodeIdentifierPart(char)
  3772. * @since 1.1
  3773. */
  3774. public static boolean isIdentifierIgnorable(char ch) {
  3775. return isIdentifierIgnorable((int)ch);
  3776. }
  3777. /**
  3778. * Determines if the specified character (Unicode code point) should be regarded as
  3779. * an ignorable character in a Java identifier or a Unicode identifier.
  3780. * <p>
  3781. * The following Unicode characters are ignorable in a Java identifier
  3782. * or a Unicode identifier:
  3783. * <ul>
  3784. * <li>ISO control characters that are not whitespace
  3785. * <ul>
  3786. * <li><code>'\u0000'</code> through <code>'\u0008'</code>
  3787. * <li><code>'\u000E'</code> through <code>'\u001B'</code>
  3788. * <li><code>'\u007F'</code> through <code>'\u009F'</code>
  3789. * </ul>
  3790. *
  3791. * <li>all characters that have the <code>FORMAT</code> general
  3792. * category value
  3793. * </ul>
  3794. *
  3795. * @param codePoint the character (Unicode code point) to be tested.
  3796. * @return <code>true</code> if the character is an ignorable control
  3797. * character that may be part of a Java or Unicode identifier;
  3798. * <code>false</code> otherwise.
  3799. * @see java.lang.Character#isJavaIdentifierPart(int)
  3800. * @see java.lang.Character#isUnicodeIdentifierPart(int)
  3801. * @since 1.5
  3802. */
  3803. public static boolean isIdentifierIgnorable(int codePoint) {
  3804. boolean bIdentifierIgnorable = false;
  3805. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  3806. bIdentifierIgnorable = CharacterDataLatin1.isIdentifierIgnorable(codePoint);
  3807. } else {
  3808. int plane = getPlane(codePoint);
  3809. switch(plane) {
  3810. case(0):
  3811. bIdentifierIgnorable = CharacterData00.isIdentifierIgnorable(codePoint);
  3812. break;
  3813. case(1):
  3814. bIdentifierIgnorable = CharacterData01.isIdentifierIgnorable(codePoint);
  3815. break;
  3816. case(2):
  3817. bIdentifierIgnorable = CharacterData02.isIdentifierIgnorable(codePoint);
  3818. break;
  3819. case(3): // Undefined
  3820. case(4): // Undefined
  3821. case(5): // Undefined
  3822. case(6): // Undefined
  3823. case(7): // Undefined
  3824. case(8): // Undefined
  3825. case(9): // Undefined
  3826. case(10): // Undefined
  3827. case(11): // Undefined
  3828. case(12): // Undefined
  3829. case(13): // Undefined
  3830. bIdentifierIgnorable = CharacterDataUndefined.isIdentifierIgnorable(codePoint);
  3831. break;
  3832. case(14):
  3833. bIdentifierIgnorable = CharacterData0E.isIdentifierIgnorable(codePoint);
  3834. break;
  3835. case(15): // Private Use
  3836. case(16): // Private Use
  3837. bIdentifierIgnorable = CharacterDataPrivateUse.isIdentifierIgnorable(codePoint);
  3838. break;
  3839. default:
  3840. // the argument's plane is invalid, and thus is an invalid codepoint
  3841. // bIdentifierIgnorable remains false;
  3842. break;
  3843. }
  3844. }
  3845. return bIdentifierIgnorable;
  3846. }
  3847. /**
  3848. * Converts the character argument to lowercase using case
  3849. * mapping information from the UnicodeData file.
  3850. * <p>
  3851. * Note that
  3852. * <code>Character.isLowerCase(Character.toLowerCase(ch))</code>
  3853. * does not always return <code>true</code> for some ranges of
  3854. * characters, particularly those that are symbols or ideographs.
  3855. *
  3856. * <p>In general, {@link java.lang.String#toLowerCase()} should be used to map
  3857. * characters to lowercase. <code>String</code> case mapping methods
  3858. * have several benefits over <code>Character</code> case mapping methods.
  3859. * <code>String</code> case mapping methods can perform locale-sensitive
  3860. * mappings, context-sensitive mappings, and 1:M character mappings, whereas
  3861. * the <code>Character</code> case mapping methods cannot.
  3862. *
  3863. * <p><b>Note:</b> This method cannot handle <a
  3864. * href="#supplementary"> supplementary characters</a>. To support
  3865. * all Unicode characters, including supplementary characters, use
  3866. * the {@link #toLowerCase(int)} method.
  3867. *
  3868. * @param ch the character to be converted.
  3869. * @return the lowercase equivalent of the character, if any;
  3870. * otherwise, the character itself.
  3871. * @see java.lang.Character#isLowerCase(char)
  3872. * @see java.lang.String#toLowerCase()
  3873. */
  3874. public static char toLowerCase(char ch) {
  3875. return (char)toLowerCase((int)ch);
  3876. }
  3877. /**
  3878. * Converts the character (Unicode code point) argument to
  3879. * lowercase using case mapping information from the UnicodeData
  3880. * file.
  3881. *
  3882. * <p> Note that
  3883. * <code>Character.isLowerCase(Character.toLowerCase(codePoint))</code>
  3884. * does not always return <code>true</code> for some ranges of
  3885. * characters, particularly those that are symbols or ideographs.
  3886. *
  3887. * <p>In general, {@link java.lang.String#toLowerCase()} should be used to map
  3888. * characters to lowercase. <code>String</code> case mapping methods
  3889. * have several benefits over <code>Character</code> case mapping methods.
  3890. * <code>String</code> case mapping methods can perform locale-sensitive
  3891. * mappings, context-sensitive mappings, and 1:M character mappings, whereas
  3892. * the <code>Character</code> case mapping methods cannot.
  3893. *
  3894. * @param codePoint the character (Unicode code point) to be converted.
  3895. * @return the lowercase equivalent of the character (Unicode code
  3896. * point), if any; otherwise, the character itself.
  3897. * @see java.lang.Character#isLowerCase(int)
  3898. * @see java.lang.String#toLowerCase()
  3899. *
  3900. * @since 1.5
  3901. */
  3902. public static int toLowerCase(int codePoint) {
  3903. int lowerCase = codePoint;
  3904. int plane = 0;
  3905. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  3906. lowerCase = CharacterDataLatin1.toLowerCase(codePoint);
  3907. } else {
  3908. plane = getPlane(codePoint);
  3909. switch(plane) {
  3910. case(0):
  3911. lowerCase = CharacterData00.toLowerCase(codePoint);
  3912. break;
  3913. case(1):
  3914. lowerCase = CharacterData01.toLowerCase(codePoint);
  3915. break;
  3916. case(2):
  3917. lowerCase = CharacterData02.toLowerCase(codePoint);
  3918. break;
  3919. case(3): // Undefined
  3920. case(4): // Undefined
  3921. case(5): // Undefined
  3922. case(6): // Undefined
  3923. case(7): // Undefined
  3924. case(8): // Undefined
  3925. case(9): // Undefined
  3926. case(10): // Undefined
  3927. case(11): // Undefined
  3928. case(12): // Undefined
  3929. case(13): // Undefined
  3930. lowerCase = CharacterDataUndefined.toLowerCase(codePoint);
  3931. break;
  3932. case(14):
  3933. lowerCase = CharacterData0E.toLowerCase(codePoint);
  3934. break;
  3935. case(15): // Private Use
  3936. case(16): // Private Use
  3937. lowerCase = CharacterDataPrivateUse.toLowerCase(codePoint);
  3938. break;
  3939. default:
  3940. // the argument's plane is invalid, and thus is an invalid codepoint
  3941. // lowerCase remains codePoint;
  3942. break;
  3943. }
  3944. }
  3945. return lowerCase;
  3946. }
  3947. /**
  3948. * Converts the character argument to uppercase using case mapping
  3949. * information from the UnicodeData file.
  3950. * <p>
  3951. * Note that
  3952. * <code>Character.isUpperCase(Character.toUpperCase(ch))</code>
  3953. * does not always return <code>true</code> for some ranges of
  3954. * characters, particularly those that are symbols or ideographs.
  3955. *
  3956. * <p>In general, {@link java.lang.String#toUpperCase()} should be used to map
  3957. * characters to uppercase. <code>String</code> case mapping methods
  3958. * have several benefits over <code>Character</code> case mapping methods.
  3959. * <code>String</code> case mapping methods can perform locale-sensitive
  3960. * mappings, context-sensitive mappings, and 1:M character mappings, whereas
  3961. * the <code>Character</code> case mapping methods cannot.
  3962. *
  3963. * <p><b>Note:</b> This method cannot handle <a
  3964. * href="#supplementary"> supplementary characters</a>. To support
  3965. * all Unicode characters, including supplementary characters, use
  3966. * the {@link #toUpperCase(int)} method.
  3967. *
  3968. * @param ch the character to be converted.
  3969. * @return the uppercase equivalent of the character, if any;
  3970. * otherwise, the character itself.
  3971. * @see java.lang.Character#isUpperCase(char)
  3972. * @see java.lang.String#toUpperCase()
  3973. */
  3974. public static char toUpperCase(char ch) {
  3975. return (char)toUpperCase((int)ch);
  3976. }
  3977. /**
  3978. * Converts the character (Unicode code point) argument to
  3979. * uppercase using case mapping information from the UnicodeData
  3980. * file.
  3981. *
  3982. * <p>Note that
  3983. * <code>Character.isUpperCase(Character.toUpperCase(codePoint))</code>
  3984. * does not always return <code>true</code> for some ranges of
  3985. * characters, particularly those that are symbols or ideographs.
  3986. *
  3987. * <p>In general, {@link java.lang.String#toUpperCase()} should be used to map
  3988. * characters to uppercase. <code>String</code> case mapping methods
  3989. * have several benefits over <code>Character</code> case mapping methods.
  3990. * <code>String</code> case mapping methods can perform locale-sensitive
  3991. * mappings, context-sensitive mappings, and 1:M character mappings, whereas
  3992. * the <code>Character</code> case mapping methods cannot.
  3993. *
  3994. * @param codePoint the character (Unicode code point) to be converted.
  3995. * @return the uppercase equivalent of the character, if any;
  3996. * otherwise, the character itself.
  3997. * @see java.lang.Character#isUpperCase(int)
  3998. * @see java.lang.String#toUpperCase()
  3999. *
  4000. * @since 1.5
  4001. */
  4002. public static int toUpperCase(int codePoint) {
  4003. int upperCase = codePoint;
  4004. int plane = 0;
  4005. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  4006. upperCase = CharacterDataLatin1.toUpperCase(codePoint);
  4007. } else {
  4008. plane = getPlane(codePoint);
  4009. switch(plane) {
  4010. case(0):
  4011. upperCase = CharacterData00.toUpperCase(codePoint);
  4012. break;
  4013. case(1):
  4014. upperCase = CharacterData01.toUpperCase(codePoint);
  4015. break;
  4016. case(2):
  4017. upperCase = CharacterData02.toUpperCase(codePoint);
  4018. break;
  4019. case(3): // Undefined
  4020. case(4): // Undefined
  4021. case(5): // Undefined
  4022. case(6): // Undefined
  4023. case(7): // Undefined
  4024. case(8): // Undefined
  4025. case(9): // Undefined
  4026. case(10): // Undefined
  4027. case(11): // Undefined
  4028. case(12): // Undefined
  4029. case(13): // Undefined
  4030. upperCase = CharacterDataUndefined.toUpperCase(codePoint);
  4031. break;
  4032. case(14):
  4033. upperCase = CharacterData0E.toUpperCase(codePoint);
  4034. break;
  4035. case(15): // Private Use
  4036. case(16): // Private Use
  4037. upperCase = CharacterDataPrivateUse.toUpperCase(codePoint);
  4038. break;
  4039. default:
  4040. // the argument's plane is invalid, and thus is an invalid codepoint
  4041. // upperCase remains codePoint;
  4042. break;
  4043. }
  4044. }
  4045. return upperCase;
  4046. }
  4047. /**
  4048. * Converts the character argument to titlecase using case mapping
  4049. * information from the UnicodeData file. If a character has no
  4050. * explicit titlecase mapping and is not itself a titlecase char
  4051. * according to UnicodeData, then the uppercase mapping is
  4052. * returned as an equivalent titlecase mapping. If the
  4053. * <code>char</code> argument is already a titlecase
  4054. * <code>char</code>, the same <code>char</code> value will be
  4055. * returned.
  4056. * <p>
  4057. * Note that
  4058. * <code>Character.isTitleCase(Character.toTitleCase(ch))</code>
  4059. * does not always return <code>true</code> for some ranges of
  4060. * characters.
  4061. *
  4062. * <p><b>Note:</b> This method cannot handle <a
  4063. * href="#supplementary"> supplementary characters</a>. To support
  4064. * all Unicode characters, including supplementary characters, use
  4065. * the {@link #toTitleCase(int)} method.
  4066. *
  4067. * @param ch the character to be converted.
  4068. * @return the titlecase equivalent of the character, if any;
  4069. * otherwise, the character itself.
  4070. * @see java.lang.Character#isTitleCase(char)
  4071. * @see java.lang.Character#toLowerCase(char)
  4072. * @see java.lang.Character#toUpperCase(char)
  4073. * @since 1.0.2
  4074. */
  4075. public static char toTitleCase(char ch) {
  4076. return (char)toTitleCase((int)ch);
  4077. }
  4078. /**
  4079. * Converts the character (Unicode code point) argument to titlecase using case mapping
  4080. * information from the UnicodeData file. If a character has no
  4081. * explicit titlecase mapping and is not itself a titlecase char
  4082. * according to UnicodeData, then the uppercase mapping is
  4083. * returned as an equivalent titlecase mapping. If the
  4084. * character argument is already a titlecase
  4085. * character, the same character value will be
  4086. * returned.
  4087. *
  4088. * <p>Note that
  4089. * <code>Character.isTitleCase(Character.toTitleCase(codePoint))</code>
  4090. * does not always return <code>true</code> for some ranges of
  4091. * characters.
  4092. *
  4093. * @param codePoint the character (Unicode code point) to be converted.
  4094. * @return the titlecase equivalent of the character, if any;
  4095. * otherwise, the character itself.
  4096. * @see java.lang.Character#isTitleCase(int)
  4097. * @see java.lang.Character#toLowerCase(int)
  4098. * @see java.lang.Character#toUpperCase(int)
  4099. * @since 1.5
  4100. */
  4101. public static int toTitleCase(int codePoint) {
  4102. int titleCase = codePoint;
  4103. int plane = 0;
  4104. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  4105. titleCase = CharacterDataLatin1.toTitleCase(codePoint);
  4106. } else {
  4107. plane = getPlane(codePoint);
  4108. switch(plane) {
  4109. case(0):
  4110. titleCase = CharacterData00.toTitleCase(codePoint);
  4111. break;
  4112. case(1):
  4113. titleCase = CharacterData01.toTitleCase(codePoint);
  4114. break;
  4115. case(2):
  4116. titleCase = CharacterData02.toTitleCase(codePoint);
  4117. break;
  4118. case(3): // Undefined
  4119. case(4): // Undefined
  4120. case(5): // Undefined
  4121. case(6): // Undefined
  4122. case(7): // Undefined
  4123. case(8): // Undefined
  4124. case(9): // Undefined
  4125. case(10): // Undefined
  4126. case(11): // Undefined
  4127. case(12): // Undefined
  4128. case(13): // Undefined
  4129. titleCase = CharacterDataUndefined.toTitleCase(codePoint);
  4130. break;
  4131. case(14):
  4132. titleCase = CharacterData0E.toTitleCase(codePoint);
  4133. break;
  4134. case(15): // Private Use
  4135. case(16): // Private Use
  4136. titleCase = CharacterDataPrivateUse.toTitleCase(codePoint);
  4137. break;
  4138. default:
  4139. // the argument's plane is invalid, and thus is an invalid codepoint
  4140. // titleCase remains codePoint;
  4141. break;
  4142. }
  4143. }
  4144. return titleCase;
  4145. }
  4146. /**
  4147. * Returns the numeric value of the character <code>ch</code> in the
  4148. * specified radix.
  4149. * <p>
  4150. * If the radix is not in the range <code>MIN_RADIX</code> <=
  4151. * <code>radix</code> <= <code>MAX_RADIX</code> or if the
  4152. * value of <code>ch</code> is not a valid digit in the specified
  4153. * radix, <code>-1</code> is returned. A character is a valid digit
  4154. * if at least one of the following is true:
  4155. * <ul>
  4156. * <li>The method <code>isDigit</code> is <code>true</code> of the character
  4157. * and the Unicode decimal digit value of the character (or its
  4158. * single-character decomposition) is less than the specified radix.
  4159. * In this case the decimal digit value is returned.
  4160. * <li>The character is one of the uppercase Latin letters
  4161. * <code>'A'</code> through <code>'Z'</code> and its code is less than
  4162. * <code>radix + 'A' - 10</code>.
  4163. * In this case, <code>ch - 'A' + 10</code>
  4164. * is returned.
  4165. * <li>The character is one of the lowercase Latin letters
  4166. * <code>'a'</code> through <code>'z'</code> and its code is less than
  4167. * <code>radix + 'a' - 10</code>.
  4168. * In this case, <code>ch - 'a' + 10</code>
  4169. * is returned.
  4170. * </ul>
  4171. *
  4172. * <p><b>Note:</b> This method cannot handle <a
  4173. * href="#supplementary"> supplementary characters</a>. To support
  4174. * all Unicode characters, including supplementary characters, use
  4175. * the {@link #digit(int, int)} method.
  4176. *
  4177. * @param ch the character to be converted.
  4178. * @param radix the radix.
  4179. * @return the numeric value represented by the character in the
  4180. * specified radix.
  4181. * @see java.lang.Character#forDigit(int, int)
  4182. * @see java.lang.Character#isDigit(char)
  4183. */
  4184. public static int digit(char ch, int radix) {
  4185. return digit((int)ch, radix);
  4186. }
  4187. /**
  4188. * Returns the numeric value of the specified character (Unicode
  4189. * code point) in the specified radix.
  4190. *
  4191. * <p>If the radix is not in the range <code>MIN_RADIX</code> <=
  4192. * <code>radix</code> <= <code>MAX_RADIX</code> or if the
  4193. * character is not a valid digit in the specified
  4194. * radix, <code>-1</code> is returned. A character is a valid digit
  4195. * if at least one of the following is true:
  4196. * <ul>
  4197. * <li>The method {@link #isDigit(int) isDigit(codePoint)} is <code>true</code> of the character
  4198. * and the Unicode decimal digit value of the character (or its
  4199. * single-character decomposition) is less than the specified radix.
  4200. * In this case the decimal digit value is returned.
  4201. * <li>The character is one of the uppercase Latin letters
  4202. * <code>'A'</code> through <code>'Z'</code> and its code is less than
  4203. * <code>radix + 'A' - 10</code>.
  4204. * In this case, <code>ch - 'A' + 10</code>
  4205. * is returned.
  4206. * <li>The character is one of the lowercase Latin letters
  4207. * <code>'a'</code> through <code>'z'</code> and its code is less than
  4208. * <code>radix + 'a' - 10</code>.
  4209. * In this case, <code>ch - 'a' + 10</code>
  4210. * is returned.
  4211. * </ul>
  4212. *
  4213. * @param codePoint the character (Unicode code point) to be converted.
  4214. * @param radix the radix.
  4215. * @return the numeric value represented by the character in the
  4216. * specified radix.
  4217. * @see java.lang.Character#forDigit(int, int)
  4218. * @see java.lang.Character#isDigit(int)
  4219. * @since 1.5
  4220. */
  4221. public static int digit(int codePoint, int radix) {
  4222. int digit = -1;
  4223. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  4224. digit = CharacterDataLatin1.digit(codePoint, radix);
  4225. } else {
  4226. int plane = getPlane(codePoint);
  4227. switch(plane) {
  4228. case(0):
  4229. digit = CharacterData00.digit(codePoint, radix);
  4230. break;
  4231. case(1):
  4232. digit = CharacterData01.digit(codePoint, radix);
  4233. break;
  4234. case(2):
  4235. digit = CharacterData02.digit(codePoint, radix);
  4236. break;
  4237. case(3): // Undefined
  4238. case(4): // Undefined
  4239. case(5): // Undefined
  4240. case(6): // Undefined
  4241. case(7): // Undefined
  4242. case(8): // Undefined
  4243. case(9): // Undefined
  4244. case(10): // Undefined
  4245. case(11): // Undefined
  4246. case(12): // Undefined
  4247. case(13): // Undefined
  4248. digit = CharacterDataUndefined.digit(codePoint, radix);
  4249. break;
  4250. case(14):
  4251. digit = CharacterData0E.digit(codePoint, radix);
  4252. break;
  4253. case(15): // Private Use
  4254. case(16): // Private Use
  4255. digit = CharacterDataPrivateUse.digit(codePoint, radix);
  4256. break;
  4257. default:
  4258. // the argument's plane is invalid, and thus is an invalid codepoint
  4259. // digit remains -1;
  4260. break;
  4261. }
  4262. }
  4263. return digit;
  4264. }
  4265. /**
  4266. * Returns the <code>int</code> value that the specified Unicode
  4267. * character represents. For example, the character
  4268. * <code>'\u216C'</code> (the roman numeral fifty) will return
  4269. * an int with a value of 50.
  4270. * <p>
  4271. * The letters A-Z in their uppercase (<code>'\u0041'</code> through
  4272. * <code>'\u005A'</code>), lowercase
  4273. * (<code>'\u0061'</code> through <code>'\u007A'</code>), and
  4274. * full width variant (<code>'\uFF21'</code> through
  4275. * <code>'\uFF3A'</code> and <code>'\uFF41'</code> through
  4276. * <code>'\uFF5A'</code>) forms have numeric values from 10
  4277. * through 35. This is independent of the Unicode specification,
  4278. * which does not assign numeric values to these <code>char</code>
  4279. * values.
  4280. * <p>
  4281. * If the character does not have a numeric value, then -1 is returned.
  4282. * If the character has a numeric value that cannot be represented as a
  4283. * nonnegative integer (for example, a fractional value), then -2
  4284. * is returned.
  4285. *
  4286. * <p><b>Note:</b> This method cannot handle <a
  4287. * href="#supplementary"> supplementary characters</a>. To support
  4288. * all Unicode characters, including supplementary characters, use
  4289. * the {@link #getNumericValue(int)} method.
  4290. *
  4291. * @param ch the character to be converted.
  4292. * @return the numeric value of the character, as a nonnegative <code>int</code>
  4293. * value; -2 if the character has a numeric value that is not a
  4294. * nonnegative integer; -1 if the character has no numeric value.
  4295. * @see java.lang.Character#forDigit(int, int)
  4296. * @see java.lang.Character#isDigit(char)
  4297. * @since 1.1
  4298. */
  4299. public static int getNumericValue(char ch) {
  4300. return getNumericValue((int)ch);
  4301. }
  4302. /**
  4303. * Returns the <code>int</code> value that the specified
  4304. * character (Unicode code point) represents. For example, the character
  4305. * <code>'\u216C'</code> (the Roman numeral fifty) will return
  4306. * an <code>int</code> with a value of 50.
  4307. * <p>
  4308. * The letters A-Z in their uppercase (<code>'\u0041'</code> through
  4309. * <code>'\u005A'</code>), lowercase
  4310. * (<code>'\u0061'</code> through <code>'\u007A'</code>), and
  4311. * full width variant (<code>'\uFF21'</code> through
  4312. * <code>'\uFF3A'</code> and <code>'\uFF41'</code> through
  4313. * <code>'\uFF5A'</code>) forms have numeric values from 10
  4314. * through 35. This is independent of the Unicode specification,
  4315. * which does not assign numeric values to these <code>char</code>
  4316. * values.
  4317. * <p>
  4318. * If the character does not have a numeric value, then -1 is returned.
  4319. * If the character has a numeric value that cannot be represented as a
  4320. * nonnegative integer (for example, a fractional value), then -2
  4321. * is returned.
  4322. *
  4323. * @param codePoint the character (Unicode code point) to be converted.
  4324. * @return the numeric value of the character, as a nonnegative <code>int</code>
  4325. * value; -2 if the character has a numeric value that is not a
  4326. * nonnegative integer; -1 if the character has no numeric value.
  4327. * @see java.lang.Character#forDigit(int, int)
  4328. * @see java.lang.Character#isDigit(int)
  4329. * @since 1.5
  4330. */
  4331. public static int getNumericValue(int codePoint) {
  4332. int numericValue = -1;
  4333. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  4334. numericValue = CharacterDataLatin1.getNumericValue(codePoint);
  4335. } else {
  4336. int plane = getPlane(codePoint);
  4337. switch(plane) {
  4338. case(0):
  4339. numericValue = CharacterData00.getNumericValue(codePoint);
  4340. break;
  4341. case(1):
  4342. numericValue = CharacterData01.getNumericValue(codePoint);
  4343. break;
  4344. case(2):
  4345. numericValue = CharacterData02.getNumericValue(codePoint);
  4346. break;
  4347. case(3): // Undefined
  4348. case(4): // Undefined
  4349. case(5): // Undefined
  4350. case(6): // Undefined
  4351. case(7): // Undefined
  4352. case(8): // Undefined
  4353. case(9): // Undefined
  4354. case(10): // Undefined
  4355. case(11): // Undefined
  4356. case(12): // Undefined
  4357. case(13): // Undefined
  4358. numericValue = CharacterDataUndefined.getNumericValue(codePoint);
  4359. break;
  4360. case(14):
  4361. numericValue = CharacterData0E.getNumericValue(codePoint);
  4362. break;
  4363. case(15): // Private Use
  4364. case(16): // Private Use
  4365. numericValue = CharacterDataPrivateUse.getNumericValue(codePoint);
  4366. break;
  4367. default:
  4368. // the argument's plane is invalid, and thus is an invalid codepoint
  4369. // numericValue remains -1
  4370. break;
  4371. }
  4372. }
  4373. return numericValue;
  4374. }
  4375. /**
  4376. * Determines if the specified character is ISO-LATIN-1 white space.
  4377. * This method returns <code>true</code> for the following five
  4378. * characters only:
  4379. * <table>
  4380. * <tr><td><code>'\t'</code></td> <td><code>'\u0009'</code></td>
  4381. * <td><code>HORIZONTAL TABULATION</code></td></tr>
  4382. * <tr><td><code>'\n'</code></td> <td><code>'\u000A'</code></td>
  4383. * <td><code>NEW LINE</code></td></tr>
  4384. * <tr><td><code>'\f'</code></td> <td><code>'\u000C'</code></td>
  4385. * <td><code>FORM FEED</code></td></tr>
  4386. * <tr><td><code>'\r'</code></td> <td><code>'\u000D'</code></td>
  4387. * <td><code>CARRIAGE RETURN</code></td></tr>
  4388. * <tr><td><code>' '</code></td> <td><code>'\u0020'</code></td>
  4389. * <td><code>SPACE</code></td></tr>
  4390. * </table>
  4391. *
  4392. * @param ch the character to be tested.
  4393. * @return <code>true</code> if the character is ISO-LATIN-1 white
  4394. * space; <code>false</code> otherwise.
  4395. * @see java.lang.Character#isSpaceChar(char)
  4396. * @see java.lang.Character#isWhitespace(char)
  4397. * @deprecated Replaced by isWhitespace(char).
  4398. */
  4399. @Deprecated
  4400. public static boolean isSpace(char ch) {
  4401. return (ch <= 0x0020) &&
  4402. (((((1L << 0x0009) |
  4403. (1L << 0x000A) |
  4404. (1L << 0x000C) |
  4405. (1L << 0x000D) |
  4406. (1L << 0x0020)) >> ch) & 1L) != 0);
  4407. }
  4408. /**
  4409. * Determines if the specified character is a Unicode space character.
  4410. * A character is considered to be a space character if and only if
  4411. * it is specified to be a space character by the Unicode standard. This
  4412. * method returns true if the character's general category type is any of
  4413. * the following:
  4414. * <ul>
  4415. * <li> <code>SPACE_SEPARATOR</code>
  4416. * <li> <code>LINE_SEPARATOR</code>
  4417. * <li> <code>PARAGRAPH_SEPARATOR</code>
  4418. * </ul>
  4419. *
  4420. * <p><b>Note:</b> This method cannot handle <a
  4421. * href="#supplementary"> supplementary characters</a>. To support
  4422. * all Unicode characters, including supplementary characters, use
  4423. * the {@link #isSpaceChar(int)} method.
  4424. *
  4425. * @param ch the character to be tested.
  4426. * @return <code>true</code> if the character is a space character;
  4427. * <code>false</code> otherwise.
  4428. * @see java.lang.Character#isWhitespace(char)
  4429. * @since 1.1
  4430. */
  4431. public static boolean isSpaceChar(char ch) {
  4432. return isSpaceChar((int)ch);
  4433. }
  4434. /**
  4435. * Determines if the specified character (Unicode code point) is a
  4436. * Unicode space character. A character is considered to be a
  4437. * space character if and only if it is specified to be a space
  4438. * character by the Unicode standard. This method returns true if
  4439. * the character's general category type is any of the following:
  4440. *
  4441. * <ul>
  4442. * <li> {@link #SPACE_SEPARATOR}
  4443. * <li> {@link #LINE_SEPARATOR}
  4444. * <li> {@link #PARAGRAPH_SEPARATOR}
  4445. * </ul>
  4446. *
  4447. * @param codePoint the character (Unicode code point) to be tested.
  4448. * @return <code>true</code> if the character is a space character;
  4449. * <code>false</code> otherwise.
  4450. * @see java.lang.Character#isWhitespace(int)
  4451. * @since 1.5
  4452. */
  4453. public static boolean isSpaceChar(int codePoint) {
  4454. boolean bSpaceChar = false;
  4455. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  4456. bSpaceChar = CharacterDataLatin1.isSpaceChar(codePoint);
  4457. } else {
  4458. int plane = getPlane(codePoint);
  4459. switch(plane) {
  4460. case(0):
  4461. bSpaceChar = CharacterData00.isSpaceChar(codePoint);
  4462. break;
  4463. case(1):
  4464. bSpaceChar = CharacterData01.isSpaceChar(codePoint);
  4465. break;
  4466. case(2):
  4467. bSpaceChar = CharacterData02.isSpaceChar(codePoint);
  4468. break;
  4469. case(3): // Undefined
  4470. case(4): // Undefined
  4471. case(5): // Undefined
  4472. case(6): // Undefined
  4473. case(7): // Undefined
  4474. case(8): // Undefined
  4475. case(9): // Undefined
  4476. case(10): // Undefined
  4477. case(11): // Undefined
  4478. case(12): // Undefined
  4479. case(13): // Undefined
  4480. bSpaceChar = CharacterDataUndefined.isSpaceChar(codePoint);
  4481. break;
  4482. case(14):
  4483. bSpaceChar = CharacterData0E.isSpaceChar(codePoint);
  4484. break;
  4485. case(15): // Private Use
  4486. case(16): // Private Use
  4487. bSpaceChar = CharacterDataPrivateUse.isSpaceChar(codePoint);
  4488. break;
  4489. default:
  4490. // the argument's plane is invalid, and thus is an invalid codepoint
  4491. // bSpaceChar remains false
  4492. break;
  4493. }
  4494. }
  4495. return bSpaceChar;
  4496. }
  4497. /**
  4498. * Determines if the specified character is white space according to Java.
  4499. * A character is a Java whitespace character if and only if it satisfies
  4500. * one of the following criteria:
  4501. * <ul>
  4502. * <li> It is a Unicode space character (<code>SPACE_SEPARATOR</code>,
  4503. * <code>LINE_SEPARATOR</code>, or <code>PARAGRAPH_SEPARATOR</code>)
  4504. * but is not also a non-breaking space (<code>'\u00A0'</code>,
  4505. * <code>'\u2007'</code>, <code>'\u202F'</code>).
  4506. * <li> It is <code>'\u0009'</code>, HORIZONTAL TABULATION.
  4507. * <li> It is <code>'\u000A'</code>, LINE FEED.
  4508. * <li> It is <code>'\u000B'</code>, VERTICAL TABULATION.
  4509. * <li> It is <code>'\u000C'</code>, FORM FEED.
  4510. * <li> It is <code>'\u000D'</code>, CARRIAGE RETURN.
  4511. * <li> It is <code>'\u001C'</code>, FILE SEPARATOR.
  4512. * <li> It is <code>'\u001D'</code>, GROUP SEPARATOR.
  4513. * <li> It is <code>'\u001E'</code>, RECORD SEPARATOR.
  4514. * <li> It is <code>'\u001F'</code>, UNIT SEPARATOR.
  4515. * </ul>
  4516. *
  4517. * <p><b>Note:</b> This method cannot handle <a
  4518. * href="#supplementary"> supplementary characters</a>. To support
  4519. * all Unicode characters, including supplementary characters, use
  4520. * the {@link #isWhitespace(int)} method.
  4521. *
  4522. * @param ch the character to be tested.
  4523. * @return <code>true</code> if the character is a Java whitespace
  4524. * character; <code>false</code> otherwise.
  4525. * @see java.lang.Character#isSpaceChar(char)
  4526. * @since 1.1
  4527. */
  4528. public static boolean isWhitespace(char ch) {
  4529. return isWhitespace((int)ch);
  4530. }
  4531. /**
  4532. * Determines if the specified character (Unicode code point) is
  4533. * white space according to Java. A character is a Java
  4534. * whitespace character if and only if it satisfies one of the
  4535. * following criteria:
  4536. * <ul>
  4537. * <li> It is a Unicode space character ({@link #SPACE_SEPARATOR},
  4538. * {@link #LINE_SEPARATOR}, or {@link #PARAGRAPH_SEPARATOR})
  4539. * but is not also a non-breaking space (<code>'\u00A0'</code>,
  4540. * <code>'\u2007'</code>, <code>'\u202F'</code>).
  4541. * <li> It is <code>'\u0009'</code>, HORIZONTAL TABULATION.
  4542. * <li> It is <code>'\u000A'</code>, LINE FEED.
  4543. * <li> It is <code>'\u000B'</code>, VERTICAL TABULATION.
  4544. * <li> It is <code>'\u000C'</code>, FORM FEED.
  4545. * <li> It is <code>'\u000D'</code>, CARRIAGE RETURN.
  4546. * <li> It is <code>'\u001C'</code>, FILE SEPARATOR.
  4547. * <li> It is <code>'\u001D'</code>, GROUP SEPARATOR.
  4548. * <li> It is <code>'\u001E'</code>, RECORD SEPARATOR.
  4549. * <li> It is <code>'\u001F'</code>, UNIT SEPARATOR.
  4550. * </ul>
  4551. * <p>
  4552. *
  4553. * @param codePoint the character (Unicode code point) to be tested.
  4554. * @return <code>true</code> if the character is a Java whitespace
  4555. * character; <code>false</code> otherwise.
  4556. * @see java.lang.Character#isSpaceChar(int)
  4557. * @since 1.5
  4558. */
  4559. public static boolean isWhitespace(int codePoint) {
  4560. boolean bWhiteSpace = false;
  4561. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  4562. bWhiteSpace = CharacterDataLatin1.isWhitespace(codePoint);
  4563. } else {
  4564. int plane = getPlane(codePoint);
  4565. switch(plane) {
  4566. case(0):
  4567. bWhiteSpace = CharacterData00.isWhitespace(codePoint);
  4568. break;
  4569. case(1):
  4570. bWhiteSpace = CharacterData01.isWhitespace(codePoint);
  4571. break;
  4572. case(2):
  4573. bWhiteSpace = CharacterData02.isWhitespace(codePoint);
  4574. break;
  4575. case(3): // Undefined
  4576. case(4): // Undefined
  4577. case(5): // Undefined
  4578. case(6): // Undefined
  4579. case(7): // Undefined
  4580. case(8): // Undefined
  4581. case(9): // Undefined
  4582. case(10): // Undefined
  4583. case(11): // Undefined
  4584. case(12): // Undefined
  4585. case(13): // Undefined
  4586. bWhiteSpace = CharacterDataUndefined.isWhitespace(codePoint);
  4587. break;
  4588. case(14):
  4589. bWhiteSpace = CharacterData0E.isWhitespace(codePoint);
  4590. break;
  4591. case(15): // Private Use
  4592. case(16): // Private Use
  4593. bWhiteSpace = CharacterDataPrivateUse.isWhitespace(codePoint);
  4594. break;
  4595. default:
  4596. // the argument's plane is invalid, and thus is an invalid codepoint
  4597. // bWhiteSpace remains false
  4598. break;
  4599. }
  4600. }
  4601. return bWhiteSpace;
  4602. }
  4603. /**
  4604. * Determines if the specified character is an ISO control
  4605. * character. A character is considered to be an ISO control
  4606. * character if its code is in the range <code>'\u0000'</code>
  4607. * through <code>'\u001F'</code> or in the range
  4608. * <code>'\u007F'</code> through <code>'\u009F'</code>.
  4609. *
  4610. * <p><b>Note:</b> This method cannot handle <a
  4611. * href="#supplementary"> supplementary characters</a>. To support
  4612. * all Unicode characters, including supplementary characters, use
  4613. * the {@link #isISOControl(int)} method.
  4614. *
  4615. * @param ch the character to be tested.
  4616. * @return <code>true</code> if the character is an ISO control character;
  4617. * <code>false</code> otherwise.
  4618. *
  4619. * @see java.lang.Character#isSpaceChar(char)
  4620. * @see java.lang.Character#isWhitespace(char)
  4621. * @since 1.1
  4622. */
  4623. public static boolean isISOControl(char ch) {
  4624. return isISOControl((int)ch);
  4625. }
  4626. /**
  4627. * Determines if the referenced character (Unicode code point) is an ISO control
  4628. * character. A character is considered to be an ISO control
  4629. * character if its code is in the range <code>'\u0000'</code>
  4630. * through <code>'\u001F'</code> or in the range
  4631. * <code>'\u007F'</code> through <code>'\u009F'</code>.
  4632. *
  4633. * @param codePoint the character (Unicode code point) to be tested.
  4634. * @return <code>true</code> if the character is an ISO control character;
  4635. * <code>false</code> otherwise.
  4636. * @see java.lang.Character#isSpaceChar(int)
  4637. * @see java.lang.Character#isWhitespace(int)
  4638. * @since 1.5
  4639. */
  4640. public static boolean isISOControl(int codePoint) {
  4641. return (codePoint >= 0x0000 && codePoint <= 0x001F) ||
  4642. (codePoint >= 0x007F && codePoint <= 0x009F);
  4643. }
  4644. /**
  4645. * Returns a value indicating a character's general category.
  4646. *
  4647. * <p><b>Note:</b> This method cannot handle <a
  4648. * href="#supplementary"> supplementary characters</a>. To support
  4649. * all Unicode characters, including supplementary characters, use
  4650. * the {@link #getType(int)} method.
  4651. *
  4652. * @param ch the character to be tested.
  4653. * @return a value of type <code>int</code> representing the
  4654. * character's general category.
  4655. * @see java.lang.Character#COMBINING_SPACING_MARK
  4656. * @see java.lang.Character#CONNECTOR_PUNCTUATION
  4657. * @see java.lang.Character#CONTROL
  4658. * @see java.lang.Character#CURRENCY_SYMBOL
  4659. * @see java.lang.Character#DASH_PUNCTUATION
  4660. * @see java.lang.Character#DECIMAL_DIGIT_NUMBER
  4661. * @see java.lang.Character#ENCLOSING_MARK
  4662. * @see java.lang.Character#END_PUNCTUATION
  4663. * @see java.lang.Character#FINAL_QUOTE_PUNCTUATION
  4664. * @see java.lang.Character#FORMAT
  4665. * @see java.lang.Character#INITIAL_QUOTE_PUNCTUATION
  4666. * @see java.lang.Character#LETTER_NUMBER
  4667. * @see java.lang.Character#LINE_SEPARATOR
  4668. * @see java.lang.Character#LOWERCASE_LETTER
  4669. * @see java.lang.Character#MATH_SYMBOL
  4670. * @see java.lang.Character#MODIFIER_LETTER
  4671. * @see java.lang.Character#MODIFIER_SYMBOL
  4672. * @see java.lang.Character#NON_SPACING_MARK
  4673. * @see java.lang.Character#OTHER_LETTER
  4674. * @see java.lang.Character#OTHER_NUMBER
  4675. * @see java.lang.Character#OTHER_PUNCTUATION
  4676. * @see java.lang.Character#OTHER_SYMBOL
  4677. * @see java.lang.Character#PARAGRAPH_SEPARATOR
  4678. * @see java.lang.Character#PRIVATE_USE
  4679. * @see java.lang.Character#SPACE_SEPARATOR
  4680. * @see java.lang.Character#START_PUNCTUATION
  4681. * @see java.lang.Character#SURROGATE
  4682. * @see java.lang.Character#TITLECASE_LETTER
  4683. * @see java.lang.Character#UNASSIGNED
  4684. * @see java.lang.Character#UPPERCASE_LETTER
  4685. * @since 1.1
  4686. */
  4687. public static int getType(char ch) {
  4688. return getType((int)ch);
  4689. }
  4690. /**
  4691. * Returns a value indicating a character's general category.
  4692. *
  4693. * @param codePoint the character (Unicode code point) to be tested.
  4694. * @return a value of type <code>int</code> representing the
  4695. * character's general category.
  4696. * @see Character#COMBINING_SPACING_MARK COMBINING_SPACING_MARK
  4697. * @see Character#CONNECTOR_PUNCTUATION CONNECTOR_PUNCTUATION
  4698. * @see Character#CONTROL CONTROL
  4699. * @see Character#CURRENCY_SYMBOL CURRENCY_SYMBOL
  4700. * @see Character#DASH_PUNCTUATION DASH_PUNCTUATION
  4701. * @see Character#DECIMAL_DIGIT_NUMBER DECIMAL_DIGIT_NUMBER
  4702. * @see Character#ENCLOSING_MARK ENCLOSING_MARK
  4703. * @see Character#END_PUNCTUATION END_PUNCTUATION
  4704. * @see Character#FINAL_QUOTE_PUNCTUATION FINAL_QUOTE_PUNCTUATION
  4705. * @see Character#FORMAT FORMAT
  4706. * @see Character#INITIAL_QUOTE_PUNCTUATION INITIAL_QUOTE_PUNCTUATION
  4707. * @see Character#LETTER_NUMBER LETTER_NUMBER
  4708. * @see Character#LINE_SEPARATOR LINE_SEPARATOR
  4709. * @see Character#LOWERCASE_LETTER LOWERCASE_LETTER
  4710. * @see Character#MATH_SYMBOL MATH_SYMBOL
  4711. * @see Character#MODIFIER_LETTER MODIFIER_LETTER
  4712. * @see Character#MODIFIER_SYMBOL MODIFIER_SYMBOL
  4713. * @see Character#NON_SPACING_MARK NON_SPACING_MARK
  4714. * @see Character#OTHER_LETTER OTHER_LETTER
  4715. * @see Character#OTHER_NUMBER OTHER_NUMBER
  4716. * @see Character#OTHER_PUNCTUATION OTHER_PUNCTUATION
  4717. * @see Character#OTHER_SYMBOL OTHER_SYMBOL
  4718. * @see Character#PARAGRAPH_SEPARATOR PARAGRAPH_SEPARATOR
  4719. * @see Character#PRIVATE_USE PRIVATE_USE
  4720. * @see Character#SPACE_SEPARATOR SPACE_SEPARATOR
  4721. * @see Character#START_PUNCTUATION START_PUNCTUATION
  4722. * @see Character#SURROGATE SURROGATE
  4723. * @see Character#TITLECASE_LETTER TITLECASE_LETTER
  4724. * @see Character#UNASSIGNED UNASSIGNED
  4725. * @see Character#UPPERCASE_LETTER UPPERCASE_LETTER
  4726. * @since 1.5
  4727. */
  4728. public static int getType(int codePoint) {
  4729. int type = Character.UNASSIGNED;
  4730. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  4731. type = CharacterDataLatin1.getType(codePoint);
  4732. } else {
  4733. int plane = getPlane(codePoint);
  4734. switch(plane) {
  4735. case(0):
  4736. type = CharacterData00.getType(codePoint);
  4737. break;
  4738. case(1):
  4739. type = CharacterData01.getType(codePoint);
  4740. break;
  4741. case(2):
  4742. type = CharacterData02.getType(codePoint);
  4743. break;
  4744. case(3): // Undefined
  4745. case(4): // Undefined
  4746. case(5): // Undefined
  4747. case(6): // Undefined
  4748. case(7): // Undefined
  4749. case(8): // Undefined
  4750. case(9): // Undefined
  4751. case(10): // Undefined
  4752. case(11): // Undefined
  4753. case(12): // Undefined
  4754. case(13): // Undefined
  4755. type = CharacterDataUndefined.getType(codePoint);
  4756. break;
  4757. case(14):
  4758. type = CharacterData0E.getType(codePoint);
  4759. break;
  4760. case(15): // Private Use
  4761. case(16): // Private Use
  4762. type = CharacterDataPrivateUse.getType(codePoint);
  4763. break;
  4764. default:
  4765. // the argument's plane is invalid, and thus is an invalid codepoint
  4766. // type remains UNASSIGNED
  4767. break;
  4768. }
  4769. }
  4770. return type;
  4771. }
  4772. /**
  4773. * Determines the character representation for a specific digit in
  4774. * the specified radix. If the value of <code>radix</code> is not a
  4775. * valid radix, or the value of <code>digit</code> is not a valid
  4776. * digit in the specified radix, the null character
  4777. * (<code>'\u0000'</code>) is returned.
  4778. * <p>
  4779. * The <code>radix</code> argument is valid if it is greater than or
  4780. * equal to <code>MIN_RADIX</code> and less than or equal to
  4781. * <code>MAX_RADIX</code>. The <code>digit</code> argument is valid if
  4782. * <code>0 <=digit < radix</code>.
  4783. * <p>
  4784. * If the digit is less than 10, then
  4785. * <code>'0' + digit</code> is returned. Otherwise, the value
  4786. * <code>'a' + digit - 10</code> is returned.
  4787. *
  4788. * @param digit the number to convert to a character.
  4789. * @param radix the radix.
  4790. * @return the <code>char</code> representation of the specified digit
  4791. * in the specified radix.
  4792. * @see java.lang.Character#MIN_RADIX
  4793. * @see java.lang.Character#MAX_RADIX
  4794. * @see java.lang.Character#digit(char, int)
  4795. */
  4796. public static char forDigit(int digit, int radix) {
  4797. if ((digit >= radix) || (digit < 0)) {
  4798. return '\0';
  4799. }
  4800. if ((radix < Character.MIN_RADIX) || (radix > Character.MAX_RADIX)) {
  4801. return '\0';
  4802. }
  4803. if (digit < 10) {
  4804. return (char)('0' + digit);
  4805. }
  4806. return (char)('a' - 10 + digit);
  4807. }
  4808. /**
  4809. * Returns the Unicode directionality property for the given
  4810. * character. Character directionality is used to calculate the
  4811. * visual ordering of text. The directionality value of undefined
  4812. * <code>char</code> values is <code>DIRECTIONALITY_UNDEFINED</code>.
  4813. *
  4814. * <p><b>Note:</b> This method cannot handle <a
  4815. * href="#supplementary"> supplementary characters</a>. To support
  4816. * all Unicode characters, including supplementary characters, use
  4817. * the {@link #getDirectionality(int)} method.
  4818. *
  4819. * @param ch <code>char</code> for which the directionality property
  4820. * is requested.
  4821. * @return the directionality property of the <code>char</code> value.
  4822. *
  4823. * @see Character#DIRECTIONALITY_UNDEFINED
  4824. * @see Character#DIRECTIONALITY_LEFT_TO_RIGHT
  4825. * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT
  4826. * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC
  4827. * @see Character#DIRECTIONALITY_EUROPEAN_NUMBER
  4828. * @see Character#DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR
  4829. * @see Character#DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR
  4830. * @see Character#DIRECTIONALITY_ARABIC_NUMBER
  4831. * @see Character#DIRECTIONALITY_COMMON_NUMBER_SEPARATOR
  4832. * @see Character#DIRECTIONALITY_NONSPACING_MARK
  4833. * @see Character#DIRECTIONALITY_BOUNDARY_NEUTRAL
  4834. * @see Character#DIRECTIONALITY_PARAGRAPH_SEPARATOR
  4835. * @see Character#DIRECTIONALITY_SEGMENT_SEPARATOR
  4836. * @see Character#DIRECTIONALITY_WHITESPACE
  4837. * @see Character#DIRECTIONALITY_OTHER_NEUTRALS
  4838. * @see Character#DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING
  4839. * @see Character#DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE
  4840. * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING
  4841. * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE
  4842. * @see Character#DIRECTIONALITY_POP_DIRECTIONAL_FORMAT
  4843. * @since 1.4
  4844. */
  4845. public static byte getDirectionality(char ch) {
  4846. return getDirectionality((int)ch);
  4847. }
  4848. /**
  4849. * Returns the Unicode directionality property for the given
  4850. * character (Unicode code point). Character directionality is
  4851. * used to calculate the visual ordering of text. The
  4852. * directionality value of undefined character is {@link
  4853. * #DIRECTIONALITY_UNDEFINED}.
  4854. *
  4855. * @param codePoint the character (Unicode code point) for which
  4856. * the directionality property * is requested.
  4857. * @return the directionality property of the character.
  4858. *
  4859. * @see Character#DIRECTIONALITY_UNDEFINED DIRECTIONALITY_UNDEFINED
  4860. * @see Character#DIRECTIONALITY_LEFT_TO_RIGHT DIRECTIONALITY_LEFT_TO_RIGHT
  4861. * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT DIRECTIONALITY_RIGHT_TO_LEFT
  4862. * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC
  4863. * @see Character#DIRECTIONALITY_EUROPEAN_NUMBER DIRECTIONALITY_EUROPEAN_NUMBER
  4864. * @see Character#DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR
  4865. * @see Character#DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR
  4866. * @see Character#DIRECTIONALITY_ARABIC_NUMBER DIRECTIONALITY_ARABIC_NUMBER
  4867. * @see Character#DIRECTIONALITY_COMMON_NUMBER_SEPARATOR DIRECTIONALITY_COMMON_NUMBER_SEPARATOR
  4868. * @see Character#DIRECTIONALITY_NONSPACING_MARK DIRECTIONALITY_NONSPACING_MARK
  4869. * @see Character#DIRECTIONALITY_BOUNDARY_NEUTRAL DIRECTIONALITY_BOUNDARY_NEUTRAL
  4870. * @see Character#DIRECTIONALITY_PARAGRAPH_SEPARATOR DIRECTIONALITY_PARAGRAPH_SEPARATOR
  4871. * @see Character#DIRECTIONALITY_SEGMENT_SEPARATOR DIRECTIONALITY_SEGMENT_SEPARATOR
  4872. * @see Character#DIRECTIONALITY_WHITESPACE DIRECTIONALITY_WHITESPACE
  4873. * @see Character#DIRECTIONALITY_OTHER_NEUTRALS DIRECTIONALITY_OTHER_NEUTRALS
  4874. * @see Character#DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING
  4875. * @see Character#DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE
  4876. * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING
  4877. * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE
  4878. * @see Character#DIRECTIONALITY_POP_DIRECTIONAL_FORMAT DIRECTIONALITY_POP_DIRECTIONAL_FORMAT
  4879. * @since 1.5
  4880. */
  4881. public static byte getDirectionality(int codePoint) {
  4882. byte directionality = Character.DIRECTIONALITY_UNDEFINED;
  4883. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  4884. directionality = CharacterDataLatin1.getDirectionality(codePoint);
  4885. } else {
  4886. int plane = getPlane(codePoint);
  4887. switch(plane) {
  4888. case(0):
  4889. directionality = CharacterData00.getDirectionality(codePoint);
  4890. break;
  4891. case(1):
  4892. directionality = CharacterData01.getDirectionality(codePoint);
  4893. break;
  4894. case(2):
  4895. directionality = CharacterData02.getDirectionality(codePoint);
  4896. break;
  4897. case(3): // Undefined
  4898. case(4): // Undefined
  4899. case(5): // Undefined
  4900. case(6): // Undefined
  4901. case(7): // Undefined
  4902. case(8): // Undefined
  4903. case(9): // Undefined
  4904. case(10): // Undefined
  4905. case(11): // Undefined
  4906. case(12): // Undefined
  4907. case(13): // Undefined
  4908. directionality = CharacterDataUndefined.getDirectionality(codePoint);
  4909. break;
  4910. case(14):
  4911. directionality = CharacterData0E.getDirectionality(codePoint);
  4912. break;
  4913. case(15): // Private Use
  4914. case(16): // Private Use
  4915. directionality = CharacterDataPrivateUse.getDirectionality(codePoint);
  4916. break;
  4917. default:
  4918. // the argument's plane is invalid, and thus is an invalid codepoint
  4919. // directionality remains DIRECTIONALITY_UNDEFINED
  4920. break;
  4921. }
  4922. }
  4923. return directionality;
  4924. }
  4925. /**
  4926. * Determines whether the character is mirrored according to the
  4927. * Unicode specification. Mirrored characters should have their
  4928. * glyphs horizontally mirrored when displayed in text that is
  4929. * right-to-left. For example, <code>'\u0028'</code> LEFT
  4930. * PARENTHESIS is semantically defined to be an <i>opening
  4931. * parenthesis</i>. This will appear as a "(" in text that is
  4932. * left-to-right but as a ")" in text that is right-to-left.
  4933. *
  4934. * <p><b>Note:</b> This method cannot handle <a
  4935. * href="#supplementary"> supplementary characters</a>. To support
  4936. * all Unicode characters, including supplementary characters, use
  4937. * the {@link #isMirrored(int)} method.
  4938. *
  4939. * @param ch <code>char</code> for which the mirrored property is requested
  4940. * @return <code>true</code> if the char is mirrored, <code>false</code>
  4941. * if the <code>char</code> is not mirrored or is not defined.
  4942. * @since 1.4
  4943. */
  4944. public static boolean isMirrored(char ch) {
  4945. return isMirrored((int)ch);
  4946. }
  4947. /**
  4948. * Determines whether the specified character (Unicode code point)
  4949. * is mirrored according to the Unicode specification. Mirrored
  4950. * characters should have their glyphs horizontally mirrored when
  4951. * displayed in text that is right-to-left. For example,
  4952. * <code>'\u0028'</code> LEFT PARENTHESIS is semantically
  4953. * defined to be an <i>opening parenthesis</i>. This will appear
  4954. * as a "(" in text that is left-to-right but as a ")" in text
  4955. * that is right-to-left.
  4956. *
  4957. * @param codePoint the character (Unicode code point) to be tested.
  4958. * @return <code>true</code> if the character is mirrored, <code>false</code>
  4959. * if the character is not mirrored or is not defined.
  4960. * @since 1.5
  4961. */
  4962. public static boolean isMirrored(int codePoint) {
  4963. boolean bMirrored = false;
  4964. if (codePoint >= MIN_CODE_POINT && codePoint <= FAST_PATH_MAX) {
  4965. bMirrored = CharacterDataLatin1.isMirrored(codePoint);
  4966. } else {
  4967. int plane = getPlane(codePoint);
  4968. switch(plane) {
  4969. case(0):
  4970. bMirrored = CharacterData00.isMirrored(codePoint);
  4971. break;
  4972. case(1):
  4973. bMirrored = CharacterData01.isMirrored(codePoint);
  4974. break;
  4975. case(2):
  4976. bMirrored = CharacterData02.isMirrored(codePoint);
  4977. break;
  4978. case(3): // Undefined
  4979. case(4): // Undefined
  4980. case(5): // Undefined
  4981. case(6): // Undefined
  4982. case(7): // Undefined
  4983. case(8): // Undefined
  4984. case(9): // Undefined
  4985. case(10): // Undefined
  4986. case(11): // Undefined
  4987. case(12): // Undefined
  4988. case(13): // Undefined
  4989. bMirrored = CharacterDataUndefined.isMirrored(codePoint);
  4990. break;
  4991. case(14):
  4992. bMirrored = CharacterData0E.isMirrored(codePoint);
  4993. break;
  4994. case(15): // Private Use
  4995. case(16): // Private Use
  4996. bMirrored = CharacterDataPrivateUse.isMirrored(codePoint);
  4997. break;
  4998. default:
  4999. // the argument's plane is invalid, and thus is an invalid codepoint
  5000. // bMirrored remains false
  5001. break;
  5002. }
  5003. }
  5004. return bMirrored;
  5005. }
  5006. /**
  5007. * Compares two <code>Character</code> objects numerically.
  5008. *
  5009. * @param anotherCharacter the <code>Character</code> to be compared.
  5010. * @return the value <code>0</code> if the argument <code>Character</code>
  5011. * is equal to this <code>Character</code> a value less than
  5012. * <code>0</code> if this <code>Character</code> is numerically less
  5013. * than the <code>Character</code> argument; and a value greater than
  5014. * <code>0</code> if this <code>Character</code> is numerically greater
  5015. * than the <code>Character</code> argument (unsigned comparison).
  5016. * Note that this is strictly a numerical comparison; it is not
  5017. * locale-dependent.
  5018. * @since 1.2
  5019. */
  5020. public int compareTo(Character anotherCharacter) {
  5021. return this.value - anotherCharacter.value;
  5022. }
  5023. /**
  5024. * Converts the character (Unicode code point) argument to uppercase using
  5025. * information from the UnicodeData file.
  5026. * <p>
  5027. *
  5028. * @param codePoint the character (Unicode code point) to be converted.
  5029. * @return either the uppercase equivalent of the character, if
  5030. * any, or an error flag (<code>Character.CHAR_ERROR</code>)
  5031. * that indicates that a 1:M <code>char</code> mapping exists.
  5032. * @see java.lang.Character#isLowerCase(char)
  5033. * @see java.lang.Character#isUpperCase(char)
  5034. * @see java.lang.Character#toLowerCase(char)
  5035. * @see java.lang.Character#toTitleCase(char)
  5036. * @since 1.4
  5037. */
  5038. static int toUpperCaseEx(int codePoint) {
  5039. int upperCase = codePoint;
  5040. int plane = 0;
  5041. assert isValidCodePoint(codePoint);
  5042. if (codePoint <= FAST_PATH_MAX) {
  5043. upperCase = CharacterDataLatin1.toUpperCaseEx(codePoint);
  5044. } else {
  5045. plane = getPlane(codePoint);
  5046. switch(plane) {
  5047. case(0):
  5048. upperCase = CharacterData00.toUpperCaseEx(codePoint);
  5049. break;
  5050. case(1):
  5051. upperCase = CharacterData01.toUpperCase(codePoint);
  5052. break;
  5053. case(2):
  5054. upperCase = CharacterData02.toUpperCase(codePoint);
  5055. break;
  5056. case(3): // Undefined
  5057. case(4): // Undefined
  5058. case(5): // Undefined
  5059. case(6): // Undefined
  5060. case(7): // Undefined
  5061. case(8): // Undefined
  5062. case(9): // Undefined
  5063. case(10): // Undefined
  5064. case(11): // Undefined
  5065. case(12): // Undefined
  5066. case(13): // Undefined
  5067. upperCase = CharacterDataUndefined.toUpperCase(codePoint);
  5068. break;
  5069. case(14):
  5070. upperCase = CharacterData0E.toUpperCase(codePoint);
  5071. break;
  5072. case(15): // Private Use
  5073. case(16): // Private Use
  5074. upperCase = CharacterDataPrivateUse.toUpperCase(codePoint);
  5075. break;
  5076. default:
  5077. // the argument's plane is invalid, and thus is an invalid codepoint
  5078. // upperCase remains codePoint;
  5079. break;
  5080. }
  5081. }
  5082. return upperCase;
  5083. }
  5084. /**
  5085. * Converts the character (Unicode code point) argument to uppercase using case
  5086. * mapping information from the SpecialCasing file in the Unicode
  5087. * specification. If a character has no explicit uppercase
  5088. * mapping, then the <code>char</code> itself is returned in the
  5089. * <code>char[]</code>.
  5090. *
  5091. * @param codePoint the character (Unicode code point) to be converted.
  5092. * @return a <code>char[]</code> with the uppercased character.
  5093. * @since 1.4
  5094. */
  5095. static char[] toUpperCaseCharArray(int codePoint) {
  5096. char[] upperCase = null;
  5097. // As of Unicode 4.0, 1:M uppercasings only happen in the BMP.
  5098. assert isValidCodePoint(codePoint) &&
  5099. !isSupplementaryCodePoint(codePoint);
  5100. if (codePoint <= FAST_PATH_MAX) {
  5101. upperCase = CharacterDataLatin1.toUpperCaseCharArray(codePoint);
  5102. } else {
  5103. upperCase = CharacterData00.toUpperCaseCharArray(codePoint);
  5104. }
  5105. return upperCase;
  5106. }
  5107. /**
  5108. * The number of bits used to represent a <tt>char</tt> value in unsigned
  5109. * binary form.
  5110. *
  5111. * @since 1.5
  5112. */
  5113. public static final int SIZE = 16;
  5114. /**
  5115. * Returns the value obtained by reversing the order of the bytes in the
  5116. * specified <tt>char</tt> value.
  5117. *
  5118. * @return the value obtained by reversing (or, equivalently, swapping)
  5119. * the bytes in the specified <tt>char</tt> value.
  5120. * @since 1.5
  5121. */
  5122. public static char reverseBytes(char ch) {
  5123. return (char) (((ch & 0xFF00) >> 8) | (ch << 8));
  5124. }
  5125. }