org.mmbase.util
Class Strip

java.lang.Object
  extended by org.mmbase.util.Strip

public class Strip
extends Object

Class to strip characters from the beginning and end of strings.

 Example1: Strip.Char("..dfld..",'.',Strip.TRAILING) yields "..dlfd."
 Example2: Strip.Chars("..dfld..",".",Strip.TRAILING) yields "..dlfd"
 Example3: Strip.Chars(". .. dfld. , .","., ",Strip.BOTH) yields "dfld"
 

Version:
$Id: Strip.java 41055 2010-02-15 23:59:16Z michiel $
Author:
Rico Jansen

Field Summary
static int BOTH
          Strip both, characters at begin and end of string are checked
static int LEADING
          Strip leading, only characters at begin of string are checked
static int NOTHING
          Strip nothing, a rather ineffecient form of a copy
static int TRAILING
          Strip trailing, only characters at end of string are checked
 
Method Summary
static String character(String str, char chr, int where)
          Strip all of the specified character from beginning, end or both.
static String chars(String str, String chars, int where)
          Strip multiple characters contained in the set given as second parameter until a non-set character.
static String doubleQuote(String str, int where)
          Strip double quotes from beginning, end or both, only once.
static void main(String[] args)
          Test the class
static String singleQuote(String str, int where)
          Strip single quotes from beginning, end or both, only once.
static String whitespace(String str, int where)
          Strip multiple whitespace characters from beginning, end or both, that means keep on stripping util a non-whitespace character is found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOTHING

public static final int NOTHING
Strip nothing, a rather ineffecient form of a copy

See Also:
Constant Field Values

LEADING

public static final int LEADING
Strip leading, only characters at begin of string are checked

See Also:
Constant Field Values

TRAILING

public static final int TRAILING
Strip trailing, only characters at end of string are checked

See Also:
Constant Field Values

BOTH

public static final int BOTH
Strip both, characters at begin and end of string are checked

See Also:
Constant Field Values
Method Detail

doubleQuote

public static String doubleQuote(String str,
                                 int where)
Strip double quotes from beginning, end or both, only once.

Parameters:
str - the string to strip
where - one of NOTHING, LEADING, TRAILING or BOTH
Returns:
the stripped String

singleQuote

public static String singleQuote(String str,
                                 int where)
Strip single quotes from beginning, end or both, only once.

Parameters:
str - the string to strip
where - one of NOTHING, LEADING, TRAILING or BOTH
Returns:
the stripped String

whitespace

public static String whitespace(String str,
                                int where)
Strip multiple whitespace characters from beginning, end or both, that means keep on stripping util a non-whitespace character is found.

Parameters:
str - the string to strip
where - one of NOTHING, LEADING, TRAILING or BOTH
Returns:
the stripped String

character

public static String character(String str,
                               char chr,
                               int where)
Strip all of the specified character from beginning, end or both.

Parameters:
str - the string to strip
chr - the character to strip from the string
where - one of NOTHING, LEADING, TRAILING or BOTH
Returns:
the stripped String

chars

public static String chars(String str,
                           String chars,
                           int where)
Strip multiple characters contained in the set given as second parameter until a non-set character.

Parameters:
str - the string to strip
chars - a string containing all characters to strip from the string
where - one of NOTHING, LEADING, TRAILING or BOTH
Returns:
the stripped String

main

public static void main(String[] args)
Test the class



MMBase 2.0-SNAPSHOT - null