GXPARSE hosted by SourceForge.net Logo

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

java.lang.Object
  extended by ca.gorman.xml.parse.toolkit.Coroutine_NoCallback<T>
      extended by ca.gorman.xml.parse.toolkit.Coroutine_Callback<T>
          extended by ca.gorman.xml.parse.toolkit.CoroutineDocument<T>
All Implemented Interfaces:
CurrentDocument, Document, Runnable

public final class CoroutineDocument<T extends Parser>
extends Coroutine_Callback<T>
implements CurrentDocument, Runnable

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


Constructor Summary
CoroutineDocument()
           Construct instance that cannot be used until initialized by setCoroutine setListener
CoroutineDocument(Coroutine coroutine)
           Construct instance that cannot be used until initialized by setListener
CoroutineDocument(Coroutine coroutine, Listener<T> listener)
           Construct fully initialized instance, ready for immediate use.
 
Method Summary
 Listener<T> getListener()
           Get the listener.
 void parseContent()
           Parse the content of a Document.
 void run()
           Execute a callback from the parser thread to run the document handler in the application thread.
 void setListener(Listener<T> listener)
           Set or reset the listener.
 
Methods inherited from class ca.gorman.xml.parse.toolkit.Coroutine_Callback
getCoroutine, setCoroutine
 
Methods inherited from class ca.gorman.xml.parse.toolkit.Coroutine_NoCallback
getParser, setParser
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoroutineDocument

public CoroutineDocument()

Construct instance that cannot be used until initialized by setCoroutine setListener


CoroutineDocument

public CoroutineDocument(Coroutine coroutine)

Construct instance that cannot be used until initialized by setListener

Throws:
NullPointerException - if coroutine is null

CoroutineDocument

public CoroutineDocument(Coroutine coroutine,
                         Listener<T> listener)

Construct fully initialized instance, ready for immediate use.

Throws:
NullPointerException - if coroutine or listener is null
Method Detail

setListener

public void setListener(Listener<T> listener)

Set or reset the listener.

Throws:
NullPointerException - if listener is null

getListener

public Listener<T> getListener()

Get the listener.


run

public void run()

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

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

parseContent

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

Parse the content of a Document.

This method causes the parser to continue operation, and does not return until the end of the document is reached. No part of the Document has been parsed before this method is invoked.

Specified by:
parseContent in interface CurrentDocument
Throws:
ListenerException
IOException

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