⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 character.java

📁 《移动Agent技术》一书的所有章节源代码。
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * <ul>
     * <li>The method <code>isDigit</code> is true of the character 
     *     and the Unicode decimal digit value of the character (or its 
     *     single-character decomposition) is less than the specified radix. 
     *     In this case the decimal digit value is returned. 
     * <li>The character is one of the uppercase Latin letters 
     *     <code>'A'</code> through <code>'Z'</code> and its code is less than
     *     <code>radix&nbsp;+ 'A'&nbsp;-&nbsp;10</code>. 
     *     In this case, <code>ch&nbsp;- 'A'&nbsp;+&nbsp;10</code> 
     *     is returned. 
     * <li>The character is one of the lowercase Latin letters 
     *     <code>'a'</code> through <code>'z'</code> and its code is less than
     *     <code>radix&nbsp;+ 'a'&nbsp;-&nbsp;10</code>. 
     *     In this case, <code>ch&nbsp;- 'a'&nbsp;+&nbsp;10</code> 
     *     is returned. 
     * </ul>
     *
     * @param   ch      the character to be converted.
     * @param   radix   the radix.
     * @return  the numeric value represented by the character in the
     *          specified radix.
     * @see     java.lang.Character#forDigit(int, int)
     * @see     java.lang.Character#isDigit(char)
     * @since   JDK1.0
     */
    public static int digit(char ch, int radix) {
        int value = -1;
        if (radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX) {
          int val = A[Y[(X[ch>>6]<<5)|((ch>>1)&0x1F)]|(ch&0x1)];
          int kind = val & 0x1F;
          if (kind == DECIMAL_DIGIT_NUMBER) {
            value = ((ch + (val >> 9)) & 0x1F);
          }
          else if ((val & 0x0000C000) == 0x0000C000) {
            // Java supradecimal digit
            value = ((ch + (val >> 9)) & 0x1F) + 10;
          }
        }
        return (value < radix) ? value : -1;
    }

    /**
     * Returns the Unicode numeric value of the character as a
     * nonnegative integer.
     * If the character does not have a numeric value, then -1 is returned.
     * If the character has a numeric value that cannot be represented as a
     * nonnegative integer (for example, a fractional value), then -2
     * is returned.
     *
     * @param   ch      the character to be converted.
     * @param   radix   the radix.
     * @return  the numeric value of the character, as a nonnegative int value;
     *          -2 if the character has a numeric value that is not a
     *          nonnegative integer; -1 if the character has no numeric value.
     * @see     java.lang.Character#forDigit(char)
     * @see     java.lang.Character#isDigit(char)
     * @since   JDK1.1
     */
    public static int getNumericValue(char ch) {
        int val = A[Y[(X[ch>>6]<<5)|((ch>>1)&0x1F)]|(ch&0x1)];
        switch ((val >> 14) & 0x3) {
        default: // cannot occur
        case (0x00000000 >> 14):         // not numeric
            return -1;
        case (0x00004000 >> 14):              // simple numeric
            return (ch + (val >> 9)) & 0x1F;
        case (0x00008000 >> 14)      :       // "strange" numeric
            switch (ch) {
            case '\u0BF1': return 100;          // TAMIL NUMBER ONE HUNDRED
            case '\u0BF2': return 1000;         // TAMIL NUMBER ONE THOUSAND
            case '\u216C': return 50;           // ROMAN NUMERAL FIFTY
            case '\u216D': return 100;          // ROMAN NUMERAL ONE HUNDRED
            case '\u216E': return 500;          // ROMAN NUMERAL FIVE HUNDRED
            case '\u216F': return 1000;         // ROMAN NUMERAL ONE THOUSAND
            case '\u217C': return 50;           // SMALL ROMAN NUMERAL FIFTY
            case '\u217D': return 100;          // SMALL ROMAN NUMERAL ONE HUNDRED
            case '\u217E': return 500;          // SMALL ROMAN NUMERAL FIVE HUNDRED
            case '\u217F': return 1000;         // SMALL ROMAN NUMERAL ONE THOUSAND
            case '\u2180': return 1000;         // ROMAN NUMERAL ONE THOUSAND C D
            case '\u2181': return 5000;         // ROMAN NUMERAL FIVE THOUSAND
            case '\u2182': return 10000;        // ROMAN NUMERAL TEN THOUSAND
            default:       return -2;
            }
        case (0x0000C000 >> 14):           // Java supradecimal
            return ((ch + (val >> 9)) & 0x1F) + 10;
        }
    }

    /**
     * Determines if the specified character is ISO-LATIN-1 white space. 
     * This method returns <code>true</code> for the following five 
     * characters only: 
     * <table><code>
     * <tr><td>'\t'</td>  <td>&#92;u0009</td>  <td>HORIZONTAL TABULATION</td></tr>
     * <tr><td>'\n'</td>  <td>&#92;u000A</td>  <td>NEW LINE</td></tr>
     * <tr><td>'\f'</td>  <td>&#92;u000C</td>  <td>FORM FEED</td></tr>
     * <tr><td>'\r'</td>  <td>&#92;u000D</td>  <td>CARRIAGE RETURN</td></tr>
     * <tr><td>'&nbsp;&nbsp;'</td>
     *                    <td>&#92;u0020</td>  <td>SPACE</td></tr>
     * </code></table>
     *
     * @param      ch   the character to be tested.
     * @return     <code>true</code> if the character is ISO-LATIN-1 white
     *             space; <code>false</code> otherwise.
     * @see        java.lang.Character#isSpaceChar(char)
     * @see        java.lang.Character#isWhitespace(char)
     * @since      JDK1.0
     * @deprecated Replaced by isWhitespace(char).
     */
    public static boolean isSpace(char ch) {
      return (ch <= 0x0020) &&
             (((((1L << 0x0009) |
                 (1L << 0x000A) |
                 (1L << 0x000C) |
                 (1L << 0x000D) |
                 (1L << 0x0020)) >> ch) & 1L) != 0);
    }

    /**
     * Determines if the specified character is a Unicode space character.
     * A character is considered to be a space character if and only if
     * it is specified to be a space character by the Unicode 2.0 standard
     * (category "Zs", "Zl, or "Zp" in the Unicode specification data file).
     * 
     * @param   ch      the character to be tested.
     * @return  true if the character is a space character; false otherwise.
     * @see     java.lang.Character#isWhitespace(char)
     * @since   JDK1.1
     */
    public static boolean isSpaceChar(char ch) {
        return (((((1 << SPACE_SEPARATOR) |
                   (1 << LINE_SEPARATOR) |
                   (1 << PARAGRAPH_SEPARATOR))
                  >> (A[Y[(X[ch>>6]<<5)|((ch>>1)&0x1F)]|(ch&0x1)] & 0x1F)) & 1) != 0);
    }

    /**
     * Determines if the specified character is white space according to Java.
     * A character is considered to be a Java whitespace character if and only
     * if it satisfies one of the following criteria:
     * <ul>
     * <li> It is a Unicode space separator (category "Zs"), but is not
     *      a no-break space (&#92;u00A0 or &#92;uFEFF).
     * <li> It is a Unicode line separator (category "Zl").
     * <li> It is a Unicode paragraph separator (category "Zp").
     * <li> It is &#92;u0009, HORIZONTAL TABULATION.
     * <li> It is &#92;u000A, LINE FEED.
     * <li> It is &#92;u000B, VERTICAL TABULATION.
     * <li> It is &#92;u000C, FORM FEED.
     * <li> It is &#92;u000D, CARRIAGE RETURN.
     * <li> It is &#92;u001C, FILE SEPARATOR.
     * <li> It is &#92;u001D, GROUP SEPARATOR.
     * <li> It is &#92;u001E, RECORD SEPARATOR.
     * <li> It is &#92;u001F, UNIT SEPARATOR.
     * </ul>
     *
     * @param   ch      the character to be tested.
     * @return  true if the character is a Java whitespace character;
     *          false otherwise.
     * @see     java.lang.Character#isSpaceChar(char)
     * @since   JDK1.1
     */
    public static boolean isWhitespace(char ch) {
      return (A[Y[(X[ch>>6]<<5)|((ch>>1)&0x1F)]|(ch&0x1)] & 0x00070000) == 0x00040000;
    }

    /**
     * Determines if the specified character is an ISO control character.
     * A character is considered to be an ISO control character if its
     * code is in the range &#92;u0000 through &#92;u001F or in the range
     * &#92;u007F through &#92;u009F.
     *
     * @param   ch      the character to be tested.
     * @return  true if the character is an ISO control character;
     *          false otherwise.
     *
     * @see     java.lang.Character#isSpaceChar(char)
     * @see     java.lang.Character#isWhitespace(char)
     * @since   JDK1.1
     */
    public static boolean isISOControl(char ch) {
      return (ch <= 0x009F) && ((ch <= 0x001F) || (ch >= 0x007F));
    }

    /**
     * Returns a value indicating a character category.
     *
     * @param   ch      the character to be tested.
     * @return  a value of type int, the character category.
     * @see     java.lang.Character#COMBINING_SPACING_MARK
     * @see     java.lang.Character#CONNECTOR_PUNCTUATION
     * @see     java.lang.Character#CONTROL
     * @see     java.lang.Character#CURRENCY_SYMBOL
     * @see     java.lang.Character#DASH_PUNCTUATION
     * @see     java.lang.Character#DECIMAL_DIGIT_NUMBER
     * @see     java.lang.Character#ENCLOSING_MARK
     * @see     java.lang.Character#END_PUNCTUATION
     * @see     java.lang.Character#FORMAT
     * @see     java.lang.Character#LETTER_NUMBER
     * @see     java.lang.Character#LINE_SEPARATOR
     * @see     java.lang.Character#LOWERCASE_LETTER
     * @see     java.lang.Character#MATH_SYMBOL
     * @see     java.lang.Character#MODIFIER_LETTER
     * @see     java.lang.Character#MODIFIER_SYMBOL
     * @see     java.lang.Character#NON_SPACING_MARK
     * @see     java.lang.Character#OTHER_LETTER
     * @see     java.lang.Character#OTHER_NUMBER
     * @see     java.lang.Character#OTHER_PUNCTUATION
     * @see     java.lang.Character#OTHER_SYMBOL
     * @see     java.lang.Character#PARAGRAPH_SEPARATOR
     * @see     java.lang.Character#PRIVATE_USE
     * @see     java.lang.Character#SPACE_SEPARATOR
     * @see     java.lang.Character#START_PUNCTUATION
     * @see     java.lang.Character#SURROGATE
     * @see     java.lang.Character#TITLECASE_LETTER
     * @see     java.lang.Character#UNASSIGNED
     * @see     java.lang.Character#UPPERCASE_LETTER
     * @since   JDK1.1
     */
    public static int getType(char ch) {
        return A[Y[(X[ch>>6]<<5)|((ch>>1)&0x1F)]|(ch&0x1)] & 0x1F;
    }

    /**
     * Determines the character representation for a specific digit in 
     * the specified radix. If the value of <code>radix</code> is not a 
     * valid radix, or the value of <code>digit</code> is not a valid 
     * digit in the specified radix, the null character 
     * (<code>'&#92;u0000'</code>) is returned. 
     * <p>
     * The <code>radix</code> argument is valid if it is greater than or 
     * equal to <code>MIN_RADIX</code> and less than or equal to 
     * <code>MAX_RADIX</code>. The <code>digit</code> argument is valid if
     * <code>0&nbsp;&lt;= digit&nbsp;&lt;=&nbsp;radix</code>. 
     * <p>
     * If the digit is less than 10, then 
     * <code>'0'&nbsp;+ digit</code> is returned. Otherwise, the value 
     * <code>'a'&nbsp;+ digit&nbsp;-&nbsp;10</code> is returned. 
     *
     * @param   digit   the number to convert to a character.
     * @param   radix   the radix.
     * @return  the <code>char</code> representation of the specified digit
     *          in the specified radix. 
     * @see     java.lang.Character#MIN_RADIX
     * @see     java.lang.Character#MAX_RADIX
     * @see     java.lang.Character#digit(char, int)
     * @since   JDK1.0
     */
    public static char forDigit(int digit, int radix) {
        if ((digit >= radix) || (digit < 0)) {
            return '\0';
        }
        if ((radix < MIN_RADIX) || (radix > MAX_RADIX)) {
            return '\0';
        }
        if (digit < 10) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -