FileDocCategorySizeDatePackage
XMLCharacterRecognizer.javaAPI DocJava SE 5 API2831Fri Aug 26 14:56:04 BST 2005com.sun.org.apache.xml.internal.utils

XMLCharacterRecognizer

public class XMLCharacterRecognizer extends Object
Class used to verify whether the specified ch conforms to the XML 1.0 definition of whitespace.
xsl.usage
internal

Fields Summary
Constructors Summary
Methods Summary
public static booleanisWhiteSpace(char ch)
Returns whether the specified ch conforms to the XML 1.0 definition of whitespace. Refer to the definition of S for details.

param
ch Character to check as XML whitespace.
return
=true if ch is XML whitespace; otherwise =false.

    return (ch == 0x20) || (ch == 0x09) || (ch == 0xD) || (ch == 0xA);
  
public static booleanisWhiteSpace(char[] ch, int start, int length)
Tell if the string is whitespace.

param
ch Character array to check as XML whitespace.
param
start Start index of characters in the array
param
length Number of characters in the array
return
True if the characters in the array are XML whitespace; otherwise, false.


    int end = start + length;

    for (int s = start; s < end; s++)
    {
      if (!isWhiteSpace(ch[s]))
        return false;
    }

    return true;
  
public static booleanisWhiteSpace(java.lang.StringBuffer buf)
Tell if the string is whitespace.

param
buf StringBuffer to check as XML whitespace.
return
True if characters in buffer are XML whitespace, false otherwise


    int n = buf.length();

    for (int i = 0; i < n; i++)
    {
      if (!isWhiteSpace(buf.charAt(i)))
        return false;
    }

    return true;
  
public static booleanisWhiteSpace(java.lang.String s)
Tell if the string is whitespace.

param
buf StringBuffer to check as XML whitespace.
return
True if characters in buffer are XML whitespace, false otherwise


    if(null != s)
    {
      int n = s.length();
  
      for (int i = 0; i < n; i++)
      {
        if (!isWhiteSpace(s.charAt(i)))
          return false;
      }
    }

    return true;