org.apache.struts2.jasper.xmlparser

## Class XMLChar

- java.lang.Object
- - org.apache.struts2.jasper.xmlparser.XMLChar

-     public 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.

  Version:
    $Id: XMLChar.java 467222 2006-10-24 03:17:11Z markt $
  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 and Description
    --- | ---
    `static int` | `MASK_CONTENT` Content character mask.
    `static int` | `MASK_NAME` Name character mask.
    `static int` | `MASK_NAME_START` Name start character mask.
    `static int` | `MASK_NCNAME` NCName character mask.
    `static int` | `MASK_NCNAME_START` NCName start character mask.
    `static int` | `MASK_PUBID` Pubid character mask.
    `static int` | `MASK_SPACE` Space character mask.
    `static int` | `MASK_VALID` Valid character mask.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XMLChar()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static char` | `highSurrogate(int c)`
    `static boolean` | `isContent(int c)`
    `static boolean` | `isHighSurrogate(int c)`
    `static boolean` | `isInvalid(int c)`
    `static boolean` | `isLowSurrogate(int c)`
    `static boolean` | `isMarkup(int c)`
    `static boolean` | `isName(int c)`
    `static boolean` | `isNameStart(int c)`
    `static boolean` | `isNCName(int c)`
    `static boolean` | `isNCNameStart(int c)`
    `static boolean` | `isPubid(int c)`
    `static boolean` | `isSpace(int c)`
    `static boolean` | `isSupplemental(int c)`
    `static boolean` | `isValid(int c)`
    `static boolean` | `isValidIANAEncoding(String ianaEncoding)`
    `static boolean` | `isValidJavaEncoding(String javaEncoding)`
    `static boolean` | `isValidName(String name)` Check to see if a string is a valid Name according to [5] in the XML 1.0 Recommendation
    `static boolean` | `isValidNCName(String ncName)` Check to see if a string is a valid NCName according to [4] from the XML Namespaces 1.0 Recommendation
    `static boolean` | `isValidNmtoken(String nmtoken)` Check to see if a string is a valid Nmtoken according to [7] in the XML 1.0 Recommendation
    `static char` | `lowSurrogate(int c)`
    `static int` | `supplemental(char h, char l)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### MASK_VALID

          public static final int MASK_VALID

      Valid character mask.
      See Also:
        Constant Field Values

    - #### MASK_SPACE

          public static final int MASK_SPACE

      Space character mask.
      See Also:
        Constant Field Values

    - #### MASK_NAME_START

          public static final int MASK_NAME_START

      Name start character mask.
      See Also:
        Constant Field Values

    - #### MASK_NAME

          public static final int MASK_NAME

      Name character mask.
      See Also:
        Constant Field Values

    - #### MASK_PUBID

          public static final int MASK_PUBID

      Pubid character mask.
      See Also:
        Constant Field Values

    - #### MASK_CONTENT

          public static final int MASK_CONTENT

      Content character mask. Special characters are those that can be considered the start of markup, such as '<' and '&'. The various newline characters are considered special as well. All other valid XML characters can be considered content.

      This is an optimization for the inner loop of character scanning.

      See Also:
        Constant Field Values

    - #### MASK_NCNAME_START

          public static final int MASK_NCNAME_START

      NCName start character mask.
      See Also:
        Constant Field Values

    - #### MASK_NCNAME

          public static final int MASK_NCNAME

      NCName character mask.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### XMLChar

          public XMLChar()

  - ### Method Detail

    - #### isSupplemental

          public static boolean isSupplemental(int c)

      Parameters:
        `c` - The character to check.
      Returns:
        true if the specified character is a supplemental character.

    - #### supplemental

          public static int supplemental(char h,
                                         char l)

      Parameters:
        `h` - The high surrogate.
        `l` - The low surrogate.
      Returns:
        true the supplemental character corresponding to the given surrogates.

    - #### highSurrogate

          public static char highSurrogate(int c)

      Parameters:
        `c` - The supplemental character to "split".
      Returns:
        the high surrogate of a supplemental character

    - #### lowSurrogate

          public static char lowSurrogate(int c)

      Parameters:
        `c` - The supplemental character to "split".
      Returns:
        the low surrogate of a supplemental character

    - #### isHighSurrogate

          public static boolean isHighSurrogate(int c)

      Parameters:
        `c` - The character to check.
      Returns:
        whether the given character is a high surrogate

    - #### isLowSurrogate

          public static boolean isLowSurrogate(int c)

      Parameters:
        `c` - The character to check.
      Returns:
        whether the given character is a low surrogate

    - #### isValid

          public static boolean isValid(int c)

      Parameters:
        `c` - The character to check.
      Returns:
        true if the specified character is valid. This method also checks the surrogate character range from 0x10000 to 0x10FFFF.

        If the program chooses to apply the mask directly to the `CHARS` array, then they are responsible for checking the surrogate character range.

    - #### isInvalid

          public static boolean isInvalid(int c)

      Parameters:
        `c` - The character to check.
      Returns:
        true if the specified character is invalid.

    - #### isContent

          public static boolean isContent(int c)

      Parameters:
        `c` - The character to check.
      Returns:
        true if the specified character can be considered content.

    - #### isMarkup

          public static boolean isMarkup(int c)

      Parameters:
        `c` - The character to check.
      Returns:
        true if the specified character can be considered markup. Markup characters include '<', '&', and '%'.

    - #### isSpace

          public static boolean isSpace(int c)

      Parameters:
        `c` - The character to check.
      Returns:
        true if the specified character is a space character as defined by production [3] in the XML 1.0 specification.

    - #### isNameStart

          public static boolean isNameStart(int c)

      Parameters:
        `c` - The character to check.
      Returns:
        true if the specified character is a valid name start character as defined by production [5] in the XML 1.0 specification.

    - #### isName

          public static boolean isName(int c)

      Parameters:
        `c` - The character to check.
      Returns:
        true if the specified character is a valid name character as defined by production [4] in the XML 1.0 specification.

    - #### isNCNameStart

          public static boolean isNCNameStart(int c)

      Parameters:
        `c` - The character to check.
      Returns:
        true if the specified character is a valid NCName start character as defined by production [4] in Namespaces in XML recommendation.

    - #### isNCName

          public static boolean isNCName(int c)

      Parameters:
        `c` - The character to check.
      Returns:
        true if the specified character is a valid NCName character as defined by production [5] in Namespaces in XML recommendation.

    - #### isPubid

          public static boolean isPubid(int c)

      Parameters:
        `c` - The character to check.
      Returns:
        true if the specified character is a valid Pubid character as defined by production [13] in the XML 1.0 specification.

    - #### isValidName

          public static boolean isValidName(String name)

      Check to see if a string is a valid Name according to [5] in the XML 1.0 Recommendation
      Parameters:
        `name` - string to check
      Returns:
        true if name is a valid Name

    - #### isValidNCName

          public static boolean isValidNCName(String ncName)

      Check to see if a string is a valid NCName according to [4] from the XML Namespaces 1.0 Recommendation
      Parameters:
        `ncName` - string to check
      Returns:
        true if name is a valid NCName

    - #### isValidNmtoken

          public static boolean isValidNmtoken(String nmtoken)

      Check to see if a string is a valid Nmtoken according to [7] in the XML 1.0 Recommendation
      Parameters:
        `nmtoken` - string to check
      Returns:
        true if nmtoken is a valid Nmtoken

    - #### isValidIANAEncoding

          public static boolean isValidIANAEncoding(String ianaEncoding)

      Parameters:
        `ianaEncoding` - The IANA encoding name.
      Returns:
        true if the encoding name is a valid IANA encoding. This method does not verify that there is a decoder available for this encoding, only that the characters are valid for an IANA encoding name.

    - #### isValidJavaEncoding

          public static boolean isValidJavaEncoding(String javaEncoding)

      Parameters:
        `javaEncoding` - The Java encoding name.
      Returns:
        true if the encoding name is a valid Java encoding. This method does not verify that there is a decoder available for this encoding, only that the characters are valid for an Java encoding name.

Copyright © 2000–2023 Apache Software Foundation. All rights reserved.