?? character.java
字號:
* Stores unicode uppercase attribute table. Exploit package visibility * of String.value to avoid copying the array. * @see CharData#UPPER */ private static final char[] upper = String.zeroBasedStringValue(CharData.UPPER); /** * Stores unicode lowercase attribute table. Exploit package visibility * of String.value to avoid copying the array. * @see CharData#LOWER */ private static final char[] lower = String.zeroBasedStringValue(CharData.LOWER); /** * Stores unicode direction attribute table. Exploit package visibility * of String.value to avoid copying the array. * @see CharData#DIRECTION */ // Package visible for use by String. static final char[] direction = String.zeroBasedStringValue(CharData.DIRECTION); /** * Stores unicode titlecase table. Exploit package visibility of * String.value to avoid copying the array. * @see CharData#TITLE */ private static final char[] title = String.zeroBasedStringValue(CharData.TITLE); /** * Mask for grabbing the type out of the contents of data. * @see CharData#DATA */ private static final int TYPE_MASK = 0x1F; /** * Mask for grabbing the non-breaking space flag out of the contents of * data. * @see CharData#DATA */ private static final int NO_BREAK_MASK = 0x20; /** * Mask for grabbing the mirrored directionality flag out of the contents * of data. * @see CharData#DATA */ private static final int MIRROR_MASK = 0x40; /** * Min value for supplementary code point. * * @since 1.5 */ public static final int MIN_SUPPLEMENTARY_CODE_POINT = 0x10000; /** * Min value for code point. * * @since 1.5 */ public static final int MIN_CODE_POINT = 0; /** * Max value for code point. * * @since 1.5 */ public static final int MAX_CODE_POINT = 0x010ffff; /** * Minimum high surrogate code in UTF-16 encoding. * * @since 1.5 */ public static final char MIN_HIGH_SURROGATE = '\ud800'; /** * Maximum high surrogate code in UTF-16 encoding. * * @since 1.5 */ public static final char MAX_HIGH_SURROGATE = '\udbff'; /** * Minimum low surrogate code in UTF-16 encoding. * * @since 1.5 */ public static final char MIN_LOW_SURROGATE = '\udc00'; /** * Maximum low surrogate code in UTF-16 encoding. * * @since 1.5 */ public static final char MAX_LOW_SURROGATE = '\udfff'; /** * Minimum surrogate code in UTF-16 encoding. * * @since 1.5 */ public static final char MIN_SURROGATE = MIN_HIGH_SURROGATE; /** * Maximum low surrogate code in UTF-16 encoding. * * @since 1.5 */ public static final char MAX_SURROGATE = MAX_LOW_SURROGATE; /** * Grabs an attribute offset from the Unicode attribute database. The lower * 5 bits are the character type, the next 2 bits are flags, and the top * 9 bits are the offset into the attribute tables. * * @param ch the character to look up * @return the character's attribute offset and type * @see #TYPE_MASK * @see #NO_BREAK_MASK * @see #MIRROR_MASK * @see CharData#DATA * @see CharData#SHIFT */ // Package visible for use in String. static char readChar(char ch) { // Perform 16-bit addition to find the correct entry in data. return data[(char) (blocks[ch >> CharData.SHIFT] + ch)]; } /** * Wraps up a character. * * @param value the character to wrap */ public Character(char value) { this.value = value; } /** * Returns the character which has been wrapped by this class. * * @return the character wrapped */ public char charValue() { return value; } /** * Returns the numerical value (unsigned) of the wrapped character. * Range of returned values: 0x0000-0xFFFF. * * @return the value of the wrapped character */ public int hashCode() { return value; } /** * Determines if an object is equal to this object. This is only true for * another Character object wrapping the same value. * * @param o object to compare * @return true if o is a Character with the same value */ public boolean equals(Object o) { return o instanceof Character && value == ((Character) o).value; } /** * Converts the wrapped character into a String. * * @return a String containing one character -- the wrapped character * of this instance */ public String toString() { // Package constructor avoids an array copy. return new String(new char[] { value }, 0, 1, true); } /** * Returns a String of length 1 representing the specified character. * * @param ch the character to convert * @return a String containing the character * @since 1.4 */ public static String toString(char ch) { // Package constructor avoids an array copy. return new String(new char[] { ch }, 0, 1, true); } /** * Determines if a character is a Unicode lowercase letter. For example, * <code>'a'</code> is lowercase. * <br> * lowercase = [Ll] * * @param ch character to test * @return true if ch is a Unicode lowercase letter, else false * @see #isUpperCase(char) * @see #isTitleCase(char) * @see #toLowerCase(char) * @see #getType(char) */ public static boolean isLowerCase(char ch) { return getType(ch) == LOWERCASE_LETTER; } /** * Determines if a character is a Unicode uppercase letter. For example, * <code>'A'</code> is uppercase. * <br> * uppercase = [Lu] * * @param ch character to test * @return true if ch is a Unicode uppercase letter, else false * @see #isLowerCase(char) * @see #isTitleCase(char) * @see #toUpperCase(char) * @see #getType(char) */ public static boolean isUpperCase(char ch) { return getType(ch) == UPPERCASE_LETTER; } /** * Determines if a character is a Unicode titlecase letter. For example, * the character "Lj" (Latin capital L with small letter j) is titlecase. * <br> * titlecase = [Lt] * * @param ch character to test * @return true if ch is a Unicode titlecase letter, else false * @see #isLowerCase(char) * @see #isUpperCase(char) * @see #toTitleCase(char) * @see #getType(char) */ public static boolean isTitleCase(char ch) { return getType(ch) == TITLECASE_LETTER; } /** * Determines if a character is a Unicode decimal digit. For example, * <code>'0'</code> is a digit. * <br> * Unicode decimal digit = [Nd] * * @param ch character to test * @return true if ch is a Unicode decimal digit, else false * @see #digit(char, int) * @see #forDigit(int, int) * @see #getType(char) */ public static boolean isDigit(char ch) { return getType(ch) == DECIMAL_DIGIT_NUMBER; } /** * Determines if a character is part of the Unicode Standard. This is an * evolving standard, but covers every character in the data file. * <br> * defined = not [Cn] * * @param ch character to test * @return true if ch is a Unicode character, else false * @see #isDigit(char) * @see #isLetter(char) * @see #isLetterOrDigit(char) * @see #isLowerCase(char) * @see #isTitleCase(char) * @see #isUpperCase(char) */ public static boolean isDefined(char ch) { return getType(ch) != UNASSIGNED; } /** * Determines if a character is a Unicode letter. Not all letters have case, * so this may return true when isLowerCase and isUpperCase return false. * <br> * letter = [Lu]|[Ll]|[Lt]|[Lm]|[Lo] * * @param ch character to test * @return true if ch is a Unicode letter, else false * @see #isDigit(char) * @see #isJavaIdentifierStart(char) * @see #isJavaLetter(char) * @see #isJavaLetterOrDigit(char) * @see #isLetterOrDigit(char) * @see #isLowerCase(char) * @see #isTitleCase(char) * @see #isUnicodeIdentifierStart(char) * @see #isUpperCase(char) */ public static boolean isLetter(char ch) { return ((1 << getType(ch)) & ((1 << UPPERCASE_LETTER) | (1 << LOWERCASE_LETTER) | (1 << TITLECASE_LETTER) | (1 << MODIFIER_LETTER) | (1 << OTHER_LETTER))) != 0; } /** * Determines if a character is a Unicode letter or a Unicode digit. This * is the combination of isLetter and isDigit. * <br> * letter or digit = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nd] * * @param ch character to test * @return true if ch is a Unicode letter or a Unicode digit, else false * @see #isDigit(char) * @see #isJavaIdentifierPart(char) * @see #isJavaLetter(char) * @see #isJavaLetterOrDigit(char) * @see #isLetter(char) * @see #isUnicodeIdentifierPart(char) */ public static boolean isLetterOrDigit(char ch) { return ((1 << getType(ch)) & ((1 << UPPERCASE_LETTER) | (1 << LOWERCASE_LETTER) | (1 << TITLECASE_LETTER) | (1 << MODIFIER_LETTER) | (1 << OTHER_LETTER) | (1 << DECIMAL_DIGIT_NUMBER))) != 0; } /** * Determines if a character can start a Java identifier. This is the * combination of isLetter, any character where getType returns * LETTER_NUMBER, currency symbols (like '$'), and connecting punctuation * (like '_'). * * @param ch character to test * @return true if ch can start a Java identifier, else false * @deprecated Replaced by {@link #isJavaIdentifierStart(char)} * @see #isJavaLetterOrDigit(char) * @see #isJavaIdentifierStart(char) * @see #isJavaIdentifierPart(char) * @see #isLetter(char) * @see #isLetterOrDigit(char) * @see #isUnicodeIdentifierStart(char) */ public static boolean isJavaLetter(char ch) { return isJavaIdentifierStart(ch); } /** * Determines if a character can follow the first letter in * a Java identifier. This is the combination of isJavaLetter (isLetter, * type of LETTER_NUMBER, currency, connecting punctuation) and digit, * numeric letter (like Roman numerals), combining marks, non-spacing marks, * or isIdentifierIgnorable. * * @param ch character to test * @return true if ch can follow the first letter in a Java identifier * @deprecated Replaced by {@link #isJavaIdentifierPart(char)} * @see #isJavaLetter(char) * @see #isJavaIdentifierStart(char) * @see #isJavaIdentifierPart(char) * @see #isLetter(char) * @see #isLetterOrDigit(char) * @see #isUnicodeIdentifierPart(char) * @see #isIdentifierIgnorable(char) */ public static boolean isJavaLetterOrDigit(char ch) { return isJavaIdentifierPart(ch); } /** * Determines if a character can start a Java identifier. This is the * combination of isLetter, any character where getType returns * LETTER_NUMBER, currency symbols (like '$'), and connecting punctuation * (like '_'). * <br> * Java identifier start = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Sc]|[Pc] * * @param ch character to test * @return true if ch can start a Java identifier, else false * @see #isJavaIdentifierPart(char) * @see #isLetter(char) * @see #isUnicodeIdentifierStart(char) * @since 1.1 */ public static boolean isJavaIdentifierStart(char ch) { return ((1 << getType(ch)) & ((1 << UPPERCASE_LETTER) | (1 << LOWERCASE_LETTER) | (1 << TITLECASE_LETTER) | (1 << MODIFIER_LETTER) | (1 << OTHER_LETTER) | (1 << LETTER_NUMBER) | (1 << CURRENCY_SYMBOL) | (1 << CONNECTOR_PUNCTUATION))) != 0; } /** * Determines if a character can follow the first letter in * a Java identifier. This is the combination of isJavaLetter (isLetter, * type of LETTER_NUMBER, currency, connecting punctuation) and digit, * numeric letter (like Roman numerals), combining marks, non-spacing marks, * or isIdentifierIgnorable. * <br> * Java identifier extender = * [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Sc]|[Pc]|[Mn]|[Mc]|[Nd]|[Cf] * |U+0000-U+0008|U+000E-U+001B|U+007F-U+009F * * @param ch character to test * @return true if ch can follow the first letter in a Java identifier * @see #isIdentifierIgnorable(char) * @see #isJavaIdentifierStart(char) * @see #isLetterOrDigit(char) * @see #isUnicodeIdentifierPart(char) * @since 1.1 */ public static boolean isJavaIdentifierPart(char ch) { int category = getType(ch); return ((1 << category) & ((1 << UPPERCASE_LETTER) | (1 << LOWERCASE_LETTER) | (1 << TITLECASE_LETTER) | (1 << MODIFIER_LETTER) | (1 << OTHER_LETTER) | (1 << NON_SPACING_MARK) | (1 << COMBINING_SPACING_MARK) | (1 << DECIMAL_DIGIT_NUMBER) | (1 << LETTER_NUMBER) | (1 << CURRENCY_SYMBOL) | (1 << CONNECTOR_PUNCTUATION) | (1 << FORMAT))) != 0 || (category == CONTROL && isIdentifierIgnorable(ch)); } /** * Determines if a character can start a Unicode identifier. Only * letters can start a Unicode identifier, but this includes characters * in LETTER_NUMBER. * <br> * Unicode identifier start = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl] * * @param ch character to test * @return true if ch can start a Unicode identifier, else false * @see #isJavaIdentifierStart(char) * @see #isLetter(char) * @see #isUnicodeIdentifierPart(char) * @since 1.1 */ public static boolean isUnicodeIdentifierStart(char ch) { return ((1 << getType(ch)) & ((1 << UPPERCASE_LETTER)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -