Package net.sf.saxon.value
Class Whitespace
- java.lang.Object
-
- net.sf.saxon.value.Whitespace
-
public class Whitespace extends java.lang.Object
This class provides helper methods and constants for handling whitespace
-
-
Field Summary
Fields Modifier and Type Field Description static int
ALL
static int
COLLAPSE
static int
IGNORABLE
static int
NONE
The values NONE, IGNORABLE, and ALL identify which kinds of whitespace text node should be stripped when building a source treestatic int
PRESERVE
The values PRESERVE, REPLACE, and COLLAPSE represent the three options for whitespace normalization.static int
REPLACE
static int
UNSPECIFIED
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.CharSequence
applyWhitespaceNormalization(int action, java.lang.CharSequence value)
Apply schema-defined whitespace normalization to a stringstatic java.lang.CharSequence
collapseWhitespace(java.lang.CharSequence in)
Collapse whitespace as defined in XML Schemastatic boolean
containsWhitespace(java.lang.CharSequence value)
Determine if a string contains any whitespacestatic boolean
isWhite(java.lang.CharSequence content)
Determine if a string is all-whitespacestatic boolean
isWhitespace(int ch)
Test whether a character is whitespacestatic java.lang.CharSequence
normalizeWhitespace(java.lang.CharSequence in)
Normalize whitespace as defined in XML Schemastatic java.lang.CharSequence
removeAllWhitespace(java.lang.CharSequence value)
Remove all whitespace characters from a stringstatic java.lang.CharSequence
removeLeadingWhitespace(java.lang.CharSequence value)
Remove leading whitespace characters from a stringstatic java.lang.CharSequence
trimWhitespace(java.lang.CharSequence in)
Remove leading and trailing whitespace.
-
-
-
Field Detail
-
PRESERVE
public static final int PRESERVE
The values PRESERVE, REPLACE, and COLLAPSE represent the three options for whitespace normalization. They are deliberately chosen in ascending strength order; given a number of whitespace facets, only the strongest needs to be carried out.- See Also:
- Constant Field Values
-
REPLACE
public static final int REPLACE
- See Also:
- Constant Field Values
-
COLLAPSE
public static final int COLLAPSE
- See Also:
- Constant Field Values
-
NONE
public static final int NONE
The values NONE, IGNORABLE, and ALL identify which kinds of whitespace text node should be stripped when building a source tree- See Also:
- Constant Field Values
-
IGNORABLE
public static final int IGNORABLE
- See Also:
- Constant Field Values
-
ALL
public static final int ALL
- See Also:
- Constant Field Values
-
UNSPECIFIED
public static final int UNSPECIFIED
- See Also:
- Constant Field Values
-
-
Method Detail
-
isWhitespace
public static boolean isWhitespace(int ch)
Test whether a character is whitespace
-
applyWhitespaceNormalization
public static java.lang.CharSequence applyWhitespaceNormalization(int action, java.lang.CharSequence value)
Apply schema-defined whitespace normalization to a string- Parameters:
action
- the action to be applied: one of PRESERVE, REPLACE, or COLLAPSEvalue
- the value to be normalized- Returns:
- the value after normalization
-
removeAllWhitespace
public static java.lang.CharSequence removeAllWhitespace(java.lang.CharSequence value)
Remove all whitespace characters from a string
-
removeLeadingWhitespace
public static java.lang.CharSequence removeLeadingWhitespace(java.lang.CharSequence value)
Remove leading whitespace characters from a string
-
containsWhitespace
public static boolean containsWhitespace(java.lang.CharSequence value)
Determine if a string contains any whitespace
-
isWhite
public static final boolean isWhite(java.lang.CharSequence content)
Determine if a string is all-whitespace- Parameters:
content
- the string to be tested- Returns:
- true if the supplied string contains no non-whitespace characters
-
normalizeWhitespace
public static java.lang.CharSequence normalizeWhitespace(java.lang.CharSequence in)
Normalize whitespace as defined in XML Schema
-
collapseWhitespace
public static java.lang.CharSequence collapseWhitespace(java.lang.CharSequence in)
Collapse whitespace as defined in XML Schema
-
trimWhitespace
public static java.lang.CharSequence trimWhitespace(java.lang.CharSequence in)
Remove leading and trailing whitespace. This has the same effect as collapseWhitespace, but is cheaper, for use by data types that do not allow internal whitespace.- Parameters:
in
- the input string whose whitespace is to be removed- Returns:
- the result of removing excess whitespace
-
-