< prev index next >

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

Print this page
rev 56092 : imported patch 8229831


9899      * @see     Character#isJavaIdentifierStart(int)
9900      * @see     Character#isLetterOrDigit(int)
9901      * @see     Character#isUnicodeIdentifierPart(int)
9902      * @see     javax.lang.model.SourceVersion#isIdentifier(CharSequence)
9903      * @since   1.5
9904      */
9905     public static boolean isJavaIdentifierPart(int codePoint) {
9906         return CharacterData.of(codePoint).isJavaIdentifierPart(codePoint);
9907     }
9908 
9909     /**
9910      * Determines if the specified character is permissible as the
9911      * first character in a Unicode identifier.
9912      * <p>
9913      * A character may start a Unicode identifier if and only if
9914      * one of the following conditions is true:
9915      * <ul>
9916      * <li> {@link #isLetter(char) isLetter(ch)} returns {@code true}
9917      * <li> {@link #getType(char) getType(ch)} returns
9918      *      {@code LETTER_NUMBER}.


9919      * </ul>









9920      *
9921      * <p><b>Note:</b> This method cannot handle <a
9922      * href="#supplementary"> supplementary characters</a>. To support
9923      * all Unicode characters, including supplementary characters, use
9924      * the {@link #isUnicodeIdentifierStart(int)} method.
9925      *
9926      * @param   ch      the character to be tested.
9927      * @return  {@code true} if the character may start a Unicode
9928      *          identifier; {@code false} otherwise.
9929      * @see     Character#isJavaIdentifierStart(char)
9930      * @see     Character#isLetter(char)
9931      * @see     Character#isUnicodeIdentifierPart(char)
9932      * @since   1.1
9933      */
9934     public static boolean isUnicodeIdentifierStart(char ch) {
9935         return isUnicodeIdentifierStart((int)ch);
9936     }
9937 
9938     /**
9939      * Determines if the specified character (Unicode code point) is permissible as the
9940      * first character in a Unicode identifier.
9941      * <p>
9942      * A character may start a Unicode identifier if and only if
9943      * one of the following conditions is true:
9944      * <ul>
9945      * <li> {@link #isLetter(int) isLetter(codePoint)}
9946      *      returns {@code true}
9947      * <li> {@link #getType(int) getType(codePoint)}
9948      *      returns {@code LETTER_NUMBER}.


9949      * </ul>










9950      * @param   codePoint the character (Unicode code point) to be tested.
9951      * @return  {@code true} if the character may start a Unicode
9952      *          identifier; {@code false} otherwise.
9953      * @see     Character#isJavaIdentifierStart(int)
9954      * @see     Character#isLetter(int)
9955      * @see     Character#isUnicodeIdentifierPart(int)
9956      * @since   1.5
9957      */
9958     public static boolean isUnicodeIdentifierStart(int codePoint) {
9959         return CharacterData.of(codePoint).isUnicodeIdentifierStart(codePoint);
9960     }
9961 
9962     /**
9963      * Determines if the specified character may be part of a Unicode
9964      * identifier as other than the first character.
9965      * <p>
9966      * A character may be part of a Unicode identifier if and only if
9967      * one of the following statements is true:
9968      * <ul>
9969      * <li>  it is a letter
9970      * <li>  it is a connecting punctuation character (such as {@code '_'})
9971      * <li>  it is a digit
9972      * <li>  it is a numeric letter (such as a Roman numeral character)
9973      * <li>  it is a combining mark
9974      * <li>  it is a non-spacing mark
9975      * <li> {@code isIdentifierIgnorable} returns
9976      * {@code true} for this character.




9977      * </ul>











9978      *
9979      * <p><b>Note:</b> This method cannot handle <a
9980      * href="#supplementary"> supplementary characters</a>. To support
9981      * all Unicode characters, including supplementary characters, use
9982      * the {@link #isUnicodeIdentifierPart(int)} method.
9983      *
9984      * @param   ch      the character to be tested.
9985      * @return  {@code true} if the character may be part of a
9986      *          Unicode identifier; {@code false} otherwise.
9987      * @see     Character#isIdentifierIgnorable(char)
9988      * @see     Character#isJavaIdentifierPart(char)
9989      * @see     Character#isLetterOrDigit(char)
9990      * @see     Character#isUnicodeIdentifierStart(char)
9991      * @since   1.1
9992      */
9993     public static boolean isUnicodeIdentifierPart(char ch) {
9994         return isUnicodeIdentifierPart((int)ch);
9995     }
9996 
9997     /**
9998      * Determines if the specified character (Unicode code point) may be part of a Unicode
9999      * identifier as other than the first character.
10000      * <p>
10001      * A character may be part of a Unicode identifier if and only if
10002      * one of the following statements is true:
10003      * <ul>
10004      * <li>  it is a letter
10005      * <li>  it is a connecting punctuation character (such as {@code '_'})
10006      * <li>  it is a digit
10007      * <li>  it is a numeric letter (such as a Roman numeral character)
10008      * <li>  it is a combining mark
10009      * <li>  it is a non-spacing mark
10010      * <li> {@code isIdentifierIgnorable} returns
10011      * {@code true} for this character.




10012      * </ul>












10013      * @param   codePoint the character (Unicode code point) to be tested.
10014      * @return  {@code true} if the character may be part of a
10015      *          Unicode identifier; {@code false} otherwise.
10016      * @see     Character#isIdentifierIgnorable(int)
10017      * @see     Character#isJavaIdentifierPart(int)
10018      * @see     Character#isLetterOrDigit(int)
10019      * @see     Character#isUnicodeIdentifierStart(int)
10020      * @since   1.5
10021      */
10022     public static boolean isUnicodeIdentifierPart(int codePoint) {
10023         return CharacterData.of(codePoint).isUnicodeIdentifierPart(codePoint);
10024     }
10025 
10026     /**
10027      * Determines if the specified character should be regarded as
10028      * an ignorable character in a Java identifier or a Unicode identifier.
10029      * <p>
10030      * The following Unicode characters are ignorable in a Java identifier
10031      * or a Unicode identifier:
10032      * <ul>




9899      * @see     Character#isJavaIdentifierStart(int)
9900      * @see     Character#isLetterOrDigit(int)
9901      * @see     Character#isUnicodeIdentifierPart(int)
9902      * @see     javax.lang.model.SourceVersion#isIdentifier(CharSequence)
9903      * @since   1.5
9904      */
9905     public static boolean isJavaIdentifierPart(int codePoint) {
9906         return CharacterData.of(codePoint).isJavaIdentifierPart(codePoint);
9907     }
9908 
9909     /**
9910      * Determines if the specified character is permissible as the
9911      * first character in a Unicode identifier.
9912      * <p>
9913      * A character may start a Unicode identifier if and only if
9914      * one of the following conditions is true:
9915      * <ul>
9916      * <li> {@link #isLetter(char) isLetter(ch)} returns {@code true}
9917      * <li> {@link #getType(char) getType(ch)} returns
9918      *      {@code LETTER_NUMBER}.
9919      * <li> it is an <a href="http://www.unicode.org/reports/tr44/#Other_ID_Start">
9920      *      {@code Other_ID_Start}</a> character.
9921      * </ul>
9922      * <p>
9923      * This method conforms to <a href="https://unicode.org/reports/tr31/#R1">
9924      * UAX31-R1: Default Identifiers</a> requirement of the Unicode Standard,
9925      * with the following profile of UAX31:
9926      * <pre>
9927      * Start := ID_Start + 'VERTICAL TILDE' (U+2E2F)
9928      * </pre>
9929      * {@code 'VERTICAL TILDE'} is added to {@code Start} solely for backward
9930      * compatibility.
9931      *
9932      * <p><b>Note:</b> This method cannot handle <a
9933      * href="#supplementary"> supplementary characters</a>. To support
9934      * all Unicode characters, including supplementary characters, use
9935      * the {@link #isUnicodeIdentifierStart(int)} method.
9936      *
9937      * @param   ch      the character to be tested.
9938      * @return  {@code true} if the character may start a Unicode
9939      *          identifier; {@code false} otherwise.
9940      * @see     Character#isJavaIdentifierStart(char)
9941      * @see     Character#isLetter(char)
9942      * @see     Character#isUnicodeIdentifierPart(char)
9943      * @since   1.1
9944      */
9945     public static boolean isUnicodeIdentifierStart(char ch) {
9946         return isUnicodeIdentifierStart((int)ch);
9947     }
9948 
9949     /**
9950      * Determines if the specified character (Unicode code point) is permissible as the
9951      * first character in a Unicode identifier.
9952      * <p>
9953      * A character may start a Unicode identifier if and only if
9954      * one of the following conditions is true:
9955      * <ul>
9956      * <li> {@link #isLetter(int) isLetter(codePoint)}
9957      *      returns {@code true}
9958      * <li> {@link #getType(int) getType(codePoint)}
9959      *      returns {@code LETTER_NUMBER}.
9960      * <li> it is an <a href="http://www.unicode.org/reports/tr44/#Other_ID_Start">
9961      *      {@code Other_ID_Start}</a> character.
9962      * </ul>
9963      * <p>
9964      * This method conforms to <a href="https://unicode.org/reports/tr31/#R1">
9965      * UAX31-R1: Default Identifiers</a> requirement of the Unicode Standard,
9966      * with the following profile of UAX31:
9967      * <pre>
9968      * Start := ID_Start + 'VERTICAL TILDE' (U+2E2F)
9969      * </pre>
9970      * {@code 'VERTICAL TILDE'} is added to {@code Start} solely for backward
9971      * compatibility.
9972      *
9973      * @param   codePoint the character (Unicode code point) to be tested.
9974      * @return  {@code true} if the character may start a Unicode
9975      *          identifier; {@code false} otherwise.
9976      * @see     Character#isJavaIdentifierStart(int)
9977      * @see     Character#isLetter(int)
9978      * @see     Character#isUnicodeIdentifierPart(int)
9979      * @since   1.5
9980      */
9981     public static boolean isUnicodeIdentifierStart(int codePoint) {
9982         return CharacterData.of(codePoint).isUnicodeIdentifierStart(codePoint);
9983     }
9984 
9985     /**
9986      * Determines if the specified character may be part of a Unicode
9987      * identifier as other than the first character.
9988      * <p>
9989      * A character may be part of a Unicode identifier if and only if
9990      * one of the following statements is true:
9991      * <ul>
9992      * <li>  it is a letter
9993      * <li>  it is a connecting punctuation character (such as {@code '_'})
9994      * <li>  it is a digit
9995      * <li>  it is a numeric letter (such as a Roman numeral character)
9996      * <li>  it is a combining mark
9997      * <li>  it is a non-spacing mark
9998      * <li> {@code isIdentifierIgnorable} returns
9999      * {@code true} for this character.
10000      * <li> it is an <a href="http://www.unicode.org/reports/tr44/#Other_ID_Start">
10001      *      {@code Other_ID_Start}</a> character.
10002      * <li> it is an <a href="http://www.unicode.org/reports/tr44/#Other_ID_Continue">
10003      *      {@code Other_ID_Continue}</a> character.
10004      * </ul>
10005      * <p>
10006      * This method conforms to <a href="https://unicode.org/reports/tr31/#R1">
10007      * UAX31-R1: Default Identifiers</a> requirement of the Unicode Standard,
10008      * with the following profile of UAX31:
10009      * <pre>
10010      * Continue := Start + ID_Continue + ignorable
10011      * Medial := empty
10012      * ignorable := isIdentifierIgnorable(char) returns true for the character
10013      * </pre>
10014      * {@code ignorable} is added to {@code Continue} solely for backward
10015      * compatibility.
10016      *
10017      * <p><b>Note:</b> This method cannot handle <a
10018      * href="#supplementary"> supplementary characters</a>. To support
10019      * all Unicode characters, including supplementary characters, use
10020      * the {@link #isUnicodeIdentifierPart(int)} method.
10021      *
10022      * @param   ch      the character to be tested.
10023      * @return  {@code true} if the character may be part of a
10024      *          Unicode identifier; {@code false} otherwise.
10025      * @see     Character#isIdentifierIgnorable(char)
10026      * @see     Character#isJavaIdentifierPart(char)
10027      * @see     Character#isLetterOrDigit(char)
10028      * @see     Character#isUnicodeIdentifierStart(char)
10029      * @since   1.1
10030      */
10031     public static boolean isUnicodeIdentifierPart(char ch) {
10032         return isUnicodeIdentifierPart((int)ch);
10033     }
10034 
10035     /**
10036      * Determines if the specified character (Unicode code point) may be part of a Unicode
10037      * identifier as other than the first character.
10038      * <p>
10039      * A character may be part of a Unicode identifier if and only if
10040      * one of the following statements is true:
10041      * <ul>
10042      * <li>  it is a letter
10043      * <li>  it is a connecting punctuation character (such as {@code '_'})
10044      * <li>  it is a digit
10045      * <li>  it is a numeric letter (such as a Roman numeral character)
10046      * <li>  it is a combining mark
10047      * <li>  it is a non-spacing mark
10048      * <li> {@code isIdentifierIgnorable} returns
10049      * {@code true} for this character.
10050      * <li> it is an <a href="http://www.unicode.org/reports/tr44/#Other_ID_Start">
10051      *      {@code Other_ID_Start}</a> character.
10052      * <li> it is an <a href="http://www.unicode.org/reports/tr44/#Other_ID_Continue">
10053      *      {@code Other_ID_Continue}</a> character.
10054      * </ul>
10055      * <p>
10056      * This method conforms to <a href="https://unicode.org/reports/tr31/#R1">
10057      * UAX31-R1: Default Identifiers</a> requirement of the Unicode Standard,
10058      * with the following profile of UAX31:
10059      * <pre>
10060      * Continue := Start + ID_Continue + ignorable
10061      * Medial := empty
10062      * ignorable := isIdentifierIgnorable(int) returns true for the character
10063      * </pre>
10064      * {@code ignorable} is added to {@code Continue} solely for backward
10065      * compatibility.
10066      *
10067      * @param   codePoint the character (Unicode code point) to be tested.
10068      * @return  {@code true} if the character may be part of a
10069      *          Unicode identifier; {@code false} otherwise.
10070      * @see     Character#isIdentifierIgnorable(int)
10071      * @see     Character#isJavaIdentifierPart(int)
10072      * @see     Character#isLetterOrDigit(int)
10073      * @see     Character#isUnicodeIdentifierStart(int)
10074      * @since   1.5
10075      */
10076     public static boolean isUnicodeIdentifierPart(int codePoint) {
10077         return CharacterData.of(codePoint).isUnicodeIdentifierPart(codePoint);
10078     }
10079 
10080     /**
10081      * Determines if the specified character should be regarded as
10082      * an ignorable character in a Java identifier or a Unicode identifier.
10083      * <p>
10084      * The following Unicode characters are ignorable in a Java identifier
10085      * or a Unicode identifier:
10086      * <ul>


< prev index next >