1239 "ARABICPRESENTATIONFORMS-B");
1240
1241 /**
1242 * Constant for the "Halfwidth and Fullwidth Forms" Unicode character
1243 * block.
1244 * @since 1.2
1245 */
1246 public static final UnicodeBlock HALFWIDTH_AND_FULLWIDTH_FORMS =
1247 new UnicodeBlock("HALFWIDTH_AND_FULLWIDTH_FORMS",
1248 "HALFWIDTH AND FULLWIDTH FORMS",
1249 "HALFWIDTHANDFULLWIDTHFORMS");
1250
1251 /**
1252 * Constant for the "Specials" Unicode character block.
1253 * @since 1.2
1254 */
1255 public static final UnicodeBlock SPECIALS =
1256 new UnicodeBlock("SPECIALS");
1257
1258 /**
1259 * @deprecated As of J2SE 5, use {@link #HIGH_SURROGATES},
1260 * {@link #HIGH_PRIVATE_USE_SURROGATES}, and
1261 * {@link #LOW_SURROGATES}. These new constants match
1262 * the block definitions of the Unicode Standard.
1263 * The {@link #of(char)} and {@link #of(int)} methods
1264 * return the new constants, not SURROGATES_AREA.
1265 */
1266 @Deprecated
1267 public static final UnicodeBlock SURROGATES_AREA =
1268 new UnicodeBlock("SURROGATES_AREA");
1269
1270 /**
1271 * Constant for the "Syriac" Unicode character block.
1272 * @since 1.4
1273 */
1274 public static final UnicodeBlock SYRIAC =
1275 new UnicodeBlock("SYRIAC");
1276
1277 /**
1278 * Constant for the "Thaana" Unicode character block.
1279 * @since 1.4
1280 */
1281 public static final UnicodeBlock THAANA =
1282 new UnicodeBlock("THAANA");
1283
1284 /**
1285 * Constant for the "Sinhala" Unicode character block.
1286 * @since 1.4
7434 return valueOf(scriptName);
7435 }
7436 }
7437
7438 /**
7439 * The value of the {@code Character}.
7440 *
7441 * @serial
7442 */
7443 private final char value;
7444
7445 /** use serialVersionUID from JDK 1.0.2 for interoperability */
7446 private static final long serialVersionUID = 3786198910865385080L;
7447
7448 /**
7449 * Constructs a newly allocated {@code Character} object that
7450 * represents the specified {@code char} value.
7451 *
7452 * @param value the value to be represented by the
7453 * {@code Character} object.
7454 */
7455 public Character(char value) {
7456 this.value = value;
7457 }
7458
7459 private static class CharacterCache {
7460 private CharacterCache(){}
7461
7462 static final Character cache[] = new Character[127 + 1];
7463
7464 static {
7465 for (int i = 0; i < cache.length; i++)
7466 cache[i] = new Character((char)i);
7467 }
7468 }
7469
7470 /**
7471 * Returns a {@code Character} instance representing the specified
7472 * {@code char} value.
7473 * If a new {@code Character} instance is not required, this method
7474 * should generally be used in preference to the constructor
8782 * one of the following is true:
8783 * <ul>
8784 * <li> {@link #isLetter(char) isLetter(ch)} returns {@code true}
8785 * <li> {@link #getType(char) getType(ch)} returns {@code LETTER_NUMBER}
8786 * <li> {@code ch} is a currency symbol (such as {@code '$'})
8787 * <li> {@code ch} is a connecting punctuation character (such as {@code '_'}).
8788 * </ul>
8789 *
8790 * @param ch the character to be tested.
8791 * @return {@code true} if the character may start a Java
8792 * identifier; {@code false} otherwise.
8793 * @see Character#isJavaLetterOrDigit(char)
8794 * @see Character#isJavaIdentifierStart(char)
8795 * @see Character#isJavaIdentifierPart(char)
8796 * @see Character#isLetter(char)
8797 * @see Character#isLetterOrDigit(char)
8798 * @see Character#isUnicodeIdentifierStart(char)
8799 * @since 1.0.2
8800 * @deprecated Replaced by isJavaIdentifierStart(char).
8801 */
8802 @Deprecated
8803 public static boolean isJavaLetter(char ch) {
8804 return isJavaIdentifierStart(ch);
8805 }
8806
8807 /**
8808 * Determines if the specified character may be part of a Java
8809 * identifier as other than the first character.
8810 * <p>
8811 * A character may be part of a Java identifier if and only if any
8812 * of the following are true:
8813 * <ul>
8814 * <li> it is a letter
8815 * <li> it is a currency symbol (such as {@code '$'})
8816 * <li> it is a connecting punctuation character (such as {@code '_'})
8817 * <li> it is a digit
8818 * <li> it is a numeric letter (such as a Roman numeral character)
8819 * <li> it is a combining mark
8820 * <li> it is a non-spacing mark
8821 * <li> {@code isIdentifierIgnorable} returns
8822 * {@code true} for the character.
8823 * </ul>
8824 *
8825 * @param ch the character to be tested.
8826 * @return {@code true} if the character may be part of a
8827 * Java identifier; {@code false} otherwise.
8828 * @see Character#isJavaLetter(char)
8829 * @see Character#isJavaIdentifierStart(char)
8830 * @see Character#isJavaIdentifierPart(char)
8831 * @see Character#isLetter(char)
8832 * @see Character#isLetterOrDigit(char)
8833 * @see Character#isUnicodeIdentifierPart(char)
8834 * @see Character#isIdentifierIgnorable(char)
8835 * @since 1.0.2
8836 * @deprecated Replaced by isJavaIdentifierPart(char).
8837 */
8838 @Deprecated
8839 public static boolean isJavaLetterOrDigit(char ch) {
8840 return isJavaIdentifierPart(ch);
8841 }
8842
8843 /**
8844 * Determines if the specified character (Unicode code point) is an alphabet.
8845 * <p>
8846 * A character is considered to be alphabetic if its general category type,
8847 * provided by {@link Character#getType(int) getType(codePoint)}, is any of
8848 * the following:
8849 * <ul>
8850 * <li> <code>UPPERCASE_LETTER</code>
8851 * <li> <code>LOWERCASE_LETTER</code>
8852 * <li> <code>TITLECASE_LETTER</code>
8853 * <li> <code>MODIFIER_LETTER</code>
8854 * <li> <code>OTHER_LETTER</code>
8855 * <li> <code>LETTER_NUMBER</code>
8856 * </ul>
8857 * or it has contributory property Other_Alphabetic as defined by the
8858 * Unicode Standard.
9563 * <table summary="truechars">
9564 * <tr><td>{@code '\t'}</td> <td>{@code U+0009}</td>
9565 * <td>{@code HORIZONTAL TABULATION}</td></tr>
9566 * <tr><td>{@code '\n'}</td> <td>{@code U+000A}</td>
9567 * <td>{@code NEW LINE}</td></tr>
9568 * <tr><td>{@code '\f'}</td> <td>{@code U+000C}</td>
9569 * <td>{@code FORM FEED}</td></tr>
9570 * <tr><td>{@code '\r'}</td> <td>{@code U+000D}</td>
9571 * <td>{@code CARRIAGE RETURN}</td></tr>
9572 * <tr><td>{@code ' '}</td> <td>{@code U+0020}</td>
9573 * <td>{@code SPACE}</td></tr>
9574 * </table>
9575 *
9576 * @param ch the character to be tested.
9577 * @return {@code true} if the character is ISO-LATIN-1 white
9578 * space; {@code false} otherwise.
9579 * @see Character#isSpaceChar(char)
9580 * @see Character#isWhitespace(char)
9581 * @deprecated Replaced by isWhitespace(char).
9582 */
9583 @Deprecated
9584 public static boolean isSpace(char ch) {
9585 return (ch <= 0x0020) &&
9586 (((((1L << 0x0009) |
9587 (1L << 0x000A) |
9588 (1L << 0x000C) |
9589 (1L << 0x000D) |
9590 (1L << 0x0020)) >> ch) & 1L) != 0);
9591 }
9592
9593
9594 /**
9595 * Determines if the specified character is a Unicode space character.
9596 * A character is considered to be a space character if and only if
9597 * it is specified to be a space character by the Unicode Standard. This
9598 * method returns true if the character's general category type is any of
9599 * the following:
9600 * <ul>
9601 * <li> {@code SPACE_SEPARATOR}
9602 * <li> {@code LINE_SEPARATOR}
9603 * <li> {@code PARAGRAPH_SEPARATOR}
|
1239 "ARABICPRESENTATIONFORMS-B");
1240
1241 /**
1242 * Constant for the "Halfwidth and Fullwidth Forms" Unicode character
1243 * block.
1244 * @since 1.2
1245 */
1246 public static final UnicodeBlock HALFWIDTH_AND_FULLWIDTH_FORMS =
1247 new UnicodeBlock("HALFWIDTH_AND_FULLWIDTH_FORMS",
1248 "HALFWIDTH AND FULLWIDTH FORMS",
1249 "HALFWIDTHANDFULLWIDTHFORMS");
1250
1251 /**
1252 * Constant for the "Specials" Unicode character block.
1253 * @since 1.2
1254 */
1255 public static final UnicodeBlock SPECIALS =
1256 new UnicodeBlock("SPECIALS");
1257
1258 /**
1259 * @deprecated
1260 * Instead of {@code SURROGATES_AREA}, use {@link #HIGH_SURROGATES},
1261 * {@link #HIGH_PRIVATE_USE_SURROGATES}, and {@link #LOW_SURROGATES}.
1262 * These constants match the block definitions of the Unicode Standard.
1263 * The {@link #of(char)} and {@link #of(int)} methods return the
1264 * standard constants.
1265 */
1266 @Deprecated(since="1.5")
1267 public static final UnicodeBlock SURROGATES_AREA =
1268 new UnicodeBlock("SURROGATES_AREA");
1269
1270 /**
1271 * Constant for the "Syriac" Unicode character block.
1272 * @since 1.4
1273 */
1274 public static final UnicodeBlock SYRIAC =
1275 new UnicodeBlock("SYRIAC");
1276
1277 /**
1278 * Constant for the "Thaana" Unicode character block.
1279 * @since 1.4
1280 */
1281 public static final UnicodeBlock THAANA =
1282 new UnicodeBlock("THAANA");
1283
1284 /**
1285 * Constant for the "Sinhala" Unicode character block.
1286 * @since 1.4
7434 return valueOf(scriptName);
7435 }
7436 }
7437
7438 /**
7439 * The value of the {@code Character}.
7440 *
7441 * @serial
7442 */
7443 private final char value;
7444
7445 /** use serialVersionUID from JDK 1.0.2 for interoperability */
7446 private static final long serialVersionUID = 3786198910865385080L;
7447
7448 /**
7449 * Constructs a newly allocated {@code Character} object that
7450 * represents the specified {@code char} value.
7451 *
7452 * @param value the value to be represented by the
7453 * {@code Character} object.
7454 *
7455 * @deprecated
7456 * It is rarely appropriate to use this constructor. The static factory
7457 * {@link #valueOf(char)} is generally a better choice, as it is
7458 * likely to yield significantly better space and time performance.
7459 */
7460 @Deprecated(since="9")
7461 public Character(char value) {
7462 this.value = value;
7463 }
7464
7465 private static class CharacterCache {
7466 private CharacterCache(){}
7467
7468 static final Character cache[] = new Character[127 + 1];
7469
7470 static {
7471 for (int i = 0; i < cache.length; i++)
7472 cache[i] = new Character((char)i);
7473 }
7474 }
7475
7476 /**
7477 * Returns a {@code Character} instance representing the specified
7478 * {@code char} value.
7479 * If a new {@code Character} instance is not required, this method
7480 * should generally be used in preference to the constructor
8788 * one of the following is true:
8789 * <ul>
8790 * <li> {@link #isLetter(char) isLetter(ch)} returns {@code true}
8791 * <li> {@link #getType(char) getType(ch)} returns {@code LETTER_NUMBER}
8792 * <li> {@code ch} is a currency symbol (such as {@code '$'})
8793 * <li> {@code ch} is a connecting punctuation character (such as {@code '_'}).
8794 * </ul>
8795 *
8796 * @param ch the character to be tested.
8797 * @return {@code true} if the character may start a Java
8798 * identifier; {@code false} otherwise.
8799 * @see Character#isJavaLetterOrDigit(char)
8800 * @see Character#isJavaIdentifierStart(char)
8801 * @see Character#isJavaIdentifierPart(char)
8802 * @see Character#isLetter(char)
8803 * @see Character#isLetterOrDigit(char)
8804 * @see Character#isUnicodeIdentifierStart(char)
8805 * @since 1.0.2
8806 * @deprecated Replaced by isJavaIdentifierStart(char).
8807 */
8808 @Deprecated(since="1.1")
8809 public static boolean isJavaLetter(char ch) {
8810 return isJavaIdentifierStart(ch);
8811 }
8812
8813 /**
8814 * Determines if the specified character may be part of a Java
8815 * identifier as other than the first character.
8816 * <p>
8817 * A character may be part of a Java identifier if and only if any
8818 * of the following are true:
8819 * <ul>
8820 * <li> it is a letter
8821 * <li> it is a currency symbol (such as {@code '$'})
8822 * <li> it is a connecting punctuation character (such as {@code '_'})
8823 * <li> it is a digit
8824 * <li> it is a numeric letter (such as a Roman numeral character)
8825 * <li> it is a combining mark
8826 * <li> it is a non-spacing mark
8827 * <li> {@code isIdentifierIgnorable} returns
8828 * {@code true} for the character.
8829 * </ul>
8830 *
8831 * @param ch the character to be tested.
8832 * @return {@code true} if the character may be part of a
8833 * Java identifier; {@code false} otherwise.
8834 * @see Character#isJavaLetter(char)
8835 * @see Character#isJavaIdentifierStart(char)
8836 * @see Character#isJavaIdentifierPart(char)
8837 * @see Character#isLetter(char)
8838 * @see Character#isLetterOrDigit(char)
8839 * @see Character#isUnicodeIdentifierPart(char)
8840 * @see Character#isIdentifierIgnorable(char)
8841 * @since 1.0.2
8842 * @deprecated Replaced by isJavaIdentifierPart(char).
8843 */
8844 @Deprecated(since="1.1")
8845 public static boolean isJavaLetterOrDigit(char ch) {
8846 return isJavaIdentifierPart(ch);
8847 }
8848
8849 /**
8850 * Determines if the specified character (Unicode code point) is an alphabet.
8851 * <p>
8852 * A character is considered to be alphabetic if its general category type,
8853 * provided by {@link Character#getType(int) getType(codePoint)}, is any of
8854 * the following:
8855 * <ul>
8856 * <li> <code>UPPERCASE_LETTER</code>
8857 * <li> <code>LOWERCASE_LETTER</code>
8858 * <li> <code>TITLECASE_LETTER</code>
8859 * <li> <code>MODIFIER_LETTER</code>
8860 * <li> <code>OTHER_LETTER</code>
8861 * <li> <code>LETTER_NUMBER</code>
8862 * </ul>
8863 * or it has contributory property Other_Alphabetic as defined by the
8864 * Unicode Standard.
9569 * <table summary="truechars">
9570 * <tr><td>{@code '\t'}</td> <td>{@code U+0009}</td>
9571 * <td>{@code HORIZONTAL TABULATION}</td></tr>
9572 * <tr><td>{@code '\n'}</td> <td>{@code U+000A}</td>
9573 * <td>{@code NEW LINE}</td></tr>
9574 * <tr><td>{@code '\f'}</td> <td>{@code U+000C}</td>
9575 * <td>{@code FORM FEED}</td></tr>
9576 * <tr><td>{@code '\r'}</td> <td>{@code U+000D}</td>
9577 * <td>{@code CARRIAGE RETURN}</td></tr>
9578 * <tr><td>{@code ' '}</td> <td>{@code U+0020}</td>
9579 * <td>{@code SPACE}</td></tr>
9580 * </table>
9581 *
9582 * @param ch the character to be tested.
9583 * @return {@code true} if the character is ISO-LATIN-1 white
9584 * space; {@code false} otherwise.
9585 * @see Character#isSpaceChar(char)
9586 * @see Character#isWhitespace(char)
9587 * @deprecated Replaced by isWhitespace(char).
9588 */
9589 @Deprecated(since="1.1")
9590 public static boolean isSpace(char ch) {
9591 return (ch <= 0x0020) &&
9592 (((((1L << 0x0009) |
9593 (1L << 0x000A) |
9594 (1L << 0x000C) |
9595 (1L << 0x000D) |
9596 (1L << 0x0020)) >> ch) & 1L) != 0);
9597 }
9598
9599
9600 /**
9601 * Determines if the specified character is a Unicode space character.
9602 * A character is considered to be a space character if and only if
9603 * it is specified to be a space character by the Unicode Standard. This
9604 * method returns true if the character's general category type is any of
9605 * the following:
9606 * <ul>
9607 * <li> {@code SPACE_SEPARATOR}
9608 * <li> {@code LINE_SEPARATOR}
9609 * <li> {@code PARAGRAPH_SEPARATOR}
|