GXPARSE hosted by SourceForge.net Logo

ca.gorman.xml.parse.toolkit
Class CoroutineElement<T extends Parser>

java.lang.Object
  extended by ca.gorman.xml.parse.toolkit.AbstractElement
      extended by ca.gorman.xml.parse.toolkit.CoroutineElement<T>
All Implemented Interfaces:
CurrentElement, Element, Runnable

public class CoroutineElement<T extends Parser>
extends AbstractElement
implements CurrentElement, Runnable

Invokes element handler from the parser thread to run in the application thread.


Constructor Summary
CoroutineElement(QName qName, Attribute[] attribute)
           Constructor.
 
Method Summary
 int getDocumentLevel()
           Get the nesting level of this element.
 void parseContent()
           Parse the content of an element (required even if there is no content).
 void run()
           Execute a callback from the parser thread to run the element handler in the application thread.
 void skipContent()
           Unsupported operation, override this method to implement the ability to skip the content of an element.
 
Methods inherited from class ca.gorman.xml.parse.toolkit.AbstractElement
equals, getAttribute, getAttributes, getChildCount, getParent, getQName, getRepeatCount, getSiblingCount, hasAncestor, hashCode, hasParent, newInstance, setAttribute, setAttributes, setParent, setQName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ca.gorman.xml.parse.Element
equals, getAttribute, getAttributes, getChildCount, getParent, getQName, getRepeatCount, getSiblingCount, hasAncestor, hashCode, hasParent
 

Constructor Detail

CoroutineElement

public CoroutineElement(QName qName,
                        Attribute[] attribute)

Constructor.

Parameters:
qName - name of element, not null
attribute - zero or more attributes of element, not null
Throws:
NullPointerException - if any parameter is null
Method Detail

run

public final void run()

Execute a callback from the parser thread to run the element handler in the application thread. This method is invoked just before the parser starts parsing the actual DTD, and runs until the parser reaches the end of the DTD. The parser is suspended until the element handler invokes the parseContent method.

Specified by:
run in interface Runnable
Throws:
CoroutineTransferException - if the element handler throws an exception.

parseContent

public final void parseContent()
                        throws ListenerException,
                               IOException
Description copied from interface: CurrentElement

Parse the content of an element (required even if there is no content).

This method causes the parser to continue operation, and does not return until the end of the element.

Specified by:
parseContent in interface CurrentElement
Throws:
ListenerException
IOException

skipContent

public void skipContent()
                 throws ListenerException,
                        IOException

Unsupported operation, override this method to implement the ability to skip the content of an element.

Specified by:
skipContent in interface CurrentElement
Throws:
UnsupportedOperationException - when invoked
ListenerException
IOException

getDocumentLevel

public final int getDocumentLevel()
Description copied from interface: CurrentElement

Get the nesting level of this element.

Top element (the document element) is level 1, child elements have higher numbers.

Specified by:
getDocumentLevel in interface CurrentElement

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