GXPARSE hosted by SourceForge.net Logo

ca.gorman.xml.parse
Interface Parser<T extends Global>

All Known Implementing Classes:
XMLParser

public interface Parser<T extends Global>

XML stream parser that invokes Listener methods to drive an XML processing application.


Method Summary
 Element getCurrentElement()
           Get the element that is on top of the element stack.
 Element[] getElementStack()
           Get the element stack as an array.
 T getGlobal()
           Get the instance of Global, if one was provided to the Parser.
 Listener<Parser<T>> getListener()
           Get Listener.
 Location getLocation()
           Get information about the current location of the Parser in the input stream.
 boolean isParsing(QName qName)
           Indicate whether a particular element is currently being parsed.
 void parse(Input input)
           Parse a document, without making an instance of Global accessible to all Listener methods.
 void parse(Input input, T global)
           Parse a document, making an instance of Global accessible to all Listener methods.
 void setListener(Listener<Parser<T>> listener)
           Set Listener.
 

Method Detail

getListener

Listener<Parser<T>> getListener()

Get Listener.


setListener

void setListener(Listener<Parser<T>> listener)

Set Listener.

Parameters:
listener - that will receive information from the parser.
Throws:
NullPointerException - if listener is null

parse

void parse(Input input)
           throws ListenerException,
                  ParseException,
                  IOException

Parse a document, without making an instance of Global accessible to all Listener methods.

Parameters:
input - an Input that has been initialized to identify a source for an XML document
Throws:
NullPointerException - if input is null
IllegalArgumentException - if input does not contain enough information to identify a source that the parser can read
ParseException - if any component of the Parser throws an exception
ListenerException - if the Listener throws ListenerException
IOException - if the Parser throws IOException while reading input or the Listener throws IOException while writing output.

parse

void parse(Input input,
           T global)
           throws ListenerException,
                  ParseException,
                  IOException

Parse a document, making an instance of Global accessible to all Listener methods.

Parameters:
input - an Input that has been initialized to identify a source for an XML document
global - an instance Global, or null.
Throws:
NullPointerException - if input is null
IllegalArgumentException - if input does not contain enough information to identify a source that the parser can read
ParseException - if any component of the Parser throws an exception
ListenerException - if the Listener throws ListenerException
IOException - if the Parser throws IOException while reading input or the Listener throws IOException while writing output.

getGlobal

T getGlobal()

Get the instance of Global, if one was provided to the Parser.

Returns:
global an instance Global, or null.

getCurrentElement

Element getCurrentElement()

Get the element that is on top of the element stack.

Returns:
the innermost element being parsed, or null if there are no elements currently on the element stack

getElementStack

Element[] getElementStack()

Get the element stack as an array.

Returns:
an array of the zero or more elements currently being parsed, beginning with the outermost (document) element and ending with the innermost element

isParsing

boolean isParsing(QName qName)

Indicate whether a particular element is currently being parsed.

Returns:
true if the named element is currently being parsed, false otherwise

getLocation

Location getLocation()

Get information about the current location of the Parser in the input stream. The information is valid only during the invocation of a Listener method.

Returns:
a Location when the parser is active, null when the parser is not active

GXPARSE download

GXPARSE Generic XML Stream Parser API and supporting tools.   Release $Name: gxparse-sf-alpha-2_0 $
Copyright 2003-2004 Ian E. Gorman
Released under GNU Lesser General Public License