Skip navigation links

Oracle® Coherence Java API Reference
v3.5.1

E15583-01


com.tangosol.run.xml
Class SimpleParser

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.run.xml.SimpleParser


public class SimpleParser
extends Base

This class uses the XmlTokenizer to produce an XmlDocument from XML text.

Version:
1.00, 2001.07.16
Author:
Cameron Purdy

Field Summary
protected  XmlToken m_token
          The "current" token being evaluated.
protected  XmlTokenizer m_toker
          The lexical tokenizer.

 

Constructor Summary
SimpleParser()
          Construct an XML SimpleParser.

 

Method Summary
protected  XmlToken current()
          Returns the current token and advances to the next token.
protected  boolean hasCurrent()
          Determine if there is a current token.
protected  boolean hasNext()
          Determine if there is a next token.
protected  void init()
          Internal initialization.
protected  XmlDocument instantiateDocument()
          Factory method to instantiate an XmlDocument implementation.
static void main(java.lang.String[] asArgs)
          Unit test.
protected  XmlToken mark()
          Marks the current position and returns it as a token.
protected  XmlToken match(int id)
          Verifies that the current token matches the passed token id and, if so, advances to the next token.
protected  XmlToken match(java.lang.String sName)
          Verifies that the current token is a name token whose name matches the passed String and, if so, advances to the next token.
protected  XmlToken next()
          Advances to and returns the next token.
protected  void parseComment(XmlElement xml)
           
protected  void parseComment(XmlElement xml, boolean fIsDocument)
           
protected  void parseDoctype(XmlDocument xml)
           
protected  void parseDocument(XmlDocument xml)
          Factory method to instantiate an XmlDocument implementation.
protected  void parseElement(XmlElement xml)
          Note: '<' and element name have already been parsed
protected  void parseMisc(XmlElement xml)
           
protected  void parsePi(XmlElement xml)
           
protected  void parsePi(XmlElement xml, boolean fXmlDeclAllowed)
           
 XmlDocument parseXml(java.io.InputStream stream)
          Parse the specified InputStream into an XmlDocument object.
 XmlDocument parseXml(java.io.InputStream stream, java.lang.String sCharset)
          Parse the specified InputStream into an XmlDocument object using the specified charset.
 XmlDocument parseXml(java.io.Reader reader)
          Parse the specified Reader into an XmlDocument object.
 XmlDocument parseXml(java.lang.String sXml)
          Parse the specified String into an XmlDocument object.
 XmlDocument parseXml(java.lang.String sXml, XmlDocument xml)
          Parse the passed script.
protected  void parseXmlDecl(XmlDocument xml)
           
protected  XmlToken peek(int id)
          Tests if the current token matches the passed token id and, if so, advances to the next token.
protected  XmlToken peek(int cat, int subcat)
          Tests if the current token matches the passed token category and sub-category.
protected  XmlToken peek(java.lang.String sName)
          Tests if the current token is a name that matches the passed String and, if so, advances to the next token.

 

Field Detail

m_toker

protected XmlTokenizer m_toker
The lexical tokenizer.

m_token

protected XmlToken m_token
The "current" token being evaluated.

Constructor Detail

SimpleParser

public SimpleParser()
Construct an XML SimpleParser.

Method Detail

init

protected void init()
Internal initialization.

parseXml

public XmlDocument parseXml(java.lang.String sXml)
                     throws java.io.IOException
Parse the specified String into an XmlDocument object.
Parameters:
sXml - the String to parse
Returns:
an XmlDocument object
Throws:
java.io.IOException

parseXml

public XmlDocument parseXml(java.io.Reader reader)
                     throws java.io.IOException
Parse the specified Reader into an XmlDocument object.
Parameters:
reader - the Reader object
Returns:
an XmlDocument object
Throws:
java.io.IOException

parseXml

public XmlDocument parseXml(java.io.InputStream stream)
                     throws java.io.IOException
Parse the specified InputStream into an XmlDocument object.
Parameters:
stream - the InputStream object
Returns:
an XmlDocument object
Throws:
java.io.IOException

parseXml

public XmlDocument parseXml(java.io.InputStream stream,
                            java.lang.String sCharset)
                     throws java.io.IOException
Parse the specified InputStream into an XmlDocument object using the specified charset.
Parameters:
stream - the InputStream object
sCharset - the charset name
Returns:
an XmlDocument object
Throws:
java.io.IOException

parseXml

public XmlDocument parseXml(java.lang.String sXml,
                            XmlDocument xml)
                     throws java.io.IOException
Parse the passed script.
Parameters:
sXml - the script to parse (as a string)
xml - the XML document object to parse into
Throws:
java.io.IOException

instantiateDocument

protected XmlDocument instantiateDocument()
Factory method to instantiate an XmlDocument implementation.
Returns:
an object implementing XmlDocument

main

public static void main(java.lang.String[] asArgs)
Unit test.

parseDocument

protected void parseDocument(XmlDocument xml)
                      throws CompilerException
Factory method to instantiate an XmlDocument implementation.
Parameters:
xml - a blank XmlDocument
Throws:
CompilerException

parsePi

protected void parsePi(XmlElement xml)
                throws CompilerException
Throws:
CompilerException

parsePi

protected void parsePi(XmlElement xml,
                       boolean fXmlDeclAllowed)
                throws CompilerException
Throws:
CompilerException

parseXmlDecl

protected void parseXmlDecl(XmlDocument xml)
                     throws CompilerException
Throws:
CompilerException

parseDoctype

protected void parseDoctype(XmlDocument xml)
                     throws CompilerException
Throws:
CompilerException

parseElement

protected void parseElement(XmlElement xml)
                     throws CompilerException
Note: '<' and element name have already been parsed
Throws:
CompilerException

parseMisc

protected void parseMisc(XmlElement xml)
                  throws CompilerException
Throws:
CompilerException

parseComment

protected void parseComment(XmlElement xml)
                     throws CompilerException
Throws:
CompilerException

parseComment

protected void parseComment(XmlElement xml,
                            boolean fIsDocument)
                     throws CompilerException
Throws:
CompilerException

hasCurrent

protected boolean hasCurrent()
Determine if there is a current token.
Returns:
true if there is a current token

current

protected XmlToken current()
                    throws CompilerException
Returns the current token and advances to the next token.
Returns:
the current token
Throws:
CompilerException - potentially thrown by the tokenizer

hasNext

protected boolean hasNext()
Determine if there is a next token.
Returns:
true if there is a next token

next

protected XmlToken next()
                 throws CompilerException
Advances to and returns the next token.
Returns:
the next token
Throws:
CompilerException - potentially thrown by the tokenizer

match

protected XmlToken match(int id)
                  throws CompilerException
Verifies that the current token matches the passed token id and, if so, advances to the next token. Otherwise, a syntax exception is thrown.
Parameters:
id - the token id to match
Returns:
the current token
Throws:
SyntaxException - thrown if the token does not match
CompilerException - potentially thrown by the tokenizer

match

protected XmlToken match(java.lang.String sName)
                  throws CompilerException
Verifies that the current token is a name token whose name matches the passed String and, if so, advances to the next token. Otherwise, a syntax exception is thrown.
Parameters:
sName - the name token text to match
Returns:
the matched token
Throws:
SyntaxException - thrown if the token does not match
CompilerException - potentially thrown by the tokenizer

peek

protected XmlToken peek(int id)
                 throws CompilerException
Tests if the current token matches the passed token id and, if so, advances to the next token.
Parameters:
id - the token id to peek for
Returns:
the current token, if matched, or null
Throws:
CompilerException - potentially thrown by the tokenizer

peek

protected XmlToken peek(int cat,
                        int subcat)
                 throws CompilerException
Tests if the current token matches the passed token category and sub-category. If so, it returns the current token and advances to the next token.
Parameters:
cat - the category to peek for
subcat - the sub-category to peek for
Returns:
the current token, if matched, or null
Throws:
CompilerException - potentially thrown by the tokenizer

peek

protected XmlToken peek(java.lang.String sName)
                 throws CompilerException
Tests if the current token is a name that matches the passed String and, if so, advances to the next token.
Parameters:
sName - the name token text to peek for
Returns:
id the current token, if matched, or null
Throws:
CompilerException - potentially thrown by the tokenizer

mark

protected XmlToken mark()
Marks the current position and returns it as a token.
Returns:
the current token

Skip navigation links

Oracle® Coherence Java API Reference
v3.5.1

E15583-01


Copyright © 2000, 2009, Oracle. All rights reserved.