net.sf.saxon.value

Class Whitespace

public class Whitespace extends Object

This class provides helper methods and constants for handling whitespace
Field Summary
static intALL
static intCOLLAPSE
static intIGNORABLE
static intNONE
The values NONE, IGNORABLE, and ALL identify which kinds of whitespace text node should be stripped when building a source tree
static intPRESERVE
The values PRESERVE, REPLACE, and COLLAPSE represent the three options for whitespace normalization.
static intREPLACE
static intUNSPECIFIED
Method Summary
static CharSequenceapplyWhitespaceNormalization(int action, CharSequence value)
Apply schema-defined whitespace normalization to a string
static booleancontainsWhitespace(CharSequence value)
Determine if a string contains any whitespace
static booleanisWhite(CharSequence content)
Determine if a string is all-whitespace
static booleanisWhitespace(int ch)
Test whether a character is whitespace
static CharSequenceremoveAllWhitespace(CharSequence value)
Remove all whitespace characters from a string
static CharSequenceremoveLeadingWhitespace(CharSequence value)
Remove leading whitespace characters from a string

Field Detail

ALL

public static final int ALL

COLLAPSE

public static final int COLLAPSE

IGNORABLE

public static final int IGNORABLE

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

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.

REPLACE

public static final int REPLACE

UNSPECIFIED

public static final int UNSPECIFIED

Method Detail

applyWhitespaceNormalization

public static CharSequence applyWhitespaceNormalization(int action, CharSequence value)
Apply schema-defined whitespace normalization to a string

Parameters: action the action to be applied: one of PRESERVE, REPLACE, or COLLAPSE value the value to be normalized

Returns: the value after normalization

containsWhitespace

public static boolean containsWhitespace(CharSequence value)
Determine if a string contains any whitespace

isWhite

public static final boolean isWhite(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

isWhitespace

public static boolean isWhitespace(int ch)
Test whether a character is whitespace

removeAllWhitespace

public static CharSequence removeAllWhitespace(CharSequence value)
Remove all whitespace characters from a string

removeLeadingWhitespace

public static CharSequence removeLeadingWhitespace(CharSequence value)
Remove leading whitespace characters from a string