org.apache.xml.dtm.ref
Class IncrementalSAXSource_Xerces

java.lang.Object
  extended by org.apache.xml.dtm.ref.IncrementalSAXSource_Xerces
All Implemented Interfaces:
IncrementalSAXSource

public class IncrementalSAXSource_Xerces
extends java.lang.Object
implements IncrementalSAXSource

IncrementalSAXSource_Xerces takes advantage of the fact that Xerces1 incremental mode is already a coroutine of sorts, and just wraps our IncrementalSAXSource API around it.

Usage example: See main().

Status: Passes simple main() unit-test. NEEDS JAVADOC.


Field Summary
(package private)  java.lang.reflect.Constructor fConfigInputSourceCtor
           
(package private)  java.lang.reflect.Method fConfigParse
           
(package private)  java.lang.reflect.Method fConfigSetByteStream
           
(package private)  java.lang.reflect.Method fConfigSetCharStream
           
(package private)  java.lang.reflect.Method fConfigSetEncoding
           
(package private)  java.lang.reflect.Method fConfigSetInput
           
(package private)  SAXParser fIncrementalParser
           
private  boolean fParseInProgress
           
(package private)  java.lang.reflect.Method fParseSome
           
(package private)  java.lang.reflect.Method fParseSomeSetup
           
(package private)  java.lang.Object fPullParserConfig
           
(package private)  java.lang.reflect.Method fReset
           
(package private)  java.lang.reflect.Method fSetInputSource
           
private static java.lang.Object[] noparms
           
private static java.lang.Object[] parmsfalse
           
 
Constructor Summary
IncrementalSAXSource_Xerces()
          Create a IncrementalSAXSource_Xerces, and create a SAXParser to go with it.
IncrementalSAXSource_Xerces(SAXParser parser)
          Create a IncrementalSAXSource_Xerces wrapped around an existing SAXParser.
 
Method Summary
static IncrementalSAXSource createIncrementalSAXSource()
           
static IncrementalSAXSource createIncrementalSAXSource(SAXParser parser)
           
 java.lang.Object deliverMoreNodes(boolean parsemore)
          deliverMoreNodes() is a simple API which tells the coroutine parser that we need more nodes.
static void main(java.lang.String[] args)
          Simple unit test.
private  boolean parseSome()
           
private  boolean parseSomeSetup(org.xml.sax.InputSource source)
           
 void setContentHandler(org.xml.sax.ContentHandler handler)
          Register a SAX-style content handler for us to output to
 void setDTDHandler(org.xml.sax.DTDHandler handler)
          Register a SAX-style DTD handler for us to output to
 void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler)
          Register a SAX-style lexical handler for us to output to
 void startParse(org.xml.sax.InputSource source)
          startParse() is a simple API which tells the IncrementalSAXSource to begin reading a document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fParseSomeSetup

java.lang.reflect.Method fParseSomeSetup

fParseSome

java.lang.reflect.Method fParseSome

fPullParserConfig

java.lang.Object fPullParserConfig

fConfigSetInput

java.lang.reflect.Method fConfigSetInput

fConfigParse

java.lang.reflect.Method fConfigParse

fSetInputSource

java.lang.reflect.Method fSetInputSource

fConfigInputSourceCtor

java.lang.reflect.Constructor fConfigInputSourceCtor

fConfigSetByteStream

java.lang.reflect.Method fConfigSetByteStream

fConfigSetCharStream

java.lang.reflect.Method fConfigSetCharStream

fConfigSetEncoding

java.lang.reflect.Method fConfigSetEncoding

fReset

java.lang.reflect.Method fReset

fIncrementalParser

SAXParser fIncrementalParser

fParseInProgress

private boolean fParseInProgress

noparms

private static final java.lang.Object[] noparms

parmsfalse

private static final java.lang.Object[] parmsfalse
Constructor Detail

IncrementalSAXSource_Xerces

public IncrementalSAXSource_Xerces()
                            throws java.lang.NoSuchMethodException
Create a IncrementalSAXSource_Xerces, and create a SAXParser to go with it. Xerces2 incremental parsing is only supported if this constructor is used, due to limitations in the Xerces2 API (as of Beta 3). If you don't like that restriction, tell the Xerces folks that there should be a simpler way to request incremental SAX parsing.

Throws:
java.lang.NoSuchMethodException

IncrementalSAXSource_Xerces

public IncrementalSAXSource_Xerces(SAXParser parser)
                            throws java.lang.NoSuchMethodException
Create a IncrementalSAXSource_Xerces wrapped around an existing SAXParser. Currently this works only for recent releases of Xerces-1. Xerces-2 incremental is currently possible only if we are allowed to create the parser instance, due to limitations in the API exposed by Xerces-2 Beta 3; see the no-args constructor for that code.

Throws:
if - the SAXParser class doesn't support the Xerces incremental parse operations. In that case, caller should fall back upon the IncrementalSAXSource_Filter approach.
java.lang.NoSuchMethodException
Method Detail

createIncrementalSAXSource

public static IncrementalSAXSource createIncrementalSAXSource()

createIncrementalSAXSource

public static IncrementalSAXSource createIncrementalSAXSource(SAXParser parser)

setContentHandler

public void setContentHandler(org.xml.sax.ContentHandler handler)
Description copied from interface: IncrementalSAXSource
Register a SAX-style content handler for us to output to

Specified by:
setContentHandler in interface IncrementalSAXSource

setLexicalHandler

public void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler)
Description copied from interface: IncrementalSAXSource
Register a SAX-style lexical handler for us to output to

Specified by:
setLexicalHandler in interface IncrementalSAXSource

setDTDHandler

public void setDTDHandler(org.xml.sax.DTDHandler handler)
Description copied from interface: IncrementalSAXSource
Register a SAX-style DTD handler for us to output to

Specified by:
setDTDHandler in interface IncrementalSAXSource

startParse

public void startParse(org.xml.sax.InputSource source)
                throws org.xml.sax.SAXException
startParse() is a simple API which tells the IncrementalSAXSource to begin reading a document.

Specified by:
startParse in interface IncrementalSAXSource
Throws:
org.xml.sax.SAXException - is parse thread is already in progress or parsing can not be started.

deliverMoreNodes

public java.lang.Object deliverMoreNodes(boolean parsemore)
deliverMoreNodes() is a simple API which tells the coroutine parser that we need more nodes. This is intended to be called from one of our partner routines, and serves to encapsulate the details of how incremental parsing has been achieved.

Specified by:
deliverMoreNodes in interface IncrementalSAXSource
Parameters:
parsemore - If true, tells the incremental parser to generate another chunk of output. If false, tells the parser that we're satisfied and it can terminate parsing of this document.
Returns:
Boolean.TRUE if the CoroutineParser believes more data may be available for further parsing. Boolean.FALSE if parsing ran to completion. Exception if the parser objected for some reason.

parseSomeSetup

private boolean parseSomeSetup(org.xml.sax.InputSource source)
                        throws org.xml.sax.SAXException,
                               java.io.IOException,
                               java.lang.IllegalAccessException,
                               java.lang.reflect.InvocationTargetException,
                               java.lang.InstantiationException
Throws:
org.xml.sax.SAXException
java.io.IOException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.InstantiationException

parseSome

private boolean parseSome()
                   throws org.xml.sax.SAXException,
                          java.io.IOException,
                          java.lang.IllegalAccessException,
                          java.lang.reflect.InvocationTargetException
Throws:
org.xml.sax.SAXException
java.io.IOException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

main

public static void main(java.lang.String[] args)
Simple unit test. Attempt coroutine parsing of document indicated by first argument (as a URI), report progress.