< prev index next >

src/java.base/share/classes/java/lang/Character.java

Print this page
rev 51516 : 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
Reviewed-by: kvn, rriggs, mdoerr, gromero


8822      * The following are examples of lowercase characters:
8823      * <blockquote><pre>
8824      * 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
8825      * '\u00DF' '\u00E0' '\u00E1' '\u00E2' '\u00E3' '\u00E4' '\u00E5' '\u00E6'
8826      * '\u00E7' '\u00E8' '\u00E9' '\u00EA' '\u00EB' '\u00EC' '\u00ED' '\u00EE'
8827      * '\u00EF' '\u00F0' '\u00F1' '\u00F2' '\u00F3' '\u00F4' '\u00F5' '\u00F6'
8828      * '\u00F8' '\u00F9' '\u00FA' '\u00FB' '\u00FC' '\u00FD' '\u00FE' '\u00FF'
8829      * </pre></blockquote>
8830      * <p> Many other Unicode characters are lowercase too.
8831      *
8832      * @param   codePoint the character (Unicode code point) to be tested.
8833      * @return  {@code true} if the character is lowercase;
8834      *          {@code false} otherwise.
8835      * @see     Character#isLowerCase(int)
8836      * @see     Character#isTitleCase(int)
8837      * @see     Character#toLowerCase(int)
8838      * @see     Character#getType(int)
8839      * @since   1.5
8840      */
8841     public static boolean isLowerCase(int codePoint) {
8842         return getType(codePoint) == Character.LOWERCASE_LETTER ||
8843                CharacterData.of(codePoint).isOtherLowercase(codePoint);
8844     }
8845 
8846     /**
8847      * Determines if the specified character is an uppercase character.
8848      * <p>
8849      * A character is uppercase if its general category type, provided by
8850      * {@code Character.getType(ch)}, is {@code UPPERCASE_LETTER}.
8851      * or it has contributory property Other_Uppercase as defined by the Unicode Standard.
8852      * <p>
8853      * The following are examples of uppercase characters:
8854      * <blockquote><pre>
8855      * 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
8856      * '\u00C0' '\u00C1' '\u00C2' '\u00C3' '\u00C4' '\u00C5' '\u00C6' '\u00C7'
8857      * '\u00C8' '\u00C9' '\u00CA' '\u00CB' '\u00CC' '\u00CD' '\u00CE' '\u00CF'
8858      * '\u00D0' '\u00D1' '\u00D2' '\u00D3' '\u00D4' '\u00D5' '\u00D6' '\u00D8'
8859      * '\u00D9' '\u00DA' '\u00DB' '\u00DC' '\u00DD' '\u00DE'
8860      * </pre></blockquote>
8861      * <p> Many other Unicode characters are uppercase too.
8862      *


8888      * The following are examples of uppercase characters:
8889      * <blockquote><pre>
8890      * 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
8891      * '\u00C0' '\u00C1' '\u00C2' '\u00C3' '\u00C4' '\u00C5' '\u00C6' '\u00C7'
8892      * '\u00C8' '\u00C9' '\u00CA' '\u00CB' '\u00CC' '\u00CD' '\u00CE' '\u00CF'
8893      * '\u00D0' '\u00D1' '\u00D2' '\u00D3' '\u00D4' '\u00D5' '\u00D6' '\u00D8'
8894      * '\u00D9' '\u00DA' '\u00DB' '\u00DC' '\u00DD' '\u00DE'
8895      * </pre></blockquote>
8896      * <p> Many other Unicode characters are uppercase too.
8897      *
8898      * @param   codePoint the character (Unicode code point) to be tested.
8899      * @return  {@code true} if the character is uppercase;
8900      *          {@code false} otherwise.
8901      * @see     Character#isLowerCase(int)
8902      * @see     Character#isTitleCase(int)
8903      * @see     Character#toUpperCase(int)
8904      * @see     Character#getType(int)
8905      * @since   1.5
8906      */
8907     public static boolean isUpperCase(int codePoint) {
8908         return getType(codePoint) == Character.UPPERCASE_LETTER ||
8909                CharacterData.of(codePoint).isOtherUppercase(codePoint);
8910     }
8911 
8912     /**
8913      * Determines if the specified character is a titlecase character.
8914      * <p>
8915      * A character is a titlecase character if its general
8916      * category type, provided by {@code Character.getType(ch)},
8917      * is {@code TITLECASE_LETTER}.
8918      * <p>
8919      * Some characters look like pairs of Latin letters. For example, there
8920      * is an uppercase letter that looks like "LJ" and has a corresponding
8921      * lowercase letter that looks like "lj". A third form, which looks like "Lj",
8922      * is the appropriate form to use when rendering a word in lowercase
8923      * with initial capitals, as for a book title.
8924      * <p>
8925      * These are some of the Unicode characters for which this method returns
8926      * {@code true}:
8927      * <ul>
8928      * <li>{@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON}


9039      * <li>{@code '\u005Cu0660'} through {@code '\u005Cu0669'},
9040      *     Arabic-Indic digits
9041      * <li>{@code '\u005Cu06F0'} through {@code '\u005Cu06F9'},
9042      *     Extended Arabic-Indic digits
9043      * <li>{@code '\u005Cu0966'} through {@code '\u005Cu096F'},
9044      *     Devanagari digits
9045      * <li>{@code '\u005CuFF10'} through {@code '\u005CuFF19'},
9046      *     Fullwidth digits
9047      * </ul>
9048      *
9049      * Many other character ranges contain digits as well.
9050      *
9051      * @param   codePoint the character (Unicode code point) to be tested.
9052      * @return  {@code true} if the character is a digit;
9053      *          {@code false} otherwise.
9054      * @see     Character#forDigit(int, int)
9055      * @see     Character#getType(int)
9056      * @since   1.5
9057      */
9058     public static boolean isDigit(int codePoint) {
9059         return getType(codePoint) == Character.DECIMAL_DIGIT_NUMBER;
9060     }
9061 
9062     /**
9063      * Determines if a character is defined in Unicode.
9064      * <p>
9065      * A character is defined if at least one of the following is true:
9066      * <ul>
9067      * <li>It has an entry in the UnicodeData file.
9068      * <li>It has a value in a range defined by the UnicodeData file.
9069      * </ul>
9070      *
9071      * <p><b>Note:</b> This method cannot handle <a
9072      * href="#supplementary"> supplementary characters</a>. To support
9073      * all Unicode characters, including supplementary characters, use
9074      * the {@link #isDefined(int)} method.
9075      *
9076      * @param   ch   the character to be tested
9077      * @return  {@code true} if the character has a defined meaning
9078      *          in Unicode; {@code false} otherwise.
9079      * @see     Character#isDigit(char)




8822      * The following are examples of lowercase characters:
8823      * <blockquote><pre>
8824      * 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
8825      * '\u00DF' '\u00E0' '\u00E1' '\u00E2' '\u00E3' '\u00E4' '\u00E5' '\u00E6'
8826      * '\u00E7' '\u00E8' '\u00E9' '\u00EA' '\u00EB' '\u00EC' '\u00ED' '\u00EE'
8827      * '\u00EF' '\u00F0' '\u00F1' '\u00F2' '\u00F3' '\u00F4' '\u00F5' '\u00F6'
8828      * '\u00F8' '\u00F9' '\u00FA' '\u00FB' '\u00FC' '\u00FD' '\u00FE' '\u00FF'
8829      * </pre></blockquote>
8830      * <p> Many other Unicode characters are lowercase too.
8831      *
8832      * @param   codePoint the character (Unicode code point) to be tested.
8833      * @return  {@code true} if the character is lowercase;
8834      *          {@code false} otherwise.
8835      * @see     Character#isLowerCase(int)
8836      * @see     Character#isTitleCase(int)
8837      * @see     Character#toLowerCase(int)
8838      * @see     Character#getType(int)
8839      * @since   1.5
8840      */
8841     public static boolean isLowerCase(int codePoint) {
8842         return CharacterData.of(codePoint).isLowerCase(codePoint) ||
8843                CharacterData.of(codePoint).isOtherLowercase(codePoint);
8844     }
8845 
8846     /**
8847      * Determines if the specified character is an uppercase character.
8848      * <p>
8849      * A character is uppercase if its general category type, provided by
8850      * {@code Character.getType(ch)}, is {@code UPPERCASE_LETTER}.
8851      * or it has contributory property Other_Uppercase as defined by the Unicode Standard.
8852      * <p>
8853      * The following are examples of uppercase characters:
8854      * <blockquote><pre>
8855      * 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
8856      * '\u00C0' '\u00C1' '\u00C2' '\u00C3' '\u00C4' '\u00C5' '\u00C6' '\u00C7'
8857      * '\u00C8' '\u00C9' '\u00CA' '\u00CB' '\u00CC' '\u00CD' '\u00CE' '\u00CF'
8858      * '\u00D0' '\u00D1' '\u00D2' '\u00D3' '\u00D4' '\u00D5' '\u00D6' '\u00D8'
8859      * '\u00D9' '\u00DA' '\u00DB' '\u00DC' '\u00DD' '\u00DE'
8860      * </pre></blockquote>
8861      * <p> Many other Unicode characters are uppercase too.
8862      *


8888      * The following are examples of uppercase characters:
8889      * <blockquote><pre>
8890      * 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
8891      * '\u00C0' '\u00C1' '\u00C2' '\u00C3' '\u00C4' '\u00C5' '\u00C6' '\u00C7'
8892      * '\u00C8' '\u00C9' '\u00CA' '\u00CB' '\u00CC' '\u00CD' '\u00CE' '\u00CF'
8893      * '\u00D0' '\u00D1' '\u00D2' '\u00D3' '\u00D4' '\u00D5' '\u00D6' '\u00D8'
8894      * '\u00D9' '\u00DA' '\u00DB' '\u00DC' '\u00DD' '\u00DE'
8895      * </pre></blockquote>
8896      * <p> Many other Unicode characters are uppercase too.
8897      *
8898      * @param   codePoint the character (Unicode code point) to be tested.
8899      * @return  {@code true} if the character is uppercase;
8900      *          {@code false} otherwise.
8901      * @see     Character#isLowerCase(int)
8902      * @see     Character#isTitleCase(int)
8903      * @see     Character#toUpperCase(int)
8904      * @see     Character#getType(int)
8905      * @since   1.5
8906      */
8907     public static boolean isUpperCase(int codePoint) {
8908         return CharacterData.of(codePoint).isUpperCase(codePoint) ||
8909                CharacterData.of(codePoint).isOtherUppercase(codePoint);
8910     }
8911 
8912     /**
8913      * Determines if the specified character is a titlecase character.
8914      * <p>
8915      * A character is a titlecase character if its general
8916      * category type, provided by {@code Character.getType(ch)},
8917      * is {@code TITLECASE_LETTER}.
8918      * <p>
8919      * Some characters look like pairs of Latin letters. For example, there
8920      * is an uppercase letter that looks like "LJ" and has a corresponding
8921      * lowercase letter that looks like "lj". A third form, which looks like "Lj",
8922      * is the appropriate form to use when rendering a word in lowercase
8923      * with initial capitals, as for a book title.
8924      * <p>
8925      * These are some of the Unicode characters for which this method returns
8926      * {@code true}:
8927      * <ul>
8928      * <li>{@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON}


9039      * <li>{@code '\u005Cu0660'} through {@code '\u005Cu0669'},
9040      *     Arabic-Indic digits
9041      * <li>{@code '\u005Cu06F0'} through {@code '\u005Cu06F9'},
9042      *     Extended Arabic-Indic digits
9043      * <li>{@code '\u005Cu0966'} through {@code '\u005Cu096F'},
9044      *     Devanagari digits
9045      * <li>{@code '\u005CuFF10'} through {@code '\u005CuFF19'},
9046      *     Fullwidth digits
9047      * </ul>
9048      *
9049      * Many other character ranges contain digits as well.
9050      *
9051      * @param   codePoint the character (Unicode code point) to be tested.
9052      * @return  {@code true} if the character is a digit;
9053      *          {@code false} otherwise.
9054      * @see     Character#forDigit(int, int)
9055      * @see     Character#getType(int)
9056      * @since   1.5
9057      */
9058     public static boolean isDigit(int codePoint) {
9059         return CharacterData.of(codePoint).isDigit(codePoint);
9060     }
9061 
9062     /**
9063      * Determines if a character is defined in Unicode.
9064      * <p>
9065      * A character is defined if at least one of the following is true:
9066      * <ul>
9067      * <li>It has an entry in the UnicodeData file.
9068      * <li>It has a value in a range defined by the UnicodeData file.
9069      * </ul>
9070      *
9071      * <p><b>Note:</b> This method cannot handle <a
9072      * href="#supplementary"> supplementary characters</a>. To support
9073      * all Unicode characters, including supplementary characters, use
9074      * the {@link #isDefined(int)} method.
9075      *
9076      * @param   ch   the character to be tested
9077      * @return  {@code true} if the character has a defined meaning
9078      *          in Unicode; {@code false} otherwise.
9079      * @see     Character#isDigit(char)


< prev index next >