com.sun.xml.stream
Class XMLDocumentFragmentScannerImpl.FragmentContentDriver
java.lang.Object
com.sun.xml.stream.XMLDocumentFragmentScannerImpl.FragmentContentDriver
- All Implemented Interfaces:
- XMLDocumentFragmentScannerImpl.Driver
- Direct Known Subclasses:
- XMLDocumentScannerImpl.ContentDriver
- Enclosing class:
- XMLDocumentFragmentScannerImpl
protected class XMLDocumentFragmentScannerImpl.FragmentContentDriver
- extends java.lang.Object
- implements XMLDocumentFragmentScannerImpl.Driver
Driver to handle content scanning. This driver is capable of reading
the fragment of XML document. When it has finished reading fragment
of XML documents, it can pass the job of reading to another driver.
This class has been modified as per the new design which is more suited to
efficiently build pull parser. Lot of performance improvements have been done and
the code has been added to support stax functionality/features.
- Author:
- Neeraj Bajaj, Sun Microsystems, Andy Clark, IBM, Eric Ye, IBM
Method Summary |
void |
decideSubState()
SCANNER_STATE_CONTENT and SCANNER_STATE_START_OF_MARKUP are two super states of the parser. |
protected boolean |
elementDepthIsZeroHook()
Element depth iz zero. |
protected void |
endOfFileHook(java.io.EOFException e)
End of file hook. |
int |
next()
Drives the parser to the next state/event on the input. |
protected boolean |
scanForDoctypeHook()
Scan for DOCTYPE hook. |
protected boolean |
scanRootElementHook()
Scan for root element hook. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XMLDocumentFragmentScannerImpl.FragmentContentDriver
protected XMLDocumentFragmentScannerImpl.FragmentContentDriver()
decideSubState
public void decideSubState()
throws java.io.IOException
- SCANNER_STATE_CONTENT and SCANNER_STATE_START_OF_MARKUP are two super states of the parser.
At any point of time when in doubt over the current state of the parser, the state should be
set to SCANNER_STATE_CONTENT. Parser will automatically revive itself and will set state of
the parser to one of its sub state.
sub states are defined in the parser on the basis of different XML component like
SCANNER_STATE_ENTITY_REFERENCE , SCANNER_STATE_START_ELEMENT, SCANNER_STATE_CDATA etc..
These sub states help the parser to have fine control over the parsing. These are the
different milepost, parser stops at each sub state (milepost). Based on this state it is
decided if paresr needs to stop at next milepost ??
- Throws:
java.io.IOException
next
public int next()
throws java.io.IOException,
org.apache.xerces.xni.XNIException
- Drives the parser to the next state/event on the input. Parser is guaranteed
to stop at the next state/event. Internally XML document
is divided into several states. Each state represents a sections of XML
document. When this functions returns normally, it has read the section
of XML document and returns the state corresponding to section of
document which has been read. For optimizations, a particular driver
can read ahead of the section of document (state returned) just read and
can maintain a different internal state.
State returned corresponds to Stax states.
- Specified by:
next
in interface XMLDocumentFragmentScannerImpl.Driver
- Returns:
- state representing the section of document just read.
- Throws:
java.io.IOException
- Thrown on i/o error.
org.apache.xerces.xni.XNIException
- Thrown on parse error.
scanForDoctypeHook
protected boolean scanForDoctypeHook()
throws java.io.IOException,
org.apache.xerces.xni.XNIException
- Scan for DOCTYPE hook. This method is a hook for subclasses
to add code to handle scanning for a the "DOCTYPE" string
after the string "
- Returns:
- True if the "DOCTYPE" was scanned; false if "DOCTYPE"
was not scanned.
- Throws:
java.io.IOException
org.apache.xerces.xni.XNIException
elementDepthIsZeroHook
protected boolean elementDepthIsZeroHook()
throws java.io.IOException,
org.apache.xerces.xni.XNIException
- Element depth iz zero. This methos is a hook for subclasses
to add code to handle when the element depth hits zero. When
scanning a document fragment, an element depth of zero is
normal. However, when scanning a full XML document, the
scanner must handle the trailing miscellanous section of
the document after the end of the document's root element.
- Returns:
- True if the caller should stop and return true which
allows the scanner to switch to a new scanning
driver. A return value of false indicates that
the content driver should continue as normal.
- Throws:
java.io.IOException
org.apache.xerces.xni.XNIException
scanRootElementHook
protected boolean scanRootElementHook()
throws java.io.IOException,
org.apache.xerces.xni.XNIException
- Scan for root element hook. This method is a hook for
subclasses to add code that handles scanning for the root
element. When scanning a document fragment, there is no
"root" element. However, when scanning a full XML document,
the scanner must handle the root element specially.
- Returns:
- True if the caller should stop and return true which
allows the scanner to switch to a new scanning
driver. A return value of false indicates that
the content driver should continue as normal.
- Throws:
java.io.IOException
org.apache.xerces.xni.XNIException
endOfFileHook
protected void endOfFileHook(java.io.EOFException e)
throws java.io.IOException,
org.apache.xerces.xni.XNIException
- End of file hook. This method is a hook for subclasses to
add code that handles the end of file. The end of file in
a document fragment is OK if the markup depth is zero.
However, when scanning a full XML document, an end of file
is always premature.
- Throws:
java.io.IOException
org.apache.xerces.xni.XNIException
Copyright ? 2002-2003 Apache XML Project. All Rights Reserved.