java.lang.Object
org.htmlunit.cyberneko.xerces.util.XMLChar

public final class XMLChar extends Object
This class defines the basic XML character properties. The data in this class can be used to verify that a character is a valid XML character or if the character is a space, name start, or name character.

A series of convenience methods are supplied to ease the burden of the developer. Because inlining the checks can improve per character performance, the tables of character properties are public. Using the character as an index into the CHARS array and applying the appropriate mask flag (e.g. MASK_VALID), yields the same results as calling the convenience methods. There is one exception: check the comments for the isValid method for details.

Author:
Glenn Marcy, IBM, Andy Clark, IBM, Eric Ye, IBM, Arnaud Le Hors, IBM, Michael Glavassevich, IBM, Rahul Srivastava, Sun Microsystems Inc.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Name character mask.
    static final int
    Name start character mask.
    static final int
    NCName character mask.
    static final int
    NCName start character mask.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Returns whether the given character or code point is a low surrogate.
    static boolean
    isName(int c)
    Returns whether the specified character is a valid name character as defined by production [4] in the XML 1.0 specification.
    static boolean
    isNameStart(int c)
    Returns whether the specified character is a valid name start character as defined by production [5] in the XML 1.0 specification.
    static boolean
    isNCName(int c)
    Returns whether the specified character is a valid NCName character as defined by production [5] in the Namespaces in XML recommendation.
    static boolean
    Returns whether the specified character is a valid NCName start character as defined by production [4] in the Namespaces in XML recommendation.
    static boolean
    Checks whether a string is a valid Name according to production [5] in the XML 1.0 Recommendation.
    static boolean
    Checks whether a string is a valid NCName according to production [4] from the XML Namespaces 1.0 Recommendation.
    static int
    supplemental(char h, char l)
    Returns the supplemental character corresponding to the given surrogate pair.

    Methods inherited from class java.lang.Object

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

    • MASK_NAME_START

      public static final int MASK_NAME_START
      Name start character mask.
      See Also:
    • MASK_NAME

      public static final int MASK_NAME
      Name character mask.
      See Also:
    • MASK_NCNAME_START

      public static final int MASK_NCNAME_START
      NCName start character mask.
      See Also:
    • MASK_NCNAME

      public static final int MASK_NCNAME
      NCName character mask.
      See Also:
  • Method Details

    • supplemental

      public static int supplemental(char h, char l)
      Returns the supplemental character corresponding to the given surrogate pair.
      Parameters:
      h - the high surrogate character
      l - the low surrogate character
      Returns:
      the corresponding supplemental character code point
    • isLowSurrogate

      public static boolean isLowSurrogate(int c)
      Returns whether the given character or code point is a low surrogate.
      Parameters:
      c - the character or code point to check
      Returns:
      true if the character is a low surrogate, false otherwise
    • isNameStart

      public static boolean isNameStart(int c)
      Returns whether the specified character is a valid name start character as defined by production [5] in the XML 1.0 specification.
      Parameters:
      c - the character code point to check
      Returns:
      true if the character is a valid name start character, false otherwise
    • isName

      public static boolean isName(int c)
      Returns whether the specified character is a valid name character as defined by production [4] in the XML 1.0 specification.
      Parameters:
      c - the character code point to check
      Returns:
      true if the character is a valid name character, false otherwise
    • isNCNameStart

      public static boolean isNCNameStart(int c)
      Returns whether the specified character is a valid NCName start character as defined by production [4] in the Namespaces in XML recommendation.
      Parameters:
      c - the character code point to check
      Returns:
      true if the character is a valid NCName start character, false otherwise
    • isNCName

      public static boolean isNCName(int c)
      Returns whether the specified character is a valid NCName character as defined by production [5] in the Namespaces in XML recommendation.
      Parameters:
      c - the character code point to check
      Returns:
      true if the character is a valid NCName character, false otherwise
    • isValidName

      public static boolean isValidName(String name)
      Checks whether a string is a valid Name according to production [5] in the XML 1.0 Recommendation.
      Parameters:
      name - the string to check
      Returns:
      true if the string is a valid Name, false otherwise
    • isValidNCName

      public static boolean isValidNCName(String ncName)
      Checks whether a string is a valid NCName according to production [4] from the XML Namespaces 1.0 Recommendation.
      Parameters:
      ncName - the string to check]
      Returns:
      true if the string is a valid NCName, false otherwise