org.jplate.foundation.util
Class TrimWhiteSpace

java.lang.Object
  extended by org.jplate.foundation.util.TrimWhiteSpace

public final class TrimWhiteSpace
extends java.lang.Object

This class can trim white space from an entire string. By default, white space is defined as newline, tab, carriage return and space. You may also supply user definable white space for trimming.

Consider the following examples:

Modifications:
    $Date: 2008-12-02 12:32:45 -0500 (Tue, 02 Dec 2008) $
    $Revision: 479 $
    $Author: sfloess $
    $HeadURL: https://jplate.svn.sourceforge.net/svnroot/jplate/trunk/src/dev/java/org/jplate/foundation/util/TrimWhiteSpace.java $
    


Field Summary
static java.lang.String DEFAULT_WHITE_SPACE
          This is the default white space to trim.
 
Constructor Summary
private TrimWhiteSpace()
          Default constructor not allowed.
 
Method Summary
private static java.lang.String trimActualWhiteSpace(java.lang.String str, java.lang.String whiteSpace)
          Removes the characters contained in whiteSpace from str.
static java.lang.String trimWhiteSpace(java.lang.String str)
          Removes the characters contained in DEFAULT_WHITE_SPACE from str.
static java.lang.String trimWhiteSpace(java.lang.String str, java.lang.String whiteSpace)
          Removes the characters contained in whiteSpace from str.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_WHITE_SPACE

public static final java.lang.String DEFAULT_WHITE_SPACE
This is the default white space to trim.

See Also:
Constant Field Values
Constructor Detail

TrimWhiteSpace

private TrimWhiteSpace()
Default constructor not allowed.

Throws:
java.lang.UnsupportedOperationException - if this constructor is called.
Method Detail

trimActualWhiteSpace

private static java.lang.String trimActualWhiteSpace(java.lang.String str,
                                                     java.lang.String whiteSpace)
Removes the characters contained in whiteSpace from str.

Parameters:
str - The string from which the characters contained in whiteSpace are removed.
whiteSpace - The string containing whitespace characters that should be removed from str.
Returns:
The result of removing characters contained in whiteSpace from str.

trimWhiteSpace

public static java.lang.String trimWhiteSpace(java.lang.String str,
                                              java.lang.String whiteSpace)
Removes the characters contained in whiteSpace from str. If whiteSpace is null or the empty string, DEFAULT_WHITE_SPACE will be used.

Parameters:
str - The string from which the characters contained in whiteSpace are removed.
whiteSpace - The string containing whitespace characters that should be removed from str.
Returns:
The result of removing characters contained in whiteSpace from str.
See Also:
DEFAULT_WHITE_SPACE

trimWhiteSpace

public static java.lang.String trimWhiteSpace(java.lang.String str)
Removes the characters contained in DEFAULT_WHITE_SPACE from str.

Parameters:
str - The string from which the characters contained in DEFAULT_WHITE_SPACE are removed.
Returns:
The result of removing characters contained in DEFAULT_WHITE_SPACE from str.
See Also:
DEFAULT_WHITE_SPACE