src/share/classes/java/lang/String.java

Print this page
rev 7972 : [mq]: 8023943


2635                 result[i + resultOffset] = (char)lowerChar;
2636             }
2637         }
2638         return new String(result, 0, len + resultOffset);
2639     }
2640 
2641     /**
2642      * Converts all of the characters in this {@code String} to lower
2643      * case using the rules of the default locale. This is equivalent to calling
2644      * {@code toLowerCase(Locale.getDefault())}.
2645      * <p>
2646      * <b>Note:</b> This method is locale sensitive, and may produce unexpected
2647      * results if used for strings that are intended to be interpreted locale
2648      * independently.
2649      * Examples are programming language identifiers, protocol keys, and HTML
2650      * tags.
2651      * For instance, {@code "TITLE".toLowerCase()} in a Turkish locale
2652      * returns {@code "t\u005Cu0131tle"}, where '\u005Cu0131' is the
2653      * LATIN SMALL LETTER DOTLESS I character.
2654      * To obtain correct results for locale insensitive strings, use
2655      * {@code toLowerCase(Locale.ENGLISH)}.
2656      * <p>
2657      * @return  the {@code String}, converted to lowercase.
2658      * @see     java.lang.String#toLowerCase(Locale)
2659      */
2660     public String toLowerCase() {
2661         return toLowerCase(Locale.getDefault());
2662     }
2663 
2664     /**
2665      * Converts all of the characters in this {@code String} to upper
2666      * case using the rules of the given {@code Locale}. Case mapping is based
2667      * on the Unicode Standard version specified by the {@link java.lang.Character Character}
2668      * class. Since case mappings are not always 1:1 char mappings, the resulting
2669      * {@code String} may be a different length than the original {@code String}.
2670      * <p>
2671      * Examples of locale-sensitive and 1:M case mappings are in the following table.
2672      * <p>
2673      * <table border="1" summary="Examples of locale-sensitive and 1:M case mappings. Shows Language code of locale, lower case, upper case, and description.">
2674      * <tr>
2675      *   <th>Language Code of Locale</th>


2798                 result[i + resultOffset] = (char)upperChar;
2799             }
2800         }
2801         return new String(result, 0, len + resultOffset);
2802     }
2803 
2804     /**
2805      * Converts all of the characters in this {@code String} to upper
2806      * case using the rules of the default locale. This method is equivalent to
2807      * {@code toUpperCase(Locale.getDefault())}.
2808      * <p>
2809      * <b>Note:</b> This method is locale sensitive, and may produce unexpected
2810      * results if used for strings that are intended to be interpreted locale
2811      * independently.
2812      * Examples are programming language identifiers, protocol keys, and HTML
2813      * tags.
2814      * For instance, {@code "title".toUpperCase()} in a Turkish locale
2815      * returns {@code "T\u005Cu0130TLE"}, where '\u005Cu0130' is the
2816      * LATIN CAPITAL LETTER I WITH DOT ABOVE character.
2817      * To obtain correct results for locale insensitive strings, use
2818      * {@code toUpperCase(Locale.ENGLISH)}.
2819      * <p>
2820      * @return  the {@code String}, converted to uppercase.
2821      * @see     java.lang.String#toUpperCase(Locale)
2822      */
2823     public String toUpperCase() {
2824         return toUpperCase(Locale.getDefault());
2825     }
2826 
2827     /**
2828      * Returns a copy of the string, with leading and trailing whitespace
2829      * omitted.
2830      * <p>
2831      * If this {@code String} object represents an empty character
2832      * sequence, or the first and last characters of character sequence
2833      * represented by this {@code String} object both have codes
2834      * greater than {@code '\u005Cu0020'} (the space character), then a
2835      * reference to this {@code String} object is returned.
2836      * <p>
2837      * Otherwise, if there is no character with a code greater than
2838      * {@code '\u005Cu0020'} in the string, then a new




2635                 result[i + resultOffset] = (char)lowerChar;
2636             }
2637         }
2638         return new String(result, 0, len + resultOffset);
2639     }
2640 
2641     /**
2642      * Converts all of the characters in this {@code String} to lower
2643      * case using the rules of the default locale. This is equivalent to calling
2644      * {@code toLowerCase(Locale.getDefault())}.
2645      * <p>
2646      * <b>Note:</b> This method is locale sensitive, and may produce unexpected
2647      * results if used for strings that are intended to be interpreted locale
2648      * independently.
2649      * Examples are programming language identifiers, protocol keys, and HTML
2650      * tags.
2651      * For instance, {@code "TITLE".toLowerCase()} in a Turkish locale
2652      * returns {@code "t\u005Cu0131tle"}, where '\u005Cu0131' is the
2653      * LATIN SMALL LETTER DOTLESS I character.
2654      * To obtain correct results for locale insensitive strings, use
2655      * {@code toLowerCase(Locale.ROOT)}.
2656      * <p>
2657      * @return  the {@code String}, converted to lowercase.
2658      * @see     java.lang.String#toLowerCase(Locale)
2659      */
2660     public String toLowerCase() {
2661         return toLowerCase(Locale.getDefault());
2662     }
2663 
2664     /**
2665      * Converts all of the characters in this {@code String} to upper
2666      * case using the rules of the given {@code Locale}. Case mapping is based
2667      * on the Unicode Standard version specified by the {@link java.lang.Character Character}
2668      * class. Since case mappings are not always 1:1 char mappings, the resulting
2669      * {@code String} may be a different length than the original {@code String}.
2670      * <p>
2671      * Examples of locale-sensitive and 1:M case mappings are in the following table.
2672      * <p>
2673      * <table border="1" summary="Examples of locale-sensitive and 1:M case mappings. Shows Language code of locale, lower case, upper case, and description.">
2674      * <tr>
2675      *   <th>Language Code of Locale</th>


2798                 result[i + resultOffset] = (char)upperChar;
2799             }
2800         }
2801         return new String(result, 0, len + resultOffset);
2802     }
2803 
2804     /**
2805      * Converts all of the characters in this {@code String} to upper
2806      * case using the rules of the default locale. This method is equivalent to
2807      * {@code toUpperCase(Locale.getDefault())}.
2808      * <p>
2809      * <b>Note:</b> This method is locale sensitive, and may produce unexpected
2810      * results if used for strings that are intended to be interpreted locale
2811      * independently.
2812      * Examples are programming language identifiers, protocol keys, and HTML
2813      * tags.
2814      * For instance, {@code "title".toUpperCase()} in a Turkish locale
2815      * returns {@code "T\u005Cu0130TLE"}, where '\u005Cu0130' is the
2816      * LATIN CAPITAL LETTER I WITH DOT ABOVE character.
2817      * To obtain correct results for locale insensitive strings, use
2818      * {@code toUpperCase(Locale.ROOT)}.
2819      * <p>
2820      * @return  the {@code String}, converted to uppercase.
2821      * @see     java.lang.String#toUpperCase(Locale)
2822      */
2823     public String toUpperCase() {
2824         return toUpperCase(Locale.getDefault());
2825     }
2826 
2827     /**
2828      * Returns a copy of the string, with leading and trailing whitespace
2829      * omitted.
2830      * <p>
2831      * If this {@code String} object represents an empty character
2832      * sequence, or the first and last characters of character sequence
2833      * represented by this {@code String} object both have codes
2834      * greater than {@code '\u005Cu0020'} (the space character), then a
2835      * reference to this {@code String} object is returned.
2836      * <p>
2837      * Otherwise, if there is no character with a code greater than
2838      * {@code '\u005Cu0020'} in the string, then a new