Added a deleteWhitespace method as Jakarta.Avalon has a need for this.
Should this go on StringUtils though. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@136937 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
df7a930dcf
commit
97b5ac9b4a
|
@ -63,7 +63,7 @@ import java.util.LinkedList;
|
||||||
*
|
*
|
||||||
* @author <a href="bayard@generationjava.com">Henri Yandell</a>
|
* @author <a href="bayard@generationjava.com">Henri Yandell</a>
|
||||||
* @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
|
* @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
|
||||||
* @version $Id: CharSetUtils.java,v 1.1 2002/07/19 03:35:54 bayard Exp $
|
* @version $Id: CharSetUtils.java,v 1.2 2002/07/21 20:14:14 bayard Exp $
|
||||||
*/
|
*/
|
||||||
public class CharSetUtils {
|
public class CharSetUtils {
|
||||||
|
|
||||||
|
@ -159,6 +159,15 @@ public class CharSetUtils {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes all whitespace from a String.
|
||||||
|
*
|
||||||
|
* @param str String target to delete whitespace from
|
||||||
|
*/
|
||||||
|
public static String deleteWhitespace(String str) {
|
||||||
|
return delete(str, " \t\r\n\b" );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes an argument in set-syntax, see evaluateSet,
|
* Takes an argument in set-syntax, see evaluateSet,
|
||||||
* and deletes any of characters present in the specified string.
|
* and deletes any of characters present in the specified string.
|
||||||
|
|
|
@ -65,7 +65,7 @@ import junit.textui.TestRunner;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:bayard@generationjava.com">Henri Yandell</a>
|
* @author <a href="mailto:bayard@generationjava.com">Henri Yandell</a>
|
||||||
* @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De Smet</a>
|
* @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De Smet</a>
|
||||||
* @version $Id: CharSetUtilsTest.java,v 1.1 2002/07/19 03:35:54 bayard Exp $
|
* @version $Id: CharSetUtilsTest.java,v 1.2 2002/07/21 20:14:14 bayard Exp $
|
||||||
*/
|
*/
|
||||||
public class CharSetUtilsTest extends TestCase
|
public class CharSetUtilsTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -135,6 +135,8 @@ public class CharSetUtilsTest extends TestCase
|
||||||
"", CharSetUtils.delete("hello", new String[] {"a-z"}));
|
"", CharSetUtils.delete("hello", new String[] {"a-z"}));
|
||||||
assertEquals("delete(String,String[]) failed",
|
assertEquals("delete(String,String[]) failed",
|
||||||
"heo", CharSetUtils.delete("hello", new String[] {"l"}));
|
"heo", CharSetUtils.delete("hello", new String[] {"l"}));
|
||||||
|
assertEquals("deleteWhitespace(String) failed",
|
||||||
|
"test", CharSetUtils.deleteWhitespace("t \t\ne\rs\n\n \tt"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue