org.exolab.adaptx.xml

Class Whitespace


public class Whitespace
extends java.lang.Object

A class for handling XML Whitespace

Author:
Keith Visco

Field Summary

static char
CR
Carriage Return character Changed to '\r' instead of '\u000D' to make compatible with MS J++ Mohan Embar
static String
EMPTY
Empty String
static char
LF
Linefeed character
static char
NULL
Null character
static char
SPACE
Single space character
static char
TAB
Tab character

Method Summary

static String
stripSpace(String data)
Strips whitespace from the given String.
static String
stripSpace(String data, boolean stripAllLeadSpace, boolean stripAllTrailSpace)
Strips whitespace from the given String.
static int
stripSpace(char[] data, boolean stripAllLeadSpace, boolean stripAllTrailSpace)
Strips whitespace from the given String.

Field Details

CR

public static final char CR
Carriage Return character Changed to '\r' instead of '\u000D' to make compatible with MS J++ Mohan Embar


EMPTY

public static final String EMPTY
Empty String


LF

public static final char LF
Linefeed character


NULL

public static final char NULL
Null character


SPACE

public static final char SPACE
Single space character


TAB

public static final char TAB
Tab character

Method Details

stripSpace

public static String stripSpace(String data)
Strips whitespace from the given String. Newlines (#xD), tabs (#x9), and consecutive spaces (#x20) are converted to a single space (#x20). This method is useful for processing consective Strings since any leading spaces will be converted to a single space.

Parameters:
data - the String to strip whitespace from


stripSpace

public static String stripSpace(String data,
                                boolean stripAllLeadSpace,
                                boolean stripAllTrailSpace)
Strips whitespace from the given String. Newlines (#xD), tabs (#x9), and consecutive spaces (#x20) are converted to a single space (#x20).

Parameters:
data - the String to strip whitespace from


stripSpace

public static int stripSpace(char[] data,
                             boolean stripAllLeadSpace,
                             boolean stripAllTrailSpace)
Strips whitespace from the given String. Newlines (#xD), tabs (#x9), and consecutive spaces (#x20) are converted to a single space (#x20).

Parameters:
data - the chars to strip whitespace from

Returns:
the new length of the array