org.apache.commons.lang.CharSetUtils


This class handles null input gracefully. An exception will not be thrown for a null input. Each method documents its behavior in more detail.

Constructor Detail

 public CharSetUtils() 

CharSetUtils instances should NOT be constructed in standard programming. Instead, the class should be used as CharSetUtils.evaluateSet(null);. This constructor is public to permit tools that require a JavaBean instance to operate.

Method Detail

 public static java.lang.String squeeze(java.lang.String str, java.lang.String set) 

Squeezes any repetitions of a character that is mentioned in the supplied set.

 CharSetUtils.squeeze(null, *) = null CharSetUtils.squeeze("", *) = "" CharSetUtils.squeeze(*, null) = * CharSetUtils.squeeze(*, "") = * CharSetUtils.squeeze("hello", "k-p") = "helo" CharSetUtils.squeeze("hello", "a-e") = "hello" 

Parameters: strthe string to squeeze, may be null

setthe character set to use for manipulation, may be null

Returns: modified String, null if null string input

See Also: for set-syntax.

 public static java.lang.String squeeze(java.lang.String str, java.lang.String[] set) 

Squeezes any repetitions of a character that is mentioned in the supplied set. An example is:

 squeeze("hello", {"el"}) => "helo" 

Parameters: strthe string to squeeze, may be null

setthe character set to use for manipulation, may be null

Returns: modified String, null if null string input

See Also: for set-syntax.

 public static int count(java.lang.String str, java.lang.String set) 

Takes an argument in set-syntax, see evaluateSet, and returns the number of characters present in the specified string.

 CharSetUtils.count(null, *) = 0 CharSetUtils.count("", *) = 0 CharSetUtils.count(*, null) = 0 CharSetUtils.count(*, "") = 0 CharSetUtils.count("hello", "k-p") = 3 CharSetUtils.count("hello", "a-e") = 1 

Parameters: strString to count characters in, may be null

setString set of characters to count, may be null

Returns: character count, zero if null string input

See Also: for set-syntax.

 public static int count(java.lang.String str, java.lang.String[] set) 

Takes an argument in set-syntax, see evaluateSet, and returns the number of characters present in the specified string.

An example would be:

 count("hello", {"c-f", "o"}) returns 2. 

Parameters: strString to count characters in, may be null

setString[] set of characters to count, may be null

Returns: character count, zero if null string input

See Also: for set-syntax.

 public static java.lang.String keep(java.lang.String str, java.lang.String set) 

Takes an argument in set-syntax, see evaluateSet, and keeps any of the characters present in the specified string.

 CharSetUtils.keep(null, *) = null CharSetUtils.keep("", *) = "" CharSetUtils.keep(*, null) = "" CharSetUtils.keep(*, "") = "" CharSetUtils.keep("hello", "hl") = "hll" CharSetUtils.keep("hello", "le") = "ell" 

Parameters: strString to keep characters from, may be null

setString set of characters to keep, may be null

Returns: modified String, null if null string input

See Also: for set-syntax.

 public static java.lang.String keep(java.lang.String str, java.lang.String[] set) 

Takes an argument in set-syntax, see evaluateSet, and keeps any of the characters present in the specified string.

An example would be:

 keep("hello", {"c-f", "o"}) returns "hll" 

Parameters: strString to keep characters from, may be null

setString[] set of characters to keep, may be null

Returns: modified String, null if null string input

See Also: for set-syntax.

 public static java.lang.String delete(java.lang.String str, java.lang.String set) 

Takes an argument in set-syntax, see evaluateSet, and deletes any of the characters present in the specified string.

 CharSetUtils.delete(null, *) = null CharSetUtils.delete("", *) = "" CharSetUtils.delete(*, null) = * CharSetUtils.delete(*, "") = * CharSetUtils.delete("hello", "hl") = "hll" CharSetUtils.delete("hello", "le") = "ell" 

Parameters: strString to delete characters from, may be null

setString set of characters to delete, may be null

Returns: modified String, null if null string input

See Also: for set-syntax.

 public static java.lang.String delete(java.lang.String str, java.lang.String[] set) 

Takes an argument in set-syntax, see evaluateSet, and deletes any of the characters present in the specified string.

An example would be:

 delete("hello", {"c-f", "o"}) returns "hll" 

Parameters: strString to delete characters from, may be null

setString[] set of characters to delete, may be null

Returns: modified String, null if null string input

See Also: for set-syntax.



    Apache Jakarta Commons(c) Reusable Java Components
    Real World Web Services
    ISBN: N/A
    EAN: 2147483647
    Year: 2006
    Pages: 137
    Authors: Will Iverson

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net