具体是怎么实现的呢,我如何才能看见其源代码?

解决方案 »

  1.   

    public String toUpperCase(Locale locale) {
            int     len        = count;
            int     off        = offset;
            char[]  val        = value;
            int     firstLower;        /* Now check if there are any characters that need changing. */
            scan: {
                char upperCaseChar;
                char c;
                for (firstLower = 0 ; firstLower < len ; firstLower++) {
                    c = value[off+firstLower];
                    upperCaseChar = Character.toUpperCaseEx(c);
                    if (upperCaseChar == Character.CHAR_ERROR || c != upperCaseChar) {
                        break scan;
                    }
                }
                return this;
            }        char[]  result       = new char[len]; /* might grow! */
    int     resultOffset = 0;  /* result grows, so i+resultOffset
        * is the write location in result */ /* Just copy the first few upperCase characters. */
    System.arraycopy(val, off, result, 0, firstLower);        if (locale.getLanguage().equals("tr")) {
                // special loop for Turkey
                char[] upperCharArray;
                char upperChar;
                char ch;            for (int i = firstLower; i < len; ++i) {
                    ch = val[off+i];
                    if (ch == 'i') {
                        result[i+resultOffset] = '\u0130';  // dotted cap i
                        continue;
                    }
                    if (ch == '\u0131') {                   // dotless i
                        result[i+resultOffset] = 'I';       // cap I
                        continue;
                    }
                    upperChar = Character.toUpperCaseEx(ch);
                    if (upperChar == Character.CHAR_ERROR) {
                        upperCharArray = Character.toUpperCaseCharArray(ch);
                        /* Grow result. */
                        int mapLen = upperCharArray.length;
                        char[] result2 = new char[result.length + mapLen - 1];
                        System.arraycopy(result, 0, result2, 0,
                            i + 1 + resultOffset);
                        for (int x=0; x<mapLen; ++x) {
                            result2[i+resultOffset++] = upperCharArray[x];
                        }
                        --resultOffset;
                        result = result2;
                    }
                    else {
                        result[i+resultOffset] = upperChar;
                    }
                }
            } else {
                // normal, fast loop
                char[] upperCharArray;
                char upperChar;
                char ch;
                for (int i = firstLower; i < len; ++i) {
                    ch = val[off+i];
                    upperChar = Character.toUpperCaseEx(ch);
                    if (upperChar == Character.CHAR_ERROR) {
                        upperCharArray = Character.toUpperCaseCharArray(ch);
                        /* Grow result. */
                        int mapLen = upperCharArray.length;
                        char[] result2 = new char[result.length + mapLen - 1];
                        System.arraycopy(result, 0, result2, 0,
                            i + 1 + resultOffset);
                        for (int x=0; x<mapLen; ++x) {
                            result2[i+resultOffset++] = upperCharArray[x];
                        }
                        --resultOffset;
                        result = result2;
                    }
                    else {
                        result[i+resultOffset] = upperChar;
                    }
                }
            }
            return new String(0, result.length, result);
        }