Author: bayard
Date: Sat Mar 14 16:29:28 2009
New Revision: 754482
URL: http://svn.apache.org/viewvc?rev=754482&view=rev
Log:
Removing deprecated evaluateSet and translate methods [LANG-438]
Modified:
commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSetUtils.java
commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharSetUtilsTest.java
Modified:
commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSetUtils.java
URL:
http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSetUtils.java?rev=754482&r1=754481&r2=754482&view=diff
==============================================================================
---
commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSetUtils.java
(original)
+++
commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSetUtils.java
Sat Mar 14 16:29:28 2009
@@ -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
//-----------------------------------------------------------------------
/**
@@ -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();
- }
-
}
Modified:
commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharSetUtilsTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharSetUtilsTest.java?rev=754482&r1=754481&r2=754482&view=diff
==============================================================================
---
commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharSetUtilsTest.java
(original)
+++
commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharSetUtilsTest.java
Sat Mar 14 16:29:28 2009
@@ -69,14 +69,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, ""));
@@ -235,44 +227,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) {
- }
- }
-
-
}