Class Whitespace

java.lang.Object
org.exolab.adaptx.xml.Whitespace

public class Whitespace extends Object
A class for handling XML Whitespace
Author:
Keith Visco
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char
    Carriage Return character Changed to '\r' instead of ' ' to make compatible with MS J++ Mohan Embar
    static final String
    Empty String
    static final char
    Linefeed character
    static final char
    Null character
    static final char
    Single space character
    static final char
    Tab character
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

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

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Whitespace

      public Whitespace()
  • 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
      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