org.exolab.adaptx.xpath.engine

Class XMLUtils

public final class XMLUtils extends Object

A utility class for handling whitespace and namespaces. The code in this class was adapted from XSL:P.

Version: $Revision: 3731 $

Author: Keith Visco

Field Summary
static charCR
Carriage Return character
static StringEMPTY
Empty String
static charLF
Linefeed character
static charNULL
Null character
static charSPACE
Single space character
static charTAB
Tab character
Method Summary
static String[]fromQualified(String qname)
static StringstripSpace(String data)
Strips whitespace from the given String.
static StringstripSpace(String data, boolean stripAllLeadSpace, boolean stripAllTrailSpace)
Strips whitespace from the given String.
static intstripSpace(char[] data, boolean stripAllLeadSpace, boolean stripAllTrailSpace)
Strips whitespace from the given String.
static StringtoQualified(String uri, String local)

Field Detail

CR

public static final char CR
Carriage Return character

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 Detail

fromQualified

public static String[] fromQualified(String qname)

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 stripAllLeadSpace, 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 from stripAllLeadSpace, 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

toQualified

public static String toQualified(String uri, String local)