org.glassfish.admin.rest.readers
Class XmlInputReader

java.lang.Object
  extended by org.glassfish.admin.rest.readers.InputReader
      extended by org.glassfish.admin.rest.readers.XmlInputReader

public class XmlInputReader
extends InputReader

Author:
Rajeshwar Patil

Field Summary
static java.util.HashMap entity
          The table of entity values.
 
Constructor Summary
XmlInputReader(java.io.Reader reader)
          Construct a XmlInputReader from a string.
XmlInputReader(java.lang.String s)
          Construct a InputReader from a string.
 
Method Summary
 java.lang.String nextCDATA()
          Get the text in the CDATA block.
 java.lang.Object nextContent()
          Get the next XML outer token, trimming whitespace.
 java.lang.Object nextEntity(char a)
          Return the next entity.
 java.lang.Object nextMeta()
          Returns the next XML meta token.
 java.lang.Object nextToken()
          Get the next XML Token.
 boolean skipPast(java.lang.String to)
          Skip characters until past the requested string.
 
Methods inherited from class org.glassfish.admin.rest.readers.InputReader
back, error, more, next, next, nextNonSpace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entity

public static final java.util.HashMap entity
The table of entity values. It initially contains Character values for amp, apos, gt, lt, quot.

Constructor Detail

XmlInputReader

public XmlInputReader(java.io.Reader reader)
Construct a XmlInputReader from a string.

Parameters:
reader - A reader.

XmlInputReader

public XmlInputReader(java.lang.String s)
Construct a InputReader from a string.

Parameters:
s - A source string.
Method Detail

nextCDATA

public java.lang.String nextCDATA()
                           throws InputException
Get the text in the CDATA block.

Returns:
The string up to the ]]>.
Throws:
InputException - If the ]]> is not found.

nextContent

public java.lang.Object nextContent()
                             throws InputException
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:
InputException

nextEntity

public java.lang.Object nextEntity(char a)
                            throws InputException
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:
InputException - If missing ';' in XML entity.

nextMeta

public java.lang.Object nextMeta()
                          throws InputException
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:
InputException - If a string is not properly closed or if the XML is badly structured.

nextToken

public java.lang.Object nextToken()
                           throws InputException
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:
InputException - If the XML is not well formed.

skipPast

public boolean skipPast(java.lang.String to)
                 throws InputException
Skip characters until past the requested string. If it is not found, we are left at the end of the source with a result of false.

Parameters:
to - A string to skip past.
Throws:
InputException


Copyright © 2012 GlassFish Community. All Rights Reserved.