mirror of
https://github.com/apache/commons-lang.git
synced 2025-03-02 14:09:09 +00:00
Deprecated the 'capitalise' spelling and introduced the 'capitalize' spelling.
Despite the UK [or international] English base of many of the developers on Lang, it was felt that it would be better to match Jakarta as a whole. Also none of us cared enough to make it an issue. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137589 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1a99abf1cf
commit
cd5c0cdb42
src
@ -84,7 +84,7 @@
|
||||
* - removes the last part of a String
|
||||
* <li><b>LeftPad/RightPad/Center/Repeat</b>
|
||||
* - pads a String
|
||||
* <li><b>UpperCase/LowerCase/SwapCase/Capitalise/Uncapitalise</b>
|
||||
* <li><b>UpperCase/LowerCase/SwapCase/Capitalize/Uncapitalize</b>
|
||||
* - change the case of a String
|
||||
* <li><b>NestedString</b>
|
||||
* - returns a substring nested within other Strings
|
||||
@ -144,7 +144,7 @@
|
||||
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
|
||||
* @author Phil Steitz
|
||||
* @since 1.0
|
||||
* @version $Id: StringUtils.java,v 1.93 2003/08/13 23:30:58 scolebourne Exp $
|
||||
* @version $Id: StringUtils.java,v 1.94 2003/08/14 00:04:20 bayard Exp $
|
||||
*/
|
||||
public class StringUtils {
|
||||
// Performance testing notes (JDK 1.4, Jul03, scolebourne)
|
||||
@ -3410,22 +3410,22 @@ public static String lowerCase(String str) {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Capitalises a String changing the first letter to title case as
|
||||
* <p>Capitalizes a String changing the first letter to title case as
|
||||
* per {@link Character#toTitleCase(char)}. No other letters are changed.</p>
|
||||
*
|
||||
* <p>A <code>null</code> input String returns <code>null</code>.</p>
|
||||
*
|
||||
* <pre>
|
||||
* StringUtils.capitalise(null) = null
|
||||
* StringUtils.capitalise("") = ""
|
||||
* StringUtils.capitalise("cat") = "Cat"
|
||||
* StringUtils.capitalise("cAt") = "CAt"
|
||||
* StringUtils.capitalize(null) = null
|
||||
* StringUtils.capitalize("") = ""
|
||||
* StringUtils.capitalize("cat") = "Cat"
|
||||
* StringUtils.capitalize("cAt") = "CAt"
|
||||
* </pre>
|
||||
*
|
||||
* @param str the String to capitalise, may be null
|
||||
* @return the capitalised String, <code>null</code> if null String input
|
||||
* @param str the String to capitalize, may be null
|
||||
* @return the capitalized String, <code>null</code> if null String input
|
||||
*/
|
||||
public static String capitalise(String str) {
|
||||
public static String capitalize(String str) {
|
||||
int strLen;
|
||||
if (str == null || (strLen = str.length()) == 0) {
|
||||
return str;
|
||||
@ -3437,22 +3437,29 @@ public static String capitalise(String str) {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Uncapitalises a String changing the first letter to title case as
|
||||
* @deprecated Use the standardly named {@link #capitalize(String)}.
|
||||
*/
|
||||
public static String capitalise(String str) {
|
||||
return capitalize(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Uncapitalizes a String changing the first letter to title case as
|
||||
* per {@link Character#toLowerCase(char)}. No other letters are changed.</p>
|
||||
*
|
||||
* <p>A <code>null</code> input String returns <code>null</code>.</p>
|
||||
*
|
||||
* <pre>
|
||||
* StringUtils.uncapitalise(null) = null
|
||||
* StringUtils.uncapitalise("") = ""
|
||||
* StringUtils.uncapitalise("Cat") = "cat"
|
||||
* StringUtils.uncapitalise("CAT") = "cAT"
|
||||
* StringUtils.uncapitalize(null) = null
|
||||
* StringUtils.uncapitalize("") = ""
|
||||
* StringUtils.uncapitalize("Cat") = "cat"
|
||||
* StringUtils.uncapitalize("CAT") = "cAT"
|
||||
* </pre>
|
||||
*
|
||||
* @param str the String to uncapitalise, may be null
|
||||
* @return the uncapitalised String, <code>null</code> if null String input
|
||||
* @param str the String to uncapitalize, may be null
|
||||
* @return the uncapitalized String, <code>null</code> if null String input
|
||||
*/
|
||||
public static String uncapitalise(String str) {
|
||||
public static String uncapitalize(String str) {
|
||||
int strLen;
|
||||
if (str == null || (strLen = str.length()) == 0) {
|
||||
return str;
|
||||
@ -3463,6 +3470,13 @@ public static String uncapitalise(String str) {
|
||||
.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use the standardly named {@link #uncapitalize(String)}.
|
||||
*/
|
||||
public static String uncapitalise(String str) {
|
||||
return uncapitalize(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Swaps the case of a String using a word based algorithm.</p>
|
||||
*
|
||||
@ -3518,22 +3532,22 @@ public static String swapCase(String str) {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Capitalises all the whitespace separated words in a String.
|
||||
* <p>Capitalizes all the whitespace separated words in a String.
|
||||
* Only the first letter of each word is changed.</p>
|
||||
*
|
||||
* <p>Whitespace is defined by {@link Character#isWhitespace(char)}.
|
||||
* A <code>null</code> input String returns <code>null</code>.</p>
|
||||
*
|
||||
* <pre>
|
||||
* StringUtils.capitaliseAllWords(null) = null
|
||||
* StringUtils.capitaliseAllWords("") = ""
|
||||
* StringUtils.capitaliseAllWords("i am FINE") = "I Am FINE"
|
||||
* StringUtils.capitalizeAllWords(null) = null
|
||||
* StringUtils.capitalizeAllWords("") = ""
|
||||
* StringUtils.capitalizeAllWords("i am FINE") = "I Am FINE"
|
||||
* </pre>
|
||||
*
|
||||
* @param str the String to capitalise, may be null
|
||||
* @return capitalised String, <code>null</code> if null String input
|
||||
* @param str the String to capitalize, may be null
|
||||
* @return capitalized String, <code>null</code> if null String input
|
||||
*/
|
||||
public static String capitaliseAllWords(String str) {
|
||||
public static String capitalizeAllWords(String str) {
|
||||
int strLen;
|
||||
if (str == null || (strLen = str.length()) == 0) {
|
||||
return str;
|
||||
@ -3556,22 +3570,29 @@ public static String capitaliseAllWords(String str) {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Uncapitalises all the whitespace separated words in a String.
|
||||
* @deprecated Use the standardly named {@link #capitalize(String)}.
|
||||
*/
|
||||
public static String capitaliseAllWords(String str) {
|
||||
return capitalizeAllWords(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Uncapitalizes all the whitespace separated words in a String.
|
||||
* Only the first letter of each word is changed.</p>
|
||||
*
|
||||
* <p>Whitespace is defined by {@link Character#isWhitespace(char)}.
|
||||
* A <code>null</code> input String returns <code>null</code>.</p>
|
||||
*
|
||||
* <pre>
|
||||
* StringUtils.uncapitaliseAllWords(null) = null
|
||||
* StringUtils.uncapitaliseAllWords("") = ""
|
||||
* StringUtils.uncapitaliseAllWords("I Am FINE") = "i am fINE"
|
||||
* StringUtils.uncapitalizeAllWords(null) = null
|
||||
* StringUtils.uncapitalizeAllWords("") = ""
|
||||
* StringUtils.uncapitalizeAllWords("I Am FINE") = "i am fINE"
|
||||
* </pre>
|
||||
*
|
||||
* @param str the String to uncapitalise, may be null
|
||||
* @return uncapitalised String, <code>null</code> if null String input
|
||||
* @param str the String to uncapitalize, may be null
|
||||
* @return uncapitalized String, <code>null</code> if null String input
|
||||
*/
|
||||
public static String uncapitaliseAllWords(String str) {
|
||||
public static String uncapitalizeAllWords(String str) {
|
||||
int strLen;
|
||||
if (str == null || (strLen = str.length()) == 0) {
|
||||
return str;
|
||||
@ -3593,6 +3614,13 @@ public static String uncapitaliseAllWords(String str) {
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use the standardly named {@link #uncapitalize(String)}.
|
||||
*/
|
||||
public static String uncapitaliseAllWords(String str) {
|
||||
return uncapitalizeAllWords(str);
|
||||
}
|
||||
|
||||
// Count matches
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -74,7 +74,7 @@
|
||||
* @author Holger Krauth
|
||||
* @author <a href="hps@intermeta.de">Henning P. Schmiedehausen</a>
|
||||
* @author Phil Steitz
|
||||
* @version $Id: StringUtilsTest.java,v 1.46 2003/08/13 23:08:06 scolebourne Exp $
|
||||
* @version $Id: StringUtilsTest.java,v 1.47 2003/08/14 00:04:20 bayard Exp $
|
||||
*/
|
||||
public class StringUtilsTest extends TestCase {
|
||||
|
||||
@ -162,31 +162,31 @@ public void testCaseFunctions() {
|
||||
assertEquals(null, StringUtils.upperCase(null));
|
||||
assertEquals(null, StringUtils.lowerCase(null));
|
||||
assertEquals(null, StringUtils.swapCase(null));
|
||||
assertEquals(null, StringUtils.capitalise(null));
|
||||
assertEquals(null, StringUtils.uncapitalise(null));
|
||||
assertEquals(null, StringUtils.capitaliseAllWords(null));
|
||||
assertEquals(null, StringUtils.uncapitaliseAllWords(null));
|
||||
assertEquals(null, StringUtils.capitalize(null));
|
||||
assertEquals(null, StringUtils.uncapitalize(null));
|
||||
assertEquals(null, StringUtils.capitalizeAllWords(null));
|
||||
assertEquals(null, StringUtils.uncapitalizeAllWords(null));
|
||||
|
||||
assertEquals("capitalise(String) failed",
|
||||
CAP_FOO, StringUtils.capitalise(FOO) );
|
||||
assertEquals("capitalise(empty-string) failed",
|
||||
"", StringUtils.capitalise("") );
|
||||
assertEquals("capitalise(single-char-string) failed",
|
||||
"X", StringUtils.capitalise("x") );
|
||||
assertEquals("capitaliseAllWords(String) failed",
|
||||
"Foo Bar Baz", StringUtils.capitaliseAllWords(SENTENCE) );
|
||||
assertEquals("capitaliseAllWords(empty-string) failed",
|
||||
"", StringUtils.capitaliseAllWords("") );
|
||||
assertEquals("uncapitalise(String) failed",
|
||||
FOO, StringUtils.uncapitalise(CAP_FOO) );
|
||||
assertEquals("uncapitalise(empty-string) failed",
|
||||
"", StringUtils.uncapitalise("") );
|
||||
assertEquals("uncapitalise(single-char-string) failed",
|
||||
"x", StringUtils.uncapitalise("X") );
|
||||
assertEquals("uncapitaliseAllWords(String) failed",
|
||||
SENTENCE, StringUtils.uncapitaliseAllWords("Foo Bar Baz") );
|
||||
assertEquals("uncapitaliseAllWords(empty-string) failed",
|
||||
"", StringUtils.uncapitaliseAllWords("") );
|
||||
assertEquals("capitalize(String) failed",
|
||||
CAP_FOO, StringUtils.capitalize(FOO) );
|
||||
assertEquals("capitalize(empty-string) failed",
|
||||
"", StringUtils.capitalize("") );
|
||||
assertEquals("capitalize(single-char-string) failed",
|
||||
"X", StringUtils.capitalize("x") );
|
||||
assertEquals("capitalizeAllWords(String) failed",
|
||||
"Foo Bar Baz", StringUtils.capitalizeAllWords(SENTENCE) );
|
||||
assertEquals("capitalizeAllWords(empty-string) failed",
|
||||
"", StringUtils.capitalizeAllWords("") );
|
||||
assertEquals("uncapitalize(String) failed",
|
||||
FOO, StringUtils.uncapitalize(CAP_FOO) );
|
||||
assertEquals("uncapitalize(empty-string) failed",
|
||||
"", StringUtils.uncapitalize("") );
|
||||
assertEquals("uncapitalize(single-char-string) failed",
|
||||
"x", StringUtils.uncapitalize("X") );
|
||||
assertEquals("uncapitalizeAllWords(String) failed",
|
||||
SENTENCE, StringUtils.uncapitalizeAllWords("Foo Bar Baz") );
|
||||
assertEquals("uncapitalizeAllWords(empty-string) failed",
|
||||
"", StringUtils.uncapitalizeAllWords("") );
|
||||
|
||||
assertEquals("upperCase(String) failed",
|
||||
"FOO TEST THING", StringUtils.upperCase("fOo test THING") );
|
||||
|
Loading…
x
Reference in New Issue
Block a user