📄 character.java
字号:
* @see java.lang.Character#isUnicodeIdentifierPart(char)
* @since JDK1.0.2
* @deprecated Replaced by isJavaIdentifierPart(char).
*/
public static boolean isJavaLetterOrDigit(char ch) {
return (A[Y[(X[ch>>6]<<5)|((ch>>1)&0x1F)]|(ch&0x1)] & 0x00030000) != 0;
}
/**
* Determines if the specified character is
* permissible as the first character in a Java identifier.
* A character may start a Java identifier if and only if
* it is one of the following:
* <ul>
* <li> a letter
* <li> a currency symbol (such as "$")
* <li> a connecting punctuation character (such as "_").
* </ul>
*
* @param ch the character to be tested.
* @return true if the character may start a Java identifier;
* false otherwise.
* @see java.lang.Character#isJavaIdentifierPart(char)
* @see java.lang.Character#isLetter(char)
* @see java.lang.Character#isUnicodeIdentifierStart(char)
* @since JDK1.1
*/
public static boolean isJavaIdentifierStart(char ch) {
return (A[Y[(X[ch>>6]<<5)|((ch>>1)&0x1F)]|(ch&0x1)] & 0x00070000) >= 0x00050000;
}
/**
* Determines if the specified character may be part of a Java
* identifier as other than the first character.
* A character may be part of a Java identifier if and only if
* it is one of the following:
* <ul>
* <li> a letter
* <li> a currency symbol (such as "$")
* <li> a connecting punctuation character (such as "_").
* <li> a digit
* <li> a numeric letter (such as a Roman numeral character)
* <li> a combining mark
* <li> a non-spacing mark
* <li> an ignorable control character
* </ul>
*
* @param ch the character to be tested.
* @return true if the character may be part of a Unicode identifier;
* false otherwise.
* @see java.lang.Character#isIdentifierIgnorable(char)
* @see java.lang.Character#isJavaIdentifierStart(char)
* @see java.lang.Character#isLetterOrDigit(char)
* @see java.lang.Character#isUnicodeIdentifierPart(char)
* @since JDK1.1
*/
public static boolean isJavaIdentifierPart(char ch) {
return (A[Y[(X[ch>>6]<<5)|((ch>>1)&0x1F)]|(ch&0x1)] & 0x00030000) != 0;
}
/**
* Determines if the specified character is
* permissible as the first character in a Unicode identifier.
* A character may start a Unicode identifier if and only if
* it is a letter.
*
* @param ch the character to be tested.
* @return true if the character may start a Unicode identifier;
* false otherwise.
* @see java.lang.Character#isJavaIdentifierStart(char)
* @see java.lang.Character#isLetter(char)
* @see java.lang.Character#isUnicodeIdentifierPart(char)
* @since JDK1.1
*/
public static boolean isUnicodeIdentifierStart(char ch) {
return (A[Y[(X[ch>>6]<<5)|((ch>>1)&0x1F)]|(ch&0x1)] & 0x00070000) == 0x00070000;
}
/**
* Determines if the specified character may be part of a Unicode
* identifier as other than the first character.
* A character may be part of a Unicode identifier if and only if
* it is one of the following:
* <ul>
* <li> a letter
* <li> a connecting punctuation character (such as "_").
* <li> a digit
* <li> a numeric letter (such as a Roman numeral character)
* <li> a combining mark
* <li> a non-spacing mark
* <li> an ignorable control character
* </ul>
*
* @param ch the character to be tested.
* @return true if the character may be part of a Unicode identifier;
* false otherwise.
* @see java.lang.Character#isIdentifierIgnorable(char)
* @see java.lang.Character#isJavaIdentifierPart(char)
* @see java.lang.Character#isLetterOrDigit(char)
* @see java.lang.Character#isUnicodeIdentifierStart(char)
* @since JDK1.1
*/
public static boolean isUnicodeIdentifierPart(char ch) {
return (A[Y[(X[ch>>6]<<5)|((ch>>1)&0x1F)]|(ch&0x1)] & 0x00010000) != 0;
}
/**
* Determines if the specified character should be regarded as
* an ignorable character in a Java identifier or a Unicode identifier.
* The following Unicode characters are ignorable in a Java identifier
* or a Unicode identifier:
* <table>
* <tr><td>0x0000 through 0x0008,</td>
* <td>ISO control characters that</td></tr>
* <tr><td>0x000E through 0x001B,</td> <td>are not whitespace</td></tr>
* <tr><td>and 0x007F through 0x009F</td></tr>
* <tr><td>0x200C through 0x200F</td> <td>join controls</td></tr>
* <tr><td>0x200A through 0x200E</td> <td>bidirectional controls</td></tr>
* <tr><td>0x206A through 0x206F</td> <td>format controls</td></tr>
* <tr><td>0xFEFF</td> <td>zero-width no-break space</td></tr>
* </table>
*
* @param ch the character to be tested.
* @return true if the character may be part of a Unicode identifier;
* false otherwise.
* @see java.lang.Character#isJavaIdentifierPart(char)
* @see java.lang.Character#isUnicodeIdentifierPart(char)
* @since JDK1.1
*/
public static boolean isIdentifierIgnorable(char ch) {
return (A[Y[(X[ch>>6]<<5)|((ch>>1)&0x1F)]|(ch&0x1)] & 0x00070000) == 0x00010000;
}
/**
* The given character is mapped to its lowercase equivalent; if the
* character has no lowercase equivalent, the character itself is
* returned.
* <p>
* A character has a lowercase equivalent if and only if a lowercase
* mapping is specified for the character in the Unicode attribute
* table.
* <p>
* Note that some Unicode characters in the range
* <code>'\u2000'</code> to <code>'\u2FFF'</code> have lowercase
* mappings; this method does map such characters to their lowercase
* equivalents even though the method <code>isUpperCase</code> does
* not return <code>true</code> for such characters.
*
* @param ch the character to be converted.
* @return the lowercase equivalent of the character, if any;
* otherwise the character itself.
* @see java.lang.Character#isLowerCase(char)
* @see java.lang.Character#isUpperCase(char)
* @see java.lang.Character#toTitleCase(char)
* @see java.lang.Character#toUpperCase(char)
* @since JDK1.0
*/
public static char toLowerCase(char ch) {
int val = A[Y[(X[ch>>6]<<5)|((ch>>1)&0x1F)]|(ch&0x1)];
if ((val & 0x00200000) != 0)
return (char)(ch + (val >> 22));
else
return ch;
}
/**
* Converts the character argument to uppercase. A character has an
* uppercase equivalent if and only if an uppercase mapping is
* specified for the character in the Unicode attribute table.
* <p>
* Note that some Unicode characters in the range
* <code>'\u2000'</code> to <code>'\u2000FFF'</code> have uppercase
* mappings; this method does map such characters to their titlecase
* equivalents even though the method <code>isLowerCase</code> does
* not return <code>true</code> for such characters.
*
* @param ch the character to be converted.
* @return the uppercase equivalent of the character, if any;
* otherwise the character itself.
* @see java.lang.Character#isLowerCase(char)
* @see java.lang.Character#isUpperCase(char)
* @see java.lang.Character#toLowerCase(char)
* @see java.lang.Character#toTitleCase(char)
* @since JDK1.0
*/
public static char toUpperCase(char ch) {
int val = A[Y[(X[ch>>6]<<5)|((ch>>1)&0x1F)]|(ch&0x1)];
if ((val & 0x00100000) != 0)
return (char)(ch - (val >> 22));
else
return ch;
}
/**
* Converts the character argument to titlecase. A character has a
* titlecase equivalent if and only if a titlecase mapping is
* specified for the character in the Unicode attribute table.
* <p>
* Note that some Unicode characters in the range
* <code>'\u2000'</code> through <code>'\u2FFF'</code> have titlecase
* mappings; this method does map such characters to their titlecase
* equivalents even though the method <code>isTitleCase</code> does
* not return <code>true</code> for such characters.
* <p>
* There are only four Unicode characters that are truly titlecase forms
* that are distinct from uppercase forms. As a rule, if a character has no
* true titlecase equivalent but does have an uppercase mapping, then the
* Unicode 2.0 attribute table specifies a titlecase mapping that is the
* same as the uppercase mapping.
*
* @param ch the character to be converted.
* @return the titlecase equivalent of the character, if any;
* otherwise the character itself.
* @see java.lang.Character#isTitleCase(char)
* @see java.lang.Character#toLowerCase(char)
* @see java.lang.Character#toUpperCase(char)
* @since JDK1.0.2
*/
public static char toTitleCase(char ch) {
int val = A[Y[(X[ch>>6]<<5)|((ch>>1)&0x1F)]|(ch&0x1)];
if ((val & 0x00080000) != 0) {
// There is a titlecase equivalent. Perform further checks:
if ((val & 0x00100000) == 0) {
// The character does not have an uppercase equivalent, so it must
// already be uppercase; so add 1 to get the titlecase form.
return (char)(ch + 1);
}
else if ((val & 0x00200000) == 0) {
// The character does not have a lowercase equivalent, so it must
// already be lowercase; so subtract 1 to get the titlecase form.
return (char)(ch - 1);
}
else {
// The character has both an uppercase equivalent and a lowercase
// equivalent, so it must itself be a titlecase form; return it.
return ch;
}
}
else if ((val & 0x00100000) != 0) {
// This character has no titlecase equivalent but it does have an
// uppercase equivalent, so use that (subtract the signed case offset).
return (char)(ch - (val >> 22));
}
else
return ch;
}
/**
* Returns the numeric value of the character <code>ch</code> in the
* specified radix.
* <p>
* If the radix is not in the range <code>MIN_RADIX</code> <=
* <code>radix</code> <= <code>MAX_RADIX</code> or if the
* value of <code>ch</code> is not a valid digit in the specified
* radix, <code>-1</code> is returned. A character is a valid digit
* if at least one of the following is true:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -