Moved deleteWhitespace from CharSetUtils to StringUtils.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@136938 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
97b5ac9b4a
commit
46872f9f52
|
@ -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.2 2002/07/21 20:14:14 bayard Exp $
|
* @version $Id: CharSetUtils.java,v 1.3 2002/07/21 20:19:50 bayard Exp $
|
||||||
*/
|
*/
|
||||||
public class CharSetUtils {
|
public class CharSetUtils {
|
||||||
|
|
||||||
|
@ -159,15 +159,6 @@ 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.
|
||||||
|
|
|
@ -80,7 +80,7 @@ import java.util.Iterator;
|
||||||
* @author <a href="mailto:ed@apache.org">Ed Korthof</a>
|
* @author <a href="mailto:ed@apache.org">Ed Korthof</a>
|
||||||
* @author <a href="mailto:rand_mcneely@yahoo.com>Rand McNeely</a>
|
* @author <a href="mailto:rand_mcneely@yahoo.com>Rand McNeely</a>
|
||||||
* @author <a href="mailto:scolebourne@joda.org>Stephen Colebourne</a>
|
* @author <a href="mailto:scolebourne@joda.org>Stephen Colebourne</a>
|
||||||
* @version $Id: StringUtils.java,v 1.2 2002/07/19 04:04:45 bayard Exp $
|
* @version $Id: StringUtils.java,v 1.3 2002/07/21 20:19:50 bayard Exp $
|
||||||
*/
|
*/
|
||||||
public class StringUtils {
|
public class StringUtils {
|
||||||
|
|
||||||
|
@ -122,6 +122,15 @@ public class StringUtils {
|
||||||
return (str == null ? null : str.trim());
|
return (str == null ? null : str.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes all whitespace from a String.
|
||||||
|
*
|
||||||
|
* @param str String target to delete whitespace from
|
||||||
|
*/
|
||||||
|
public static String deleteWhitespace(String str) {
|
||||||
|
return CharSetUtils.delete(str, " \t\r\n\b" );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a String is non null and is not empty (length > 0).
|
* Checks if a String is non null and is not empty (length > 0).
|
||||||
*
|
*
|
||||||
|
|
|
@ -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.2 2002/07/21 20:14:14 bayard Exp $
|
* @version $Id: CharSetUtilsTest.java,v 1.3 2002/07/21 20:19:50 bayard Exp $
|
||||||
*/
|
*/
|
||||||
public class CharSetUtilsTest extends TestCase
|
public class CharSetUtilsTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -135,8 +135,6 @@ 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"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ import junit.textui.TestRunner;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
|
* @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</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: StringUtilsTrimEmptyTest.java,v 1.3 2002/07/19 04:05:57 bayard Exp $
|
* @version $Id: StringUtilsTrimEmptyTest.java,v 1.4 2002/07/21 20:19:50 bayard Exp $
|
||||||
*/
|
*/
|
||||||
public class StringUtilsTrimEmptyTest extends TestCase {
|
public class StringUtilsTrimEmptyTest extends TestCase {
|
||||||
private static final String FOO = "foo";
|
private static final String FOO = "foo";
|
||||||
|
@ -122,6 +122,15 @@ public class StringUtilsTrimEmptyTest extends TestCase {
|
||||||
assertEquals(true, StringUtils.isEmpty(null));
|
assertEquals(true, StringUtils.isEmpty(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDeleteWhitespace() {
|
||||||
|
assertEquals("deleteWhitespace(String) failed",
|
||||||
|
"", StringUtils.deleteWhitespace(""));
|
||||||
|
assertEquals("deleteWhitespace(String) failed",
|
||||||
|
"", StringUtils.deleteWhitespace(" \t\t\n\n "));
|
||||||
|
assertEquals("deleteWhitespace(String) failed",
|
||||||
|
"test", StringUtils.deleteWhitespace("t \t\ne\rs\n\n \tt"));
|
||||||
|
}
|
||||||
|
|
||||||
public void testStrip() {
|
public void testStrip() {
|
||||||
// it's important that foo2Space is fooLeftSpace and fooRightSpace
|
// it's important that foo2Space is fooLeftSpace and fooRightSpace
|
||||||
// merged together. So same number of spaces to left as fLS and same
|
// merged together. So same number of spaces to left as fLS and same
|
||||||
|
|
Loading…
Reference in New Issue