Package org.exolab.adaptx.xml
Class Whitespace
java.lang.Object
org.exolab.adaptx.xml.Whitespace
A class for handling XML Whitespace
- Author:
- Keith Visco
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final char
Carriage Return character Changed to '\r' instead of ' ' to make compatible with MS J++ Mohan Embarstatic final String
Empty Stringstatic final char
Linefeed characterstatic final char
Null characterstatic final char
Single space characterstatic final char
Tab character -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
stripSpace
(char[] data, boolean stripAllLeadSpace, boolean stripAllTrailSpace) Strips whitespace from the given String.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.
-
Field Details
-
NULL
public static final char NULLNull character- See Also:
-
SPACE
public static final char SPACESingle space character- See Also:
-
TAB
public static final char TABTab character- See Also:
-
CR
public static final char CRCarriage Return character Changed to '\r' instead of ' ' to make compatible with MS J++ Mohan Embar- See Also:
-
LF
public static final char LFLinefeed character- See Also:
-
EMPTY
Empty String- See Also:
-
-
Constructor Details
-
Whitespace
public Whitespace()
-
-
Method Details
-
stripSpace
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
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 fromstripAllLeadSpace
- , a boolean indicating whether or not to strip all leading space. If true all whitespace from the start of the given String will be stripped. If false, all whitespace from the start of the given String will be converted to a single space.stripAllTrailSpace
- , a boolean indicating whether or not to strip all trailing space. If true all whitespace at the end of the given String will be stripped. If false, all whitespace at the end of the given String will be converted to a single space.
-
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 fromstripAllLeadSpace
- , a boolean indicating whether or not to strip all leading space. If true all whitespace from the start of the given String will be stripped. If false, all whitespace from the start of the given String will be converted to a single space.stripAllTrailSpace
- , a boolean indicating whether or not to strip all trailing space. If true all whitespace at the end of the given String will be stripped. If false, all whitespace at the end of the given String will be converted to a single space.- Returns:
- the new length of the array
-