Removing deprecated methods. Adding the CharSet.getInstance(String[]) method from trunk:r534588.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/branches/LangTwo-1.x@534590 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/java/org/apache/commons/lang2/CharSet.java b/src/java/org/apache/commons/lang2/CharSet.java
index 385da65..7ec0892 100644
--- a/src/java/org/apache/commons/lang2/CharSet.java
+++ b/src/java/org/apache/commons/lang2/CharSet.java
@@ -146,6 +146,20 @@
return new CharSet(setStr);
}
+
+ /**
+ * <p>Constructs a new CharSet using the set syntax.
+ * Each string is merged in with the set.</p>
+ *
+ * @param set Strings to merge into the initial set, may be null
+ */
+ public static CharSet getInstance(String[] setStrs) {
+ if (setStrs == null) {
+ return null;
+ }
+ return new CharSet(setStrs);
+ }
+
//-----------------------------------------------------------------------
/**
* <p>Constructs a new CharSet using the set syntax.</p>
diff --git a/src/java/org/apache/commons/lang2/CharSetUtils.java b/src/java/org/apache/commons/lang2/CharSetUtils.java
index 7920992..fa0b52b 100644
--- a/src/java/org/apache/commons/lang2/CharSetUtils.java
+++ b/src/java/org/apache/commons/lang2/CharSetUtils.java
@@ -34,7 +34,7 @@
/**
* <p>CharSetUtils instances should NOT be constructed in standard programming.
- * Instead, the class should be used as <code>CharSetUtils.evaluateSet(null);</code>.</p>
+ * Instead, the class should be used as <code>CharSet.getInstance(null);</code>.</p>
*
* <p>This constructor is public to permit tools that require a JavaBean instance
* to operate.</p>
@@ -43,36 +43,6 @@
super();
}
- // Factory
- //-----------------------------------------------------------------------
- /**
- * <p>Creates a <code>CharSet</code> instance which allows a certain amount of
- * set logic to be performed.</p>
- * <p>The syntax is:</p>
- * <ul>
- * <li>"aeio" which implies 'a','e',..</li>
- * <li>"^e" implies not e.</li>
- * <li>"ej-m" implies e,j->m. e,j,k,l,m.</li>
- * </ul>
- *
- * <pre>
- * CharSetUtils.evaluateSet(null) = null
- * CharSetUtils.evaluateSet([]) = CharSet matching nothing
- * CharSetUtils.evaluateSet(["a-e"]) = CharSet matching a,b,c,d,e
- * </pre>
- *
- * @param set the set, may be null
- * @return a CharSet instance, <code>null</code> if null input
- * @deprecated Use {@link CharSet#getInstance(String)}.
- * Method will be removed in Commons Lang 3.0.
- */
- public static CharSet evaluateSet(String[] set) {
- if (set == null) {
- return null;
- }
- return new CharSet(set);
- }
-
// Squeeze
//-----------------------------------------------------------------------
/**
@@ -88,7 +58,7 @@
* CharSetUtils.squeeze("hello", "a-e") = "hello"
* </pre>
*
- * @see #evaluateSet(java.lang.String[]) for set-syntax.
+ * @see CharSet#getInstance(java.lang.String[]) for set-syntax.
* @param str the string to squeeze, may be null
* @param set the character set to use for manipulation, may be null
* @return modified String, <code>null</code> if null string input
@@ -111,7 +81,7 @@
* <li>squeeze("hello", {"el"}) => "helo"</li>
* </ul>
*
- * @see #evaluateSet(java.lang.String[]) for set-syntax.
+ * @see CharSet#getInstance(java.lang.String[]) for set-syntax.
* @param str the string to squeeze, may be null
* @param set the character set to use for manipulation, may be null
* @return modified String, <code>null</code> if null string input
@@ -120,7 +90,7 @@
if (StringUtils.isEmpty(str) || ArrayUtils.isEmpty(set)) {
return str;
}
- CharSet chars = evaluateSet(set);
+ CharSet chars = CharSet.getInstance(set);
StringBuffer buffer = new StringBuffer(str.length());
char[] chrs = str.toCharArray();
int sz = chrs.length;
@@ -142,7 +112,7 @@
// Count
//-----------------------------------------------------------------------
/**
- * <p>Takes an argument in set-syntax, see evaluateSet,
+ * <p>Takes an argument in set-syntax, see CharSet#getInstance(String[]),
* and returns the number of characters present in the specified string.</p>
*
* <pre>
@@ -153,8 +123,8 @@
* CharSetUtils.count("hello", "k-p") = 3
* CharSetUtils.count("hello", "a-e") = 1
* </pre>
- *
- * @see #evaluateSet(java.lang.String[]) for set-syntax.
+ #
+ * @see CharSet#getInstance(java.lang.String[]) for set-syntax.
* @param str String to count characters in, may be null
* @param set String set of characters to count, may be null
* @return character count, zero if null string input
@@ -169,7 +139,7 @@
}
/**
- * <p>Takes an argument in set-syntax, see evaluateSet,
+ * <p>Takes an argument in set-syntax, see CharSet#getInstance(String[]),
* and returns the number of characters present in the specified string.</p>
*
* <p>An example would be:</p>
@@ -177,7 +147,7 @@
* <li>count("hello", {"c-f", "o"}) returns 2.</li>
* </ul>
*
- * @see #evaluateSet(java.lang.String[]) for set-syntax.
+ * @see CharSet#getInstance(java.lang.String[]) for set-syntax.
* @param str String to count characters in, may be null
* @param set String[] set of characters to count, may be null
* @return character count, zero if null string input
@@ -186,7 +156,7 @@
if (StringUtils.isEmpty(str) || ArrayUtils.isEmpty(set)) {
return 0;
}
- CharSet chars = evaluateSet(set);
+ CharSet chars = CharSet.getInstance(set);
int count = 0;
char[] chrs = str.toCharArray();
int sz = chrs.length;
@@ -201,7 +171,7 @@
// Keep
//-----------------------------------------------------------------------
/**
- * <p>Takes an argument in set-syntax, see evaluateSet,
+ * <p>Takes an argument in set-syntax, see CharSet#getInstance(String[]),
* and keeps any of characters present in the specified string.</p>
*
* <pre>
@@ -213,7 +183,7 @@
* CharSetUtils.keep("hello", "le") = "ell"
* </pre>
*
- * @see #evaluateSet(java.lang.String[]) for set-syntax.
+ * @see CharSet#getInstance(java.lang.String[]) for set-syntax.
* @param str String to keep characters from, may be null
* @param set String set of characters to keep, may be null
* @return modified String, <code>null</code> if null string input
@@ -232,7 +202,7 @@
}
/**
- * <p>Takes an argument in set-syntax, see evaluateSet,
+ * <p>Takes an argument in set-syntax, see CharSet#getInstance(String[]),
* and keeps any of characters present in the specified string.</p>
*
* <p>An example would be:</p>
@@ -241,7 +211,7 @@
* returns "eo"</li>
* </ul>
*
- * @see #evaluateSet(java.lang.String[]) for set-syntax.
+ * @see CharSet#getInstance(java.lang.String[]) for set-syntax.
* @param str String to keep characters from, may be null
* @param set String[] set of characters to keep, may be null
* @return modified String, <code>null</code> if null string input
@@ -260,7 +230,7 @@
// Delete
//-----------------------------------------------------------------------
/**
- * <p>Takes an argument in set-syntax, see evaluateSet,
+ * <p>Takes an argument in set-syntax, see CharSet#getInstance(String[]),
* and deletes any of characters present in the specified string.</p>
*
* <pre>
@@ -272,7 +242,7 @@
* CharSetUtils.delete("hello", "le") = "ho"
* </pre>
*
- * @see #evaluateSet(java.lang.String[]) for set-syntax.
+ * @see CharSet#getInstance(java.lang.String[]) for set-syntax.
* @param str String to delete characters from, may be null
* @param set String set of characters to delete, may be null
* @return modified String, <code>null</code> if null string input
@@ -287,7 +257,7 @@
}
/**
- * <p>Takes an argument in set-syntax, see evaluateSet,
+ * <p>Takes an argument in set-syntax, see CharSet#getInstance(String[]),
* and deletes any of characters present in the specified string.</p>
*
* <p>An example would be:</p>
@@ -296,7 +266,7 @@
* "hll"</li>
* </ul>
*
- * @see #evaluateSet(java.lang.String[]) for set-syntax.
+ * @see CharSet#getInstance(java.lang.String[]) for set-syntax.
* @param str String to delete characters from, may be null
* @param set String[] set of characters to delete, may be null
* @return modified String, <code>null</code> if null string input
@@ -318,7 +288,7 @@
* @return modified String
*/
private static String modify(String str, String[] set, boolean expect) {
- CharSet chars = evaluateSet(set);
+ CharSet chars = CharSet.getInstance(set);
StringBuffer buffer = new StringBuffer(str.length());
char[] chrs = str.toCharArray();
int sz = chrs.length;
@@ -330,61 +300,4 @@
return buffer.toString();
}
- // Translate
- //-----------------------------------------------------------------------
- /**
- * <p>Translate characters in a String.
- * This is a multi character search and replace routine.</p>
- *
- * <p>An example is:</p>
- * <ul>
- * <li>translate("hello", "ho", "jy")
- * => jelly</li>
- * </ul>
- *
- * <p>If the length of characters to search for is greater than the
- * length of characters to replace, then the last character is
- * used.</p>
- *
- * <pre>
- * CharSetUtils.translate(null, *, *) = null
- * CharSetUtils.translate("", *, *) = ""
- * </pre>
- *
- * @param str String to replace characters in, may be null
- * @param searchChars a set of characters to search for, must not be null
- * @param replaceChars a set of characters to replace, must not be null or empty ("")
- * @return translated String, <code>null</code> if null string input
- * @throws NullPointerException if <code>searchChars</code> or <code>replaceChars</code>
- * is <code>null</code>
- * @throws ArrayIndexOutOfBoundsException if <code>replaceChars</code> is empty ("")
- * @deprecated Use {@link StringUtils#replaceChars(String, String, String)}.
- * Method will be removed in Commons Lang 3.0.
- * NOTE: StringUtils#replaceChars behaves differently when 'searchChars' is longer
- * than 'replaceChars'. CharSetUtils#translate will use the last char of the replacement
- * string whereas StringUtils#replaceChars will delete
- */
- public static String translate(String str, String searchChars, String replaceChars) {
- if (StringUtils.isEmpty(str)) {
- return str;
- }
- StringBuffer buffer = new StringBuffer(str.length());
- char[] chrs = str.toCharArray();
- char[] withChrs = replaceChars.toCharArray();
- int sz = chrs.length;
- int withMax = replaceChars.length() - 1;
- for(int i=0; i<sz; i++) {
- int idx = searchChars.indexOf(chrs[i]);
- if(idx != -1) {
- if(idx > withMax) {
- idx = withMax;
- }
- buffer.append(withChrs[idx]);
- } else {
- buffer.append(chrs[i]);
- }
- }
- return buffer.toString();
- }
-
}
diff --git a/src/java/org/apache/commons/lang2/StringUtils.java b/src/java/org/apache/commons/lang2/StringUtils.java
index c0ff003..b6584d0 100644
--- a/src/java/org/apache/commons/lang2/StringUtils.java
+++ b/src/java/org/apache/commons/lang2/StringUtils.java
@@ -88,7 +88,7 @@
*
* <p>A side effect of the <code>null</code> handling is that a
* <code>NullPointerException</code> should be considered a bug in
- * <code>StringUtils</code> (except for deprecated methods).</p>
+ * <code>StringUtils</code>.</p>
*
* <p>Methods in this class give sample code to explain their operation.
* The symbol <code>*</code> is used to indicate any input including <code>null</code>.</p>
@@ -256,29 +256,6 @@
/**
* <p>Removes control characters (char <= 32) from both
* ends of this String, handling <code>null</code> by returning
- * an empty String ("").</p>
- *
- * <pre>
- * StringUtils.clean(null) = ""
- * StringUtils.clean("") = ""
- * StringUtils.clean("abc") = "abc"
- * StringUtils.clean(" abc ") = "abc"
- * StringUtils.clean(" ") = ""
- * </pre>
- *
- * @see java.lang.String#trim()
- * @param str the String to clean, may be null
- * @return the trimmed text, never <code>null</code>
- * @deprecated Use the clearer named {@link #trimToEmpty(String)}.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String clean(String str) {
- return str == null ? EMPTY : str.trim();
- }
-
- /**
- * <p>Removes control characters (char <= 32) from both
- * ends of this String, handling <code>null</code> by returning
* <code>null</code>.</p>
*
* <p>The String is trimmed using {@link String#trim()}.
@@ -1950,62 +1927,6 @@
// Nested extraction
//-----------------------------------------------------------------------
- /**
- * <p>Gets the String that is nested in between two instances of the
- * same String.</p>
- *
- * <p>A <code>null</code> input String returns <code>null</code>.
- * A <code>null</code> tag returns <code>null</code>.</p>
- *
- * <pre>
- * StringUtils.getNestedString(null, *) = null
- * StringUtils.getNestedString("", "") = ""
- * StringUtils.getNestedString("", "tag") = null
- * StringUtils.getNestedString("tagabctag", null) = null
- * StringUtils.getNestedString("tagabctag", "") = ""
- * StringUtils.getNestedString("tagabctag", "tag") = "abc"
- * </pre>
- *
- * @param str the String containing nested-string, may be null
- * @param tag the String before and after nested-string, may be null
- * @return the nested String, <code>null</code> if no match
- * @deprecated Use the better named {@link #substringBetween(String, String)}.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String getNestedString(String str, String tag) {
- return substringBetween(str, tag, tag);
- }
-
- /**
- * <p>Gets the String that is nested in between two Strings.
- * Only the first match is returned.</p>
- *
- * <p>A <code>null</code> input String returns <code>null</code>.
- * A <code>null</code> open/close returns <code>null</code> (no match).
- * An empty ("") open/close returns an empty string.</p>
- *
- * <pre>
- * StringUtils.getNestedString(null, *, *) = null
- * StringUtils.getNestedString("", "", "") = ""
- * StringUtils.getNestedString("", "", "tag") = null
- * StringUtils.getNestedString("", "tag", "tag") = null
- * StringUtils.getNestedString("yabcz", null, null) = null
- * StringUtils.getNestedString("yabcz", "", "") = ""
- * StringUtils.getNestedString("yabcz", "y", "z") = "abc"
- * StringUtils.getNestedString("yabczyabcz", "y", "z") = "abc"
- * </pre>
- *
- * @param str the String containing nested-string, may be null
- * @param open the String before nested-string, may be null
- * @param close the String after nested-string, may be null
- * @return the nested String, <code>null</code> if no match
- * @deprecated Use the better named {@link #substringBetween(String, String, String)}.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String getNestedString(String str, String open, String close) {
- return substringBetween(str, open, close);
- }
-
// Splitting
//-----------------------------------------------------------------------
/**
@@ -2533,28 +2454,6 @@
// Joining
//-----------------------------------------------------------------------
/**
- * <p>Concatenates elements of an array into a single String.
- * Null objects or empty strings within the array are represented by
- * empty strings.</p>
- *
- * <pre>
- * StringUtils.concatenate(null) = null
- * StringUtils.concatenate([]) = ""
- * StringUtils.concatenate([null]) = ""
- * StringUtils.concatenate(["a", "b", "c"]) = "abc"
- * StringUtils.concatenate([null, "", "a"]) = "a"
- * </pre>
- *
- * @param array the array of values to concatenate, may be null
- * @return the concatenated String, <code>null</code> if null array input
- * @deprecated Use the better named {@link #join(Object[])} instead.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String concatenate(Object[] array) {
- return join(array, null);
- }
-
- /**
* <p>Joins the elements of the provided array into a single String
* containing the provided list of elements.</p>
*
@@ -2881,39 +2780,6 @@
// Delete
//-----------------------------------------------------------------------
/**
- * <p>Deletes all 'space' characters from a String as defined by
- * {@link Character#isSpace(char)}.</p>
- *
- * <p>This is the only StringUtils method that uses the
- * <code>isSpace</code> definition. You are advised to use
- * {@link #deleteWhitespace(String)} instead as whitespace is much
- * better localized.</p>
- *
- * <pre>
- * StringUtils.deleteSpaces(null) = null
- * StringUtils.deleteSpaces("") = ""
- * StringUtils.deleteSpaces("abc") = "abc"
- * StringUtils.deleteSpaces(" \t abc \n ") = "abc"
- * StringUtils.deleteSpaces("ab c") = "abc"
- * StringUtils.deleteSpaces("a\nb\tc ") = "abc"
- * </pre>
- *
- * <p>Spaces are defined as <code>{' ', '\t', '\r', '\n', '\b'}</code>
- * in line with the deprecated <code>isSpace</code> method.</p>
- *
- * @param str the String to delete spaces from, may be null
- * @return the String without 'spaces', <code>null</code> if null String input
- * @deprecated Use the better localized {@link #deleteWhitespace(String)}.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String deleteSpaces(String str) {
- if (str == null) {
- return null;
- }
- return CharSetUtils.delete(str, " \t\r\n\b");
- }
-
- /**
* <p>Deletes all whitespaces from a String as defined by
* {@link Character#isWhitespace(char)}.</p>
*
@@ -3288,39 +3154,6 @@
/**
* <p>Overlays part of a String with another String.</p>
*
- * <pre>
- * StringUtils.overlayString(null, *, *, *) = NullPointerException
- * StringUtils.overlayString(*, null, *, *) = NullPointerException
- * StringUtils.overlayString("", "abc", 0, 0) = "abc"
- * StringUtils.overlayString("abcdef", null, 2, 4) = "abef"
- * StringUtils.overlayString("abcdef", "", 2, 4) = "abef"
- * StringUtils.overlayString("abcdef", "zzzz", 2, 4) = "abzzzzef"
- * StringUtils.overlayString("abcdef", "zzzz", 4, 2) = "abcdzzzzcdef"
- * StringUtils.overlayString("abcdef", "zzzz", -1, 4) = IndexOutOfBoundsException
- * StringUtils.overlayString("abcdef", "zzzz", 2, 8) = IndexOutOfBoundsException
- * </pre>
- *
- * @param text the String to do overlaying in, may be null
- * @param overlay the String to overlay, may be null
- * @param start the position to start overlaying at, must be valid
- * @param end the position to stop overlaying before, must be valid
- * @return overlayed String, <code>null</code> if null String input
- * @throws NullPointerException if text or overlay is null
- * @throws IndexOutOfBoundsException if either position is invalid
- * @deprecated Use better named {@link #overlay(String, String, int, int)} instead.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String overlayString(String text, String overlay, int start, int end) {
- return new StringBuffer(start + overlay.length() + text.length() - end + 1)
- .append(text.substring(0, start))
- .append(overlay)
- .append(text.substring(end))
- .toString();
- }
-
- /**
- * <p>Overlays part of a String with another String.</p>
- *
* <p>A <code>null</code> string input returns <code>null</code>.
* A negative index is treated as zero.
* An index greater than the string length is treated as the string length.
@@ -3469,106 +3302,6 @@
return str;
}
- /**
- * <p>Remove any "\n" if and only if it is at the end
- * of the supplied String.</p>
- *
- * @param str the String to chomp from, must not be null
- * @return String without chomped ending
- * @throws NullPointerException if str is <code>null</code>
- * @deprecated Use {@link #chomp(String)} instead.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String chompLast(String str) {
- return chompLast(str, "\n");
- }
-
- /**
- * <p>Remove a value if and only if the String ends with that value.</p>
- *
- * @param str the String to chomp from, must not be null
- * @param sep the String to chomp, must not be null
- * @return String without chomped ending
- * @throws NullPointerException if str or sep is <code>null</code>
- * @deprecated Use {@link #chomp(String,String)} instead.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String chompLast(String str, String sep) {
- if (str.length() == 0) {
- return str;
- }
- String sub = str.substring(str.length() - sep.length());
- if (sep.equals(sub)) {
- return str.substring(0, str.length() - sep.length());
- } else {
- return str;
- }
- }
-
- /**
- * <p>Remove everything and return the last value of a supplied String, and
- * everything after it from a String.</p>
- *
- * @param str the String to chomp from, must not be null
- * @param sep the String to chomp, must not be null
- * @return String chomped
- * @throws NullPointerException if str or sep is <code>null</code>
- * @deprecated Use {@link #substringAfterLast(String, String)} instead
- * (although this doesn't include the separator)
- * Method will be removed in Commons Lang 3.0.
- */
- public static String getChomp(String str, String sep) {
- int idx = str.lastIndexOf(sep);
- if (idx == str.length() - sep.length()) {
- return sep;
- } else if (idx != -1) {
- return str.substring(idx);
- } else {
- return EMPTY;
- }
- }
-
- /**
- * <p>Remove the first value of a supplied String, and everything before it
- * from a String.</p>
- *
- * @param str the String to chomp from, must not be null
- * @param sep the String to chomp, must not be null
- * @return String without chomped beginning
- * @throws NullPointerException if str or sep is <code>null</code>
- * @deprecated Use {@link #substringAfter(String,String)} instead.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String prechomp(String str, String sep) {
- int idx = str.indexOf(sep);
- if (idx != -1) {
- return str.substring(idx + sep.length());
- } else {
- return str;
- }
- }
-
- /**
- * <p>Remove and return everything before the first value of a
- * supplied String from another String.</p>
- *
- * @param str the String to chomp from, must not be null
- * @param sep the String to chomp, must not be null
- * @return String prechomped
- * @throws NullPointerException if str or sep is <code>null</code>
- * @deprecated Use {@link #substringBefore(String,String)} instead
- * (although this doesn't include the separator).
- * Method will be removed in Commons Lang 3.0.
- */
- public static String getPrechomp(String str, String sep) {
- int idx = str.indexOf(sep);
- if (idx != -1) {
- return str.substring(0, idx + sep.length());
- } else {
- return EMPTY;
- }
- }
-
// Chopping
//-----------------------------------------------------------------------
/**
@@ -3613,53 +3346,8 @@
return ret;
}
- /**
- * <p>Removes <code>\n</code> from end of a String if it's there.
- * If a <code>\r</code> precedes it, then remove that too.</p>
- *
- * @param str the String to chop a newline from, must not be null
- * @return String without newline
- * @throws NullPointerException if str is <code>null</code>
- * @deprecated Use {@link #chomp(String)} instead.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String chopNewline(String str) {
- int lastIdx = str.length() - 1;
- if (lastIdx <= 0) {
- return EMPTY;
- }
- char last = str.charAt(lastIdx);
- if (last == CharUtils.LF) {
- if (str.charAt(lastIdx - 1) == CharUtils.CR) {
- lastIdx--;
- }
- } else {
- lastIdx++;
- }
- return str.substring(0, lastIdx);
- }
-
// Conversion
//-----------------------------------------------------------------------
- /**
- * <p>Escapes any values it finds into their String form.</p>
- *
- * <p>So a tab becomes the characters <code>'\\'</code> and
- * <code>'t'</code>.</p>
- *
- * <p>As of Lang 2.0, this calls {@link StringEscapeUtils#escapeJava(String)}
- * behind the scenes.
- * </p>
- * @see StringEscapeUtils#escapeJava(java.lang.String)
- * @param str String to escape values in
- * @return String with escaped values
- * @throws NullPointerException if str is <code>null</code>
- * @deprecated Use {@link StringEscapeUtils#escapeJava(String)}
- * This method will be removed in Commons Lang 3.0
- */
- public static String escape(String str) {
- return StringEscapeUtils.escapeJava(str);
- }
// Padding
//-----------------------------------------------------------------------
@@ -4169,19 +3857,6 @@
}
/**
- * <p>Capitalizes a String changing the first letter to title case as
- * per {@link Character#toTitleCase(char)}. No other letters are changed.</p>
- *
- * @param str the String to capitalize, may be null
- * @return the capitalized String, <code>null</code> if null String input
- * @deprecated Use the standardly named {@link #capitalize(String)}.
- * Method will be removed in Commons Lang 3.0.
- */
- 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>
*
@@ -4213,19 +3888,6 @@
}
/**
- * <p>Uncapitalizes a String changing the first letter to title case as
- * per {@link Character#toLowerCase(char)}. No other letters are changed.</p>
- *
- * @param str the String to uncapitalize, may be null
- * @return the uncapitalized String, <code>null</code> if null String input
- * @deprecated Use the standardly named {@link #uncapitalize(String)}.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String uncapitalise(String str) {
- return uncapitalize(str);
- }
-
- /**
* <p>Swaps the case of a String changing upper and title case to
* lower case, and lower case to upper case.</p>
*
@@ -4274,22 +3936,6 @@
return buffer.toString();
}
- /**
- * <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>
- *
- * @param str the String to capitalize, may be null
- * @return capitalized String, <code>null</code> if null String input
- * @deprecated Use the relocated {@link WordUtils#capitalize(String)}.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String capitaliseAllWords(String str) {
- return WordUtils.capitalize(str);
- }
-
// Count matches
//-----------------------------------------------------------------------
/**
@@ -4714,42 +4360,6 @@
return join(strs, separatorChar);
}
- /**
- * <p>Reverses a String that is delimited by a specific character.</p>
- *
- * <p>The Strings between the delimiters are not reversed.
- * Thus java.lang.String becomes String.lang.java (if the delimiter
- * is <code>"."</code>).</p>
- *
- * <pre>
- * StringUtils.reverseDelimitedString(null, *) = null
- * StringUtils.reverseDelimitedString("",*) = ""
- * StringUtils.reverseDelimitedString("a.b.c", null) = "a.b.c"
- * StringUtils.reverseDelimitedString("a.b.c", ".") = "c.b.a"
- * </pre>
- *
- * @param str the String to reverse, may be null
- * @param separatorChars the separator characters to use, null treated as whitespace
- * @return the reversed String, <code>null</code> if null String input
- * @deprecated Use {@link #reverseDelimited(String, char)} instead.
- * This method is broken as the join doesn't know which char to use.
- * Method will be removed in Commons Lang 3.0.
- *
- */
- public static String reverseDelimitedString(String str, String separatorChars) {
- if (str == null) {
- return null;
- }
- // could implement manually, but simple way is to reuse other,
- // probably slower, methods.
- String[] strs = split(str, separatorChars);
- ArrayUtils.reverse(strs);
- if (separatorChars == null) {
- return join(strs, ' ');
- }
- return join(strs, separatorChars);
- }
-
// Abbreviating
//-----------------------------------------------------------------------
/**
diff --git a/src/java/org/apache/commons/lang2/SystemUtils.java b/src/java/org/apache/commons/lang2/SystemUtils.java
index 582d9f0..000ae48 100644
--- a/src/java/org/apache/commons/lang2/SystemUtils.java
+++ b/src/java/org/apache/commons/lang2/SystemUtils.java
@@ -1093,23 +1093,6 @@
* <li><code>1.31f</code> for JDK 1.3.1
* </ul>
*
- * @return the version, for example 1.31f for JDK 1.3.1
- * @deprecated Use {@link #JAVA_VERSION_FLOAT} instead.
- * Method will be removed in Commons Lang 3.0.
- */
- public static float getJavaVersion() {
- return JAVA_VERSION_FLOAT;
- }
-
- /**
- * <p>Gets the Java version number as a <code>float</code>.</p>
- *
- * <p>Example return values:</p>
- * <ul>
- * <li><code>1.2f</code> for JDK 1.2
- * <li><code>1.31f</code> for JDK 1.3.1
- * </ul>
- *
* <p>Patch releases are not reported.
* Zero is returned if {@link #JAVA_VERSION_TRIMMED} is <code>null</code>.</p>
*
diff --git a/src/java/org/apache/commons/lang2/builder/ReflectionToStringBuilder.java b/src/java/org/apache/commons/lang2/builder/ReflectionToStringBuilder.java
index c616462..37b0acd 100644
--- a/src/java/org/apache/commons/lang2/builder/ReflectionToStringBuilder.java
+++ b/src/java/org/apache/commons/lang2/builder/ReflectionToStringBuilder.java
@@ -288,52 +288,6 @@
}
/**
- * <p>
- * Builds a <code>toString</code> value through reflection.
- * </p>
- *
- * <p>
- * It uses <code>AccessibleObject.setAccessible</code> to gain access to private fields. This means that it will
- * throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
- * also not as efficient as testing explicitly.
- * </p>
- *
- * <p>
- * If the <code>outputTransients</code> is <code>true</code>, transient members will be output, otherwise they
- * are ignored, as they are likely derived fields, and not part of the value of the Object.
- * </p>
- *
- * <p>
- * Static fields will not be included. Superclass fields will be appended up to and including the specified
- * superclass. A null superclass is treated as <code>java.lang.Object</code>.
- * </p>
- *
- * <p>
- * If the style is <code>null</code>, the default <code>ToStringStyle</code> is used.
- * </p>
- *
- * @deprecated Use {@link #toString(Object,ToStringStyle,boolean,boolean,Class)}
- *
- * @param object
- * the Object to be output
- * @param style
- * the style of the <code>toString</code> to create, may be <code>null</code>
- * @param outputTransients
- * whether to include transient fields
- * @param reflectUpToClass
- * the superclass to reflect up to (inclusive), may be <code>null</code>
- * @return the String result
- * @throws IllegalArgumentException
- * if the Object is <code>null</code>
- * @since 2.0
- */
- public static String toString(Object object, ToStringStyle style,
- boolean outputTransients, Class reflectUpToClass)
- {
- return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients).toString();
- }
-
- /**
* Builds a String for a toString method excluding the given field name.
*
* @param object
@@ -496,29 +450,6 @@
/**
* Constructor.
*
- * @deprecated Use {@link #ReflectionToStringBuilder(Object,ToStringStyle,StringBuffer,Class,boolean,boolean)}.
- *
- * @param object
- * the Object to build a <code>toString</code> for
- * @param style
- * the style of the <code>toString</code> to create, may be <code>null</code>
- * @param buffer
- * the <code>StringBuffer</code> to populate, may be <code>null</code>
- * @param reflectUpToClass
- * the superclass to reflect up to (inclusive), may be <code>null</code>
- * @param outputTransients
- * whether to include transient fields
- */
- public ReflectionToStringBuilder(Object object, ToStringStyle style, StringBuffer buffer, Class reflectUpToClass,
- boolean outputTransients) {
- super(object, style, buffer);
- this.setUpToClass(reflectUpToClass);
- this.setAppendTransients(outputTransients);
- }
-
- /**
- * Constructor.
- *
* @param object
* the Object to build a <code>toString</code> for
* @param style
diff --git a/src/java/org/apache/commons/lang2/builder/StandardToStringStyle.java b/src/java/org/apache/commons/lang2/builder/StandardToStringStyle.java
index 526b601..334b555 100644
--- a/src/java/org/apache/commons/lang2/builder/StandardToStringStyle.java
+++ b/src/java/org/apache/commons/lang2/builder/StandardToStringStyle.java
@@ -80,17 +80,6 @@
}
/**
- * <p>Gets whether to output short or long class names.</p>
- *
- * @return the current shortClassName flag
- * @deprecated Use {@link #isUseShortClassName()}
- * Method will be removed in Commons Lang 3.0.
- */
- public boolean isShortClassName() {
- return super.isUseShortClassName();
- }
-
- /**
* <p>Sets whether to output short or long class names.</p>
*
* @param useShortClassName the new useShortClassName flag
@@ -100,17 +89,6 @@
super.setUseShortClassName(useShortClassName);
}
- /**
- * <p>Sets whether to output short or long class names.</p>
- *
- * @param shortClassName the new shortClassName flag
- * @deprecated Use {@link #setUseShortClassName(boolean)}
- * Method will be removed in Commons Lang 3.0.
- */
- public void setShortClassName(boolean shortClassName) {
- super.setUseShortClassName(shortClassName);
- }
-
//---------------------------------------------------------------------
/**
diff --git a/src/java/org/apache/commons/lang2/builder/ToStringStyle.java b/src/java/org/apache/commons/lang2/builder/ToStringStyle.java
index 18c4da8..5bda59f 100644
--- a/src/java/org/apache/commons/lang2/builder/ToStringStyle.java
+++ b/src/java/org/apache/commons/lang2/builder/ToStringStyle.java
@@ -1576,17 +1576,6 @@
}
/**
- * <p>Gets whether to output short or long class names.</p>
- *
- * @return the current shortClassName flag
- * @deprecated Use {@link #isUseShortClassName()}
- * Method will be removed in Commons Lang 3.0.
- */
- protected boolean isShortClassName() {
- return useShortClassName;
- }
-
- /**
* <p>Sets whether to output short or long class names.</p>
*
* @param useShortClassName the new useShortClassName flag
@@ -1596,17 +1585,6 @@
this.useShortClassName = useShortClassName;
}
- /**
- * <p>Sets whether to output short or long class names.</p>
- *
- * @param shortClassName the new shortClassName flag
- * @deprecated Use {@link #setUseShortClassName(boolean)}
- * Method will be removed in Commons Lang 3.0.
- */
- protected void setShortClassName(boolean shortClassName) {
- this.useShortClassName = shortClassName;
- }
-
//---------------------------------------------------------------------
/**
diff --git a/src/java/org/apache/commons/lang2/math/NumberUtils.java b/src/java/org/apache/commons/lang2/math/NumberUtils.java
index 20796ee..92a1d4b 100644
--- a/src/java/org/apache/commons/lang2/math/NumberUtils.java
+++ b/src/java/org/apache/commons/lang2/math/NumberUtils.java
@@ -91,28 +91,6 @@
* <code>zero</code> if the conversion fails.</p>
*
* <p>If the string is <code>null</code>, <code>zero</code> is returned.</p>
- *
- * <pre>
- * NumberUtils.stringToInt(null) = 0
- * NumberUtils.stringToInt("") = 0
- * NumberUtils.stringToInt("1") = 1
- * </pre>
- *
- * @param str the string to convert, may be null
- * @return the int represented by the string, or <code>zero</code> if
- * conversion fails
- * @deprecated Use {@link #toInt(String)}
- * This method will be removed in Commons Lang 3.0
- */
- public static int stringToInt(String str) {
- return toInt(str);
- }
-
- /**
- * <p>Convert a <code>String</code> to an <code>int</code>, returning
- * <code>zero</code> if the conversion fails.</p>
- *
- * <p>If the string is <code>null</code>, <code>zero</code> is returned.</p>
*
* <pre>
* NumberUtils.toInt(null) = 0
@@ -134,28 +112,6 @@
* default value if the conversion fails.</p>
*
* <p>If the string is <code>null</code>, the default value is returned.</p>
- *
- * <pre>
- * NumberUtils.stringToInt(null, 1) = 1
- * NumberUtils.stringToInt("", 1) = 1
- * NumberUtils.stringToInt("1", 0) = 1
- * </pre>
- *
- * @param str the string to convert, may be null
- * @param defaultValue the default value
- * @return the int represented by the string, or the default if conversion fails
- * @deprecated Use {@link #toInt(String, int)}
- * This method will be removed in Commons Lang 3.0
- */
- public static int stringToInt(String str, int defaultValue) {
- return toInt(str, defaultValue);
- }
-
- /**
- * <p>Convert a <code>String</code> to an <code>int</code>, returning a
- * default value if the conversion fails.</p>
- *
- * <p>If the string is <code>null</code>, the default value is returned.</p>
*
* <pre>
* NumberUtils.toInt(null, 1) = 1
diff --git a/src/java/org/apache/commons/lang2/time/DateUtils.java b/src/java/org/apache/commons/lang2/time/DateUtils.java
index 6b2d9fb..3a153af 100644
--- a/src/java/org/apache/commons/lang2/time/DateUtils.java
+++ b/src/java/org/apache/commons/lang2/time/DateUtils.java
@@ -958,33 +958,4 @@
}
}
- //-------------------------------------------------------------------------
- // Deprecated int constants
- // TODO: Remove in 3.0
-
- /**
- * Number of milliseconds in a standard second.
- *
- * @deprecated Use MILLIS_PER_SECOND. This will be removed in Commons Lang 3.0.
- */
- public static final int MILLIS_IN_SECOND = 1000;
- /**
- * Number of milliseconds in a standard minute.
- *
- * @deprecated Use MILLIS_PER_MINUTE. This will be removed in Commons Lang 3.0.
- */
- public static final int MILLIS_IN_MINUTE = 60 * 1000;
- /**
- * Number of milliseconds in a standard hour.
- *
- * @deprecated Use MILLIS_PER_HOUR. This will be removed in Commons Lang 3.0.
- */
- public static final int MILLIS_IN_HOUR = 60 * 60 * 1000;
- /**
- * Number of milliseconds in a standard day.
- *
- * @deprecated Use MILLIS_PER_DAY. This will be removed in Commons Lang 3.0.
- */
- public static final int MILLIS_IN_DAY = 24 * 60 * 60 * 1000;
-
}
diff --git a/src/test/org/apache/commons/lang2/CharSetTest.java b/src/test/org/apache/commons/lang2/CharSetTest.java
index 34aa864..04bb030 100644
--- a/src/test/org/apache/commons/lang2/CharSetTest.java
+++ b/src/test/org/apache/commons/lang2/CharSetTest.java
@@ -64,7 +64,7 @@
//-----------------------------------------------------------------------
public void testGetInstance() {
- assertSame(CharSet.EMPTY, CharSet.getInstance(null));
+ assertSame(CharSet.EMPTY, CharSet.getInstance( (String) null));
assertSame(CharSet.EMPTY, CharSet.getInstance(""));
assertSame(CharSet.ASCII_ALPHA, CharSet.getInstance("a-zA-Z"));
assertSame(CharSet.ASCII_ALPHA, CharSet.getInstance("A-Za-z"));
@@ -72,6 +72,14 @@
assertSame(CharSet.ASCII_ALPHA_UPPER, CharSet.getInstance("A-Z"));
assertSame(CharSet.ASCII_NUMERIC, CharSet.getInstance("0-9"));
}
+
+ //-----------------------------------------------------------------------
+ public void testGetInstance_Stringarray() {
+ assertEquals(null, CharSet.getInstance((String[]) null));
+ assertEquals("[]", CharSet.getInstance(new String[0]).toString());
+ assertEquals("[]", CharSet.getInstance(new String[] {null}).toString());
+ assertEquals("[a-e]", CharSet.getInstance(new String[] {"a-e"}).toString());
+ }
//-----------------------------------------------------------------------
public void testConstructor_String_simple() {
diff --git a/src/test/org/apache/commons/lang2/CharSetUtilsTest.java b/src/test/org/apache/commons/lang2/CharSetUtilsTest.java
index 223922b..4837a16 100644
--- a/src/test/org/apache/commons/lang2/CharSetUtilsTest.java
+++ b/src/test/org/apache/commons/lang2/CharSetUtilsTest.java
@@ -67,14 +67,6 @@
}
//-----------------------------------------------------------------------
- public void testEvaluateSet_Stringarray() {
- assertEquals(null, CharSetUtils.evaluateSet((String[]) null));
- assertEquals("[]", CharSetUtils.evaluateSet(new String[0]).toString());
- assertEquals("[]", CharSetUtils.evaluateSet(new String[] {null}).toString());
- assertEquals("[a-e]", CharSetUtils.evaluateSet(new String[] {"a-e"}).toString());
- }
-
- //-----------------------------------------------------------------------
public void testSqueeze_StringString() {
assertEquals(null, CharSetUtils.squeeze(null, (String) null));
assertEquals(null, CharSetUtils.squeeze(null, ""));
@@ -233,44 +225,4 @@
assertEquals("heo", CharSetUtils.delete("hello", new String[] { "l" }));
}
-
- public void testTranslate() {
- assertEquals(null, CharSetUtils.translate(null, null, null));
- assertEquals("", CharSetUtils.translate("", "a", "b"));
- assertEquals("jelly", CharSetUtils.translate("hello", "ho", "jy"));
- assertEquals("jellj", CharSetUtils.translate("hello", "ho", "j"));
- assertEquals("jelly", CharSetUtils.translate("hello", "ho", "jyx"));
- assertEquals("\rhello\r", CharSetUtils.translate("\nhello\n", "\n", "\r"));
- assertEquals("hello", CharSetUtils.translate("hello", "", "x"));
- assertEquals("hello", CharSetUtils.translate("hello", "", ""));
- assertEquals("hello", CharSetUtils.translate("hello", "", ""));
- // From http://issues.apache.org/bugzilla/show_bug.cgi?id=25454
- assertEquals("q651.506bera", CharSetUtils.translate("d216.102oren", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789",
- "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM567891234"));
- }
-
- public void testTranslateNullPointerException() {
- try {
- CharSetUtils.translate("hello", null, null);
- fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
- }
- try {
- CharSetUtils.translate("hello", "h", null);
- fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
- }
- try {
- CharSetUtils.translate("hello", null, "a");
- fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
- }
- try {
- CharSetUtils.translate("hello", "h", "");
- fail("Expecting ArrayIndexOutOfBoundsException");
- } catch (ArrayIndexOutOfBoundsException ex) {
- }
- }
-
-
}
diff --git a/src/test/org/apache/commons/lang2/StringUtilsSubstringTest.java b/src/test/org/apache/commons/lang2/StringUtilsSubstringTest.java
index 0d4dc0a..e5159fb 100644
--- a/src/test/org/apache/commons/lang2/StringUtilsSubstringTest.java
+++ b/src/test/org/apache/commons/lang2/StringUtilsSubstringTest.java
@@ -332,24 +332,4 @@
StringUtils.countMatches("oooooooooooo", "ooo"));
}
- public void testGetNestedString_StringString() {
- assertEquals(null, StringUtils.getNestedString(null, "tag"));
- assertEquals("", StringUtils.getNestedString("", ""));
- assertEquals(null, StringUtils.getNestedString("", "abc"));
- assertEquals("", StringUtils.getNestedString(" ", " "));
- assertEquals(null, StringUtils.getNestedString("abc", null));
- assertEquals("", StringUtils.getNestedString("abc", ""));
- assertEquals(null, StringUtils.getNestedString("abc", "a"));
- assertEquals("bc", StringUtils.getNestedString("abca", "a"));
- assertEquals("bc", StringUtils.getNestedString("abcabca", "a"));
- assertEquals("bar", StringUtils.getNestedString("\nbar\n", "\n"));
- }
-
- public void testGetNestedString_StringStringString() {
- assertEquals(null, StringUtils.getNestedString(null, "", ""));
- assertEquals("", StringUtils.getNestedString("", "", ""));
- assertEquals("", StringUtils.getNestedString(" ", " ", " "));
- assertEquals("bar", StringUtils.getNestedString("<foo>bar</foo>", "<foo>", "</foo>") );
- }
-
}
diff --git a/src/test/org/apache/commons/lang2/StringUtilsTest.java b/src/test/org/apache/commons/lang2/StringUtilsTest.java
index c826282..96b0f7e 100644
--- a/src/test/org/apache/commons/lang2/StringUtilsTest.java
+++ b/src/test/org/apache/commons/lang2/StringUtilsTest.java
@@ -128,27 +128,14 @@
assertEquals(null, StringUtils.upperCase(null));
assertEquals(null, StringUtils.lowerCase(null));
assertEquals(null, StringUtils.capitalize(null));
- assertEquals(null, StringUtils.uncapitalise(null));
assertEquals(null, StringUtils.uncapitalize(null));
- assertEquals("capitalise(String) failed",
- FOO_CAP, StringUtils.capitalise(FOO_UNCAP) );
- assertEquals("capitalise(empty-string) failed",
- "", StringUtils.capitalise("") );
- assertEquals("capitalise(single-char-string) failed",
- "X", StringUtils.capitalise("x") );
assertEquals("capitalize(String) failed",
FOO_CAP, StringUtils.capitalize(FOO_UNCAP) );
assertEquals("capitalize(empty-string) failed",
"", StringUtils.capitalize("") );
assertEquals("capitalize(single-char-string) failed",
"X", StringUtils.capitalize("x") );
- assertEquals("uncapitalise(String) failed",
- FOO_UNCAP, StringUtils.uncapitalise(FOO_CAP) );
- assertEquals("uncapitalise(empty-string) failed",
- "", StringUtils.uncapitalise("") );
- assertEquals("uncapitalise(single-char-string) failed",
- "x", StringUtils.uncapitalise("X") );
assertEquals("uncapitalize(String) failed",
FOO_UNCAP, StringUtils.uncapitalize(FOO_CAP) );
assertEquals("uncapitalize(empty-string) failed",
@@ -157,20 +144,12 @@
"x", StringUtils.uncapitalize("X") );
// reflection type of tests: Sentences.
- assertEquals("uncapitalise(capitalise(String)) failed",
- SENTENCE_UNCAP, StringUtils.uncapitalise(StringUtils.capitalise(SENTENCE_UNCAP)) );
- assertEquals("capitalise(uncapitalise(String)) failed",
- SENTENCE_CAP, StringUtils.capitalise(StringUtils.uncapitalise(SENTENCE_CAP)) );
assertEquals("uncapitalize(capitalize(String)) failed",
SENTENCE_UNCAP, StringUtils.uncapitalize(StringUtils.capitalize(SENTENCE_UNCAP)) );
assertEquals("capitalize(uncapitalize(String)) failed",
SENTENCE_CAP, StringUtils.capitalize(StringUtils.uncapitalize(SENTENCE_CAP)) );
// reflection type of tests: One word.
- assertEquals("uncapitalise(capitalise(String)) failed",
- FOO_UNCAP, StringUtils.uncapitalise(StringUtils.capitalise(FOO_UNCAP)) );
- assertEquals("capitalise(uncapitalise(String)) failed",
- FOO_CAP, StringUtils.capitalise(StringUtils.uncapitalise(FOO_CAP)) );
assertEquals("uncapitalize(capitalize(String)) failed",
FOO_UNCAP, StringUtils.uncapitalize(StringUtils.capitalize(FOO_UNCAP)) );
assertEquals("capitalize(uncapitalize(String)) failed",
@@ -300,14 +279,6 @@
assertEquals(TEXT_LIST, StringUtils.join(Arrays.asList(ARRAY_LIST), SEPARATOR));
}
- public void testConcatenate_Objectarray() {
- assertEquals(null, StringUtils.concatenate(null));
- assertEquals("", StringUtils.concatenate(EMPTY_ARRAY_LIST));
- assertEquals("", StringUtils.concatenate(NULL_ARRAY_LIST));
- assertEquals("foo", StringUtils.concatenate(MIXED_ARRAY_LIST));
- assertEquals("foo2", StringUtils.concatenate(MIXED_TYPE_LIST));
- }
-
public void testSplit_String() {
assertEquals(null, StringUtils.split(null));
assertEquals(0, StringUtils.split("").length);
@@ -847,13 +818,6 @@
assertEquals(msg, str.substring(2), res[1]);
}
- public void testDeleteSpace_String() {
- assertEquals(null, StringUtils.deleteSpaces(null));
- assertEquals("", StringUtils.deleteSpaces(""));
- assertEquals("", StringUtils.deleteSpaces(" \t\t\n\n "));
- assertEquals("test", StringUtils.deleteSpaces("t \t\ne\rs\n\n \tt"));
- }
-
public void testDeleteWhitespace_String() {
assertEquals(null, StringUtils.deleteWhitespace(null));
assertEquals("", StringUtils.deleteWhitespace(""));
@@ -984,30 +948,6 @@
"nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM567891234"));
}
- public void testOverlayString_StringStringIntInt() {
- assertEquals("overlayString(String, String, int, int) failed",
- "foo foor baz", StringUtils.overlayString(SENTENCE_UNCAP, FOO_UNCAP, 4, 6) );
- assertEquals("abef", StringUtils.overlayString("abcdef", "", 2, 4));
- assertEquals("abzzzzef", StringUtils.overlayString("abcdef", "zzzz", 2, 4));
- assertEquals("abcdzzzzcdef", StringUtils.overlayString("abcdef", "zzzz", 4, 2));
- try {
- StringUtils.overlayString(null, "zzzz", 2, 4);
- fail();
- } catch (NullPointerException ex) {}
- try {
- StringUtils.overlayString("abcdef", null, 2, 4);
- fail();
- } catch (NullPointerException ex) {}
- try {
- StringUtils.overlayString("abcdef", "zzzz", -1, 4);
- fail();
- } catch (IndexOutOfBoundsException ex) {}
- try {
- StringUtils.overlayString("abcdef", "zzzz", 2, 8);
- fail();
- } catch (IndexOutOfBoundsException ex) {}
- }
-
public void testOverlay_StringStringIntInt() {
assertEquals(null, StringUtils.overlay(null, null, 2, 4));
assertEquals(null, StringUtils.overlay(null, null, -2, -4));
@@ -1047,36 +987,6 @@
assertEquals(true, StringUtils.containsOnly(str, new char[] {'a'}));
}
- public void testDeprecatedChompFunctions() {
- assertEquals("chompLast(String) failed",
- FOO_UNCAP, StringUtils.chompLast(FOO_UNCAP + "\n") );
-
- assertEquals("chompLast(\"\") failed",
- "", StringUtils.chompLast("") );
- assertEquals("chompLast(\"test\", \"test\") failed",
- "test", StringUtils.chompLast("test", "tst") );
-
- assertEquals("getChomp(String, String) failed",
- "\n" + FOO_UNCAP, StringUtils.getChomp(FOO_UNCAP + "\n" + FOO_UNCAP, "\n") );
- assertEquals("getChomp(String, String) failed",
- FOO_CAP, StringUtils.getChomp(FOO_CAP+FOO_CAP, FOO_CAP));
- assertEquals("getChomp(String, String) failed",
- "", StringUtils.getChomp(FOO_UNCAP, FOO_CAP));
-
- assertEquals("prechomp(String, String) failed",
- FOO_UNCAP, StringUtils.prechomp(FOO_UNCAP + "\n" + FOO_UNCAP, "\n") );
- assertEquals("prechomp(String, String) failed",
- FOO_UNCAP, StringUtils.prechomp(FOO_UNCAP, FOO_CAP));
-
- assertEquals("getPrechomp(String, String) failed",
- FOO_UNCAP + "\n", StringUtils.getPrechomp(FOO_UNCAP + "\n" + FOO_UNCAP, "\n") );
- assertEquals("getPrechomp(String, String) failed",
- "", StringUtils.getPrechomp(FOO_CAP, FOO_UNCAP));
-
- assertEquals("chopNewline(String, String) failed",
- FOO_UNCAP, StringUtils.chopNewline(FOO_UNCAP + "\r\n") );
- }
-
public void testChop() {
String[][] chopCases = {
@@ -1158,28 +1068,6 @@
"foo ", StringUtils.chomp("foo ", "foo"));
}
- public void testChopNewLine() {
-
- String[][] newLineCases = {
- { FOO_UNCAP + "\r\n", FOO_UNCAP } ,
- { FOO_UNCAP + "\n" , FOO_UNCAP } ,
- { FOO_UNCAP + "\r", FOO_UNCAP + "\r" },
- { FOO_UNCAP, FOO_UNCAP },
- { FOO_UNCAP + "\n" + FOO_UNCAP , FOO_UNCAP + "\n" + FOO_UNCAP },
- { FOO_UNCAP + "\n\n", FOO_UNCAP + "\n"},
- { "\n", "" },
- { "", "" },
- { "\r\n", "" }
- };
-
- for (int i = 0; i < newLineCases.length; i++) {
- String original = newLineCases[i][0];
- String expectedResult = newLineCases[i][1];
- assertEquals("chopNewline(String) failed",
- expectedResult, StringUtils.chopNewline(original));
- }
- }
-
//-----------------------------------------------------------------------
public void testRightPad_StringInt() {
assertEquals(null, StringUtils.rightPad(null, 5));
@@ -1310,15 +1198,6 @@
assertEquals("", StringUtils.reverseDelimited("", '.') );
}
- public void testReverseDelimitedString_StringString() {
- assertEquals(null, StringUtils.reverseDelimitedString(null, null) );
- assertEquals("", StringUtils.reverseDelimitedString("", null) );
- assertEquals("", StringUtils.reverseDelimitedString("", ".") );
- assertEquals("a.b.c", StringUtils.reverseDelimitedString("a.b.c", null) );
- assertEquals("c b a", StringUtils.reverseDelimitedString("a b c", null) );
- assertEquals("c.b.a", StringUtils.reverseDelimitedString("a.b.c", ".") );
- }
-
//-----------------------------------------------------------------------
public void testDefault_String() {
assertEquals("", StringUtils.defaultString(null));
@@ -1339,18 +1218,6 @@
}
//-----------------------------------------------------------------------
- public void testEscapeFunctions_String() {
- assertEquals("", StringUtils.escape("") );
- assertEquals("abc", StringUtils.escape("abc") );
- assertEquals("\\t", StringUtils.escape("\t") );
- assertEquals("\\\\", StringUtils.escape("\\") );
- assertEquals("\\\\\\b\\t\\r", StringUtils.escape("\\\b\t\r") );
- assertEquals("\\u1234", StringUtils.escape("\u1234") );
- assertEquals("\\u0234", StringUtils.escape("\u0234") );
- assertEquals("\\u00FD", StringUtils.escape("\u00fd") );
- }
-
- //-----------------------------------------------------------------------
public void testAbbreviate_StringInt() {
assertEquals(null, StringUtils.abbreviate(null, 10));
assertEquals("", StringUtils.abbreviate("", 10));
diff --git a/src/test/org/apache/commons/lang2/StringUtilsTrimEmptyTest.java b/src/test/org/apache/commons/lang2/StringUtilsTrimEmptyTest.java
index 592addf..c41bd43 100644
--- a/src/test/org/apache/commons/lang2/StringUtilsTrimEmptyTest.java
+++ b/src/test/org/apache/commons/lang2/StringUtilsTrimEmptyTest.java
@@ -87,16 +87,6 @@
}
//-----------------------------------------------------------------------
- public void testClean() {
- assertEquals(FOO, StringUtils.clean(FOO + " "));
- assertEquals(FOO, StringUtils.clean(" " + FOO + " "));
- assertEquals(FOO, StringUtils.clean(" " + FOO));
- assertEquals(FOO, StringUtils.clean(FOO + ""));
- assertEquals("", StringUtils.clean(" \t\r\n\b "));
- assertEquals("", StringUtils.clean(""));
- assertEquals("", StringUtils.clean(null));
- }
-
public void testTrim() {
assertEquals(FOO, StringUtils.trim(FOO + " "));
assertEquals(FOO, StringUtils.trim(" " + FOO + " "));
diff --git a/src/test/org/apache/commons/lang2/SystemUtilsTest.java b/src/test/org/apache/commons/lang2/SystemUtilsTest.java
index 2a72820..855e201 100644
--- a/src/test/org/apache/commons/lang2/SystemUtilsTest.java
+++ b/src/test/org/apache/commons/lang2/SystemUtilsTest.java
@@ -333,10 +333,6 @@
}
//-----------------------------------------------------------------------
- public void testJavaVersion() {
- assertEquals(SystemUtils.JAVA_VERSION_FLOAT, SystemUtils.getJavaVersion(), 0f);
- }
-
public void testJavaVersionAsFloat() {
JAVA_VERSION = null;
JAVA_VERSION_TRIMMED = getJavaVersionTrimmed();
diff --git a/src/test/org/apache/commons/lang2/math/NumberUtilsTest.java b/src/test/org/apache/commons/lang2/math/NumberUtilsTest.java
index e38845e..716f0e5 100644
--- a/src/test/org/apache/commons/lang2/math/NumberUtilsTest.java
+++ b/src/test/org/apache/commons/lang2/math/NumberUtilsTest.java
@@ -68,16 +68,6 @@
//---------------------------------------------------------------------
/**
- * Test for {@link NumberUtils#stringToInt(String)}.
- */
- public void testStringToIntString() {
- assertTrue("stringToInt(String) 1 failed", NumberUtils.stringToInt("12345") == 12345);
- assertTrue("stringToInt(String) 2 failed", NumberUtils.stringToInt("abc") == 0);
- assertTrue("stringToInt(empty) failed", NumberUtils.stringToInt("") == 0);
- assertTrue("stringToInt(null) failed", NumberUtils.stringToInt(null) == 0);
- }
-
- /**
* Test for {@link NumberUtils#toInt(String)}.
*/
public void testToIntString() {
@@ -88,14 +78,6 @@
}
/**
- * Test for {@link NumberUtils#stringToInt(String, int)}.
- */
- public void testStringToIntStringI() {
- assertTrue("stringToInt(String,int) 1 failed", NumberUtils.stringToInt("12345", 5) == 12345);
- assertTrue("stringToInt(String,int) 2 failed", NumberUtils.stringToInt("1234.5", 5) == 5);
- }
-
- /**
* Test for {@link NumberUtils#toInt(String, int)}.
*/
public void testToIntStringI() {