373 /**
374 * Undefined bidirectional character type. Undefined {@code char}
375 * values have undefined directionality in the Unicode specification.
376 * @since 1.4
377 */
378 public static final byte DIRECTIONALITY_UNDEFINED = -1;
379
380 /**
381 * Strong bidirectional character type "L" in the Unicode specification.
382 * @since 1.4
383 */
384 public static final byte DIRECTIONALITY_LEFT_TO_RIGHT = 0;
385
386 /**
387 * Strong bidirectional character type "R" in the Unicode specification.
388 * @since 1.4
389 */
390 public static final byte DIRECTIONALITY_RIGHT_TO_LEFT = 1;
391
392 /**
393 * Strong bidirectional character type "AL" in the Unicode specification.
394 * @since 1.4
395 */
396 public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = 2;
397
398 /**
399 * Weak bidirectional character type "EN" in the Unicode specification.
400 * @since 1.4
401 */
402 public static final byte DIRECTIONALITY_EUROPEAN_NUMBER = 3;
403
404 /**
405 * Weak bidirectional character type "ES" in the Unicode specification.
406 * @since 1.4
407 */
408 public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = 4;
409
410 /**
411 * Weak bidirectional character type "ET" in the Unicode specification.
412 * @since 1.4
413 */
3164 new UnicodeBlock("MAKASAR");
3165
3166 /**
3167 * Constant for the "Medefaidrin" Unicode
3168 * character block.
3169 * @since 12
3170 */
3171 public static final UnicodeBlock MEDEFAIDRIN =
3172 new UnicodeBlock("MEDEFAIDRIN");
3173
3174 /**
3175 * Constant for the "Mayan Numerals" Unicode
3176 * character block.
3177 * @since 12
3178 */
3179 public static final UnicodeBlock MAYAN_NUMERALS =
3180 new UnicodeBlock("MAYAN_NUMERALS",
3181 "MAYAN NUMERALS",
3182 "MAYANNUMERALS");
3183
3184 /**
3185 * Constant for the "Indic Siyaq Numbers" Unicode
3186 * character block.
3187 * @since 12
3188 */
3189 public static final UnicodeBlock INDIC_SIYAQ_NUMBERS =
3190 new UnicodeBlock("INDIC_SIYAQ_NUMBERS",
3191 "INDIC SIYAQ NUMBERS",
3192 "INDICSIYAQNUMBERS");
3193
3194 /**
3195 * Constant for the "Chess Symbols" Unicode
3196 * character block.
3197 * @since 12
3198 */
3199 public static final UnicodeBlock CHESS_SYMBOLS =
3200 new UnicodeBlock("CHESS_SYMBOLS",
3201 "CHESS SYMBOLS",
3202 "CHESSSYMBOLS");
3203
3204 /**
4756 SIDDHAM,
4757
4758 /**
4759 * Unicode script "Khudawadi".
4760 * @since 9
4761 */
4762 KHUDAWADI,
4763
4764 /**
4765 * Unicode script "Tirhuta".
4766 * @since 9
4767 */
4768 TIRHUTA,
4769
4770 /**
4771 * Unicode script "Warang Citi".
4772 * @since 9
4773 */
4774 WARANG_CITI,
4775
4776 /**
4777 * Unicode script "Ahom".
4778 * @since 9
4779 */
4780 AHOM,
4781
4782 /**
4783 * Unicode script "Anatolian Hieroglyphs".
4784 * @since 9
4785 */
4786 ANATOLIAN_HIEROGLYPHS,
4787
4788 /**
4789 * Unicode script "Hatran".
4790 * @since 9
4791 */
4792 HATRAN,
4793
4794 /**
4795 * Unicode script "Multani".
4796 * @since 9
8573 * <p>A char value is a surrogate code unit if and only if it is either
8574 * a {@linkplain #isLowSurrogate(char) low-surrogate code unit} or
8575 * a {@linkplain #isHighSurrogate(char) high-surrogate code unit}.
8576 *
8577 * @param ch the {@code char} value to be tested.
8578 * @return {@code true} if the {@code char} value is between
8579 * {@link #MIN_SURROGATE} and
8580 * {@link #MAX_SURROGATE} inclusive;
8581 * {@code false} otherwise.
8582 * @since 1.7
8583 */
8584 public static boolean isSurrogate(char ch) {
8585 return ch >= MIN_SURROGATE && ch < (MAX_SURROGATE + 1);
8586 }
8587
8588 /**
8589 * Determines whether the specified pair of {@code char}
8590 * values is a valid
8591 * <a href="http://www.unicode.org/glossary/#surrogate_pair">
8592 * Unicode surrogate pair</a>.
8593
8594 * <p>This method is equivalent to the expression:
8595 * <blockquote><pre>{@code
8596 * isHighSurrogate(high) && isLowSurrogate(low)
8597 * }</pre></blockquote>
8598 *
8599 * @param high the high-surrogate code value to be tested
8600 * @param low the low-surrogate code value to be tested
8601 * @return {@code true} if the specified high and
8602 * low-surrogate code values represent a valid surrogate pair;
8603 * {@code false} otherwise.
8604 * @since 1.5
8605 */
8606 public static boolean isSurrogatePair(char high, char low) {
8607 return isHighSurrogate(high) && isLowSurrogate(low);
8608 }
8609
8610 /**
8611 * Determines the number of {@code char} values needed to
8612 * represent the specified character (Unicode code point). If the
8613 * specified character is equal to or greater than 0x10000, then
10950 * characters should have their glyphs horizontally mirrored when
10951 * displayed in text that is right-to-left. For example,
10952 * {@code '\u005Cu0028'} LEFT PARENTHESIS is semantically
10953 * defined to be an <i>opening parenthesis</i>. This will appear
10954 * as a "(" in text that is left-to-right but as a ")" in text
10955 * that is right-to-left.
10956 *
10957 * @param codePoint the character (Unicode code point) to be tested.
10958 * @return {@code true} if the character is mirrored, {@code false}
10959 * if the character is not mirrored or is not defined.
10960 * @since 1.5
10961 */
10962 public static boolean isMirrored(int codePoint) {
10963 return CharacterData.of(codePoint).isMirrored(codePoint);
10964 }
10965
10966 /**
10967 * Compares two {@code Character} objects numerically.
10968 *
10969 * @param anotherCharacter the {@code Character} to be compared.
10970
10971 * @return the value {@code 0} if the argument {@code Character}
10972 * is equal to this {@code Character}; a value less than
10973 * {@code 0} if this {@code Character} is numerically less
10974 * than the {@code Character} argument; and a value greater than
10975 * {@code 0} if this {@code Character} is numerically greater
10976 * than the {@code Character} argument (unsigned comparison).
10977 * Note that this is strictly a numerical comparison; it is not
10978 * locale-dependent.
10979 * @since 1.2
10980 */
10981 public int compareTo(Character anotherCharacter) {
10982 return compare(this.value, anotherCharacter.value);
10983 }
10984
10985 /**
10986 * Compares two {@code char} values numerically.
10987 * The value returned is identical to what would be returned by:
10988 * <pre>
10989 * Character.valueOf(x).compareTo(Character.valueOf(y))
10990 * </pre>
|
373 /**
374 * Undefined bidirectional character type. Undefined {@code char}
375 * values have undefined directionality in the Unicode specification.
376 * @since 1.4
377 */
378 public static final byte DIRECTIONALITY_UNDEFINED = -1;
379
380 /**
381 * Strong bidirectional character type "L" in the Unicode specification.
382 * @since 1.4
383 */
384 public static final byte DIRECTIONALITY_LEFT_TO_RIGHT = 0;
385
386 /**
387 * Strong bidirectional character type "R" in the Unicode specification.
388 * @since 1.4
389 */
390 public static final byte DIRECTIONALITY_RIGHT_TO_LEFT = 1;
391
392 /**
393 * Strong bidirectional character type "AL" in the Unicode specification.
394 * @since 1.4
395 */
396 public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = 2;
397
398 /**
399 * Weak bidirectional character type "EN" in the Unicode specification.
400 * @since 1.4
401 */
402 public static final byte DIRECTIONALITY_EUROPEAN_NUMBER = 3;
403
404 /**
405 * Weak bidirectional character type "ES" in the Unicode specification.
406 * @since 1.4
407 */
408 public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = 4;
409
410 /**
411 * Weak bidirectional character type "ET" in the Unicode specification.
412 * @since 1.4
413 */
3164 new UnicodeBlock("MAKASAR");
3165
3166 /**
3167 * Constant for the "Medefaidrin" Unicode
3168 * character block.
3169 * @since 12
3170 */
3171 public static final UnicodeBlock MEDEFAIDRIN =
3172 new UnicodeBlock("MEDEFAIDRIN");
3173
3174 /**
3175 * Constant for the "Mayan Numerals" Unicode
3176 * character block.
3177 * @since 12
3178 */
3179 public static final UnicodeBlock MAYAN_NUMERALS =
3180 new UnicodeBlock("MAYAN_NUMERALS",
3181 "MAYAN NUMERALS",
3182 "MAYANNUMERALS");
3183
3184 /**
3185 * Constant for the "Indic Siyaq Numbers" Unicode
3186 * character block.
3187 * @since 12
3188 */
3189 public static final UnicodeBlock INDIC_SIYAQ_NUMBERS =
3190 new UnicodeBlock("INDIC_SIYAQ_NUMBERS",
3191 "INDIC SIYAQ NUMBERS",
3192 "INDICSIYAQNUMBERS");
3193
3194 /**
3195 * Constant for the "Chess Symbols" Unicode
3196 * character block.
3197 * @since 12
3198 */
3199 public static final UnicodeBlock CHESS_SYMBOLS =
3200 new UnicodeBlock("CHESS_SYMBOLS",
3201 "CHESS SYMBOLS",
3202 "CHESSSYMBOLS");
3203
3204 /**
4756 SIDDHAM,
4757
4758 /**
4759 * Unicode script "Khudawadi".
4760 * @since 9
4761 */
4762 KHUDAWADI,
4763
4764 /**
4765 * Unicode script "Tirhuta".
4766 * @since 9
4767 */
4768 TIRHUTA,
4769
4770 /**
4771 * Unicode script "Warang Citi".
4772 * @since 9
4773 */
4774 WARANG_CITI,
4775
4776 /**
4777 * Unicode script "Ahom".
4778 * @since 9
4779 */
4780 AHOM,
4781
4782 /**
4783 * Unicode script "Anatolian Hieroglyphs".
4784 * @since 9
4785 */
4786 ANATOLIAN_HIEROGLYPHS,
4787
4788 /**
4789 * Unicode script "Hatran".
4790 * @since 9
4791 */
4792 HATRAN,
4793
4794 /**
4795 * Unicode script "Multani".
4796 * @since 9
8573 * <p>A char value is a surrogate code unit if and only if it is either
8574 * a {@linkplain #isLowSurrogate(char) low-surrogate code unit} or
8575 * a {@linkplain #isHighSurrogate(char) high-surrogate code unit}.
8576 *
8577 * @param ch the {@code char} value to be tested.
8578 * @return {@code true} if the {@code char} value is between
8579 * {@link #MIN_SURROGATE} and
8580 * {@link #MAX_SURROGATE} inclusive;
8581 * {@code false} otherwise.
8582 * @since 1.7
8583 */
8584 public static boolean isSurrogate(char ch) {
8585 return ch >= MIN_SURROGATE && ch < (MAX_SURROGATE + 1);
8586 }
8587
8588 /**
8589 * Determines whether the specified pair of {@code char}
8590 * values is a valid
8591 * <a href="http://www.unicode.org/glossary/#surrogate_pair">
8592 * Unicode surrogate pair</a>.
8593 *
8594 * <p>This method is equivalent to the expression:
8595 * <blockquote><pre>{@code
8596 * isHighSurrogate(high) && isLowSurrogate(low)
8597 * }</pre></blockquote>
8598 *
8599 * @param high the high-surrogate code value to be tested
8600 * @param low the low-surrogate code value to be tested
8601 * @return {@code true} if the specified high and
8602 * low-surrogate code values represent a valid surrogate pair;
8603 * {@code false} otherwise.
8604 * @since 1.5
8605 */
8606 public static boolean isSurrogatePair(char high, char low) {
8607 return isHighSurrogate(high) && isLowSurrogate(low);
8608 }
8609
8610 /**
8611 * Determines the number of {@code char} values needed to
8612 * represent the specified character (Unicode code point). If the
8613 * specified character is equal to or greater than 0x10000, then
10950 * characters should have their glyphs horizontally mirrored when
10951 * displayed in text that is right-to-left. For example,
10952 * {@code '\u005Cu0028'} LEFT PARENTHESIS is semantically
10953 * defined to be an <i>opening parenthesis</i>. This will appear
10954 * as a "(" in text that is left-to-right but as a ")" in text
10955 * that is right-to-left.
10956 *
10957 * @param codePoint the character (Unicode code point) to be tested.
10958 * @return {@code true} if the character is mirrored, {@code false}
10959 * if the character is not mirrored or is not defined.
10960 * @since 1.5
10961 */
10962 public static boolean isMirrored(int codePoint) {
10963 return CharacterData.of(codePoint).isMirrored(codePoint);
10964 }
10965
10966 /**
10967 * Compares two {@code Character} objects numerically.
10968 *
10969 * @param anotherCharacter the {@code Character} to be compared.
10970 * @return the value {@code 0} if the argument {@code Character}
10971 * is equal to this {@code Character}; a value less than
10972 * {@code 0} if this {@code Character} is numerically less
10973 * than the {@code Character} argument; and a value greater than
10974 * {@code 0} if this {@code Character} is numerically greater
10975 * than the {@code Character} argument (unsigned comparison).
10976 * Note that this is strictly a numerical comparison; it is not
10977 * locale-dependent.
10978 * @since 1.2
10979 */
10980 public int compareTo(Character anotherCharacter) {
10981 return compare(this.value, anotherCharacter.value);
10982 }
10983
10984 /**
10985 * Compares two {@code char} values numerically.
10986 * The value returned is identical to what would be returned by:
10987 * <pre>
10988 * Character.valueOf(x).compareTo(Character.valueOf(y))
10989 * </pre>
|