org.richfaces.json

## Class XMLTokener

- java.lang.Object
- - org.richfaces.json.JSONTokener
  - - org.richfaces.json.XMLTokener

-     public class XMLTokener
      extends JSONTokener

  The XMLTokener extends the JSONTokener to provide additional methods for the parsing of XML texts.
  Version:
    2
  Author:
    JSON.org

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static HashMap` | `ENTITY` The table of entity values.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XMLTokener(String s)` Construct an XMLTokener from a string.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `nextCDATA()` Get the text in the CDATA block.
    `Object` | `nextContent()` Get the next XML outer token, trimming whitespace.
    `Object` | `nextEntity(char a)` Return the next entity.
    `Object` | `nextMeta()` Returns the next XML meta token.
    `Object` | `nextToken()` Get the next XML Token.

    - ### Methods inherited from class org.richfaces.json.JSONTokener

      `back, dehexchar, getMyIndex, more, next, next, next, nextClean, nextString, nextTo, nextTo, nextValue, skipPast, skipTo, syntaxError, toString`

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

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

- - ### Field Detail

    - #### ENTITY

          public static final HashMap ENTITY

      The table of entity values. It initially contains Character values for amp, apos, gt, lt, quot.

  - ### Constructor Detail

    - #### XMLTokener

          public XMLTokener(String s)

      Construct an XMLTokener from a string.
      Parameters:
        `s` - A source string.

  - ### Method Detail

    - #### nextCDATA

          public String nextCDATA()
                           throws JSONException

      Get the text in the CDATA block.
      Returns:
        The string up to the `]]>`.
      Throws:
        `JSONException` - If the `]]>` is not found.

    - #### nextContent

          public Object nextContent()
                             throws JSONException

      Get the next XML outer token, trimming whitespace. There are two kinds of tokens: the '<' character which begins a markup tag, and the content text between markup tags.
      Returns:
        A string, or a '<' Character, or null if there is no more source text.
      Throws:
        `JSONException`

    - #### nextEntity

          public Object nextEntity(char a)
                            throws JSONException

      Return the next entity. These entities are translated to Characters: `& ' > < "`.
      Parameters:
        `a` - An ampersand character.
      Returns:
        A Character or an entity String if the entity is not recognized.
      Throws:
        `JSONException` - If missing ';' in XML entity.

    - #### nextMeta

          public Object nextMeta()
                          throws JSONException

      Returns the next XML meta token. This is used for skipping over and structures.
      Returns:
        Syntax characters (`< > / = ! ?`) are returned as Character, and strings and names are returned as Boolean. We don't care what the values actually are.
      Throws:
        `JSONException` - If a string is not properly closed or if the XML is badly structured.

    - #### nextToken

          public Object nextToken()
                           throws JSONException

      Get the next XML Token. These tokens are found inside of angle brackets. It may be one of these characters: `/ > = ! ?` or it may be a string wrapped in single quotes or double quotes, or it may be a name.
      Returns:
        a String or a Character.
      Throws:
        `JSONException` - If the XML is not well formed.

Copyright © 2015 JBoss by Red Hat. All Rights Reserved.