com.sun.xml.stream
Class XMLDocumentScannerImpl

java.lang.Object
  extended by com.sun.xml.stream.XMLScanner
      extended by com.sun.xml.stream.XMLDocumentFragmentScannerImpl
          extended by com.sun.xml.stream.XMLDocumentScannerImpl
All Implemented Interfaces:
XMLEntityHandler, org.apache.xerces.xni.parser.XMLComponent, org.apache.xerces.xni.parser.XMLDocumentScanner, org.apache.xerces.xni.parser.XMLDocumentSource
Direct Known Subclasses:
XMLNSDocumentScannerImpl

public class XMLDocumentScannerImpl
extends XMLDocumentFragmentScannerImpl

This class is responsible for scanning XML document structure and content. This class has been modified as per the new design which is more suited to efficiently build pull parser. Lot of improvements have been done and the code has been added to support stax functionality/features.

Version:
$Id: XMLDocumentScannerImpl.java,v 1.1 2006/03/31 03:17:04 jeffsuttor Exp $
Author:
Neeraj Bajaj, Sun Microsystems, K.Venugopal, Sun Microsystems, Glenn Marcy, IBM, Andy Clark, IBM, Arnaud Le Hors, IBM, Eric Ye, IBM

Nested Class Summary
protected  class XMLDocumentScannerImpl.ContentDriver
          Driver to handle content scanning.
protected  class XMLDocumentScannerImpl.DTDDriver
          Driver to handle the internal and external DTD subsets.
protected  class XMLDocumentScannerImpl.PrologDriver
          Driver to handle prolog scanning.
protected  class XMLDocumentScannerImpl.TrailingMiscDriver
          Driver to handle trailing miscellaneous section scanning.
protected  class XMLDocumentScannerImpl.XMLBufferListenerImpl
          Implements XMLBufferListener interface.
protected  class XMLDocumentScannerImpl.XMLDeclDriver
          Driver to handle XMLDecl scanning.
 
Nested classes/interfaces inherited from class com.sun.xml.stream.XMLDocumentFragmentScannerImpl
XMLDocumentFragmentScannerImpl.Driver, XMLDocumentFragmentScannerImpl.Element, XMLDocumentFragmentScannerImpl.ElementStack, XMLDocumentFragmentScannerImpl.ElementStack2, XMLDocumentFragmentScannerImpl.FragmentContentDriver
 
Field Summary
static char[] COMMENTSTRING
           
protected static java.lang.String DISALLOW_DOCTYPE_DECL_FEATURE
          Feature identifier: load external DTD.
static char[] DOCTYPE
           
protected static java.lang.String DTD_SCANNER
          Property identifier: DTD scanner.
protected  boolean fBindNamespaces
           
protected  boolean fDisallowDoctype
          Disallow doctype declaration.
protected  java.lang.String fDoctypeName
          Doctype name.
protected  java.lang.String fDoctypePublicId
          Doctype declaration public identifier.
protected  java.lang.String fDoctypeSystemId
          Doctype declaration system identifier.
protected  org.apache.xerces.util.XMLStringBuffer fDTDDecl
           
protected  XMLDocumentFragmentScannerImpl.Driver fDTDDriver
          DTD driver.
protected  org.apache.xerces.xni.parser.XMLDTDScanner fDTDScanner
          DTD scanner.
protected  boolean fEndOfDocument
           
protected  int fEndPos
           
protected  boolean fLoadExternalDTD
          Load external DTD.
protected  org.apache.xerces.xni.NamespaceContext fNamespaceContext
          Namespace support.
protected  XMLDocumentFragmentScannerImpl.Driver fPrologDriver
          Prolog driver.
protected  boolean fReadingAttributes
           
protected  boolean fReadingDTD
           
protected  boolean fScanEndElement
           
protected  XMLDocumentScannerImpl.XMLBufferListenerImpl fScannerBufferlistener
           
protected  int fScannerLastState
           
protected  boolean fSeenDoctypeDecl
          Seen doctype declaration.
protected  boolean fSeenInternalSubset
           
protected  int fStartPos
           
protected  XMLDocumentFragmentScannerImpl.Driver fTrailingMiscDriver
          Trailing miscellaneous section driver.
protected  XMLDocumentFragmentScannerImpl.Driver fXMLDeclDriver
          XML declaration driver.
protected static java.lang.String LOAD_EXTERNAL_DTD
          Feature identifier: load external DTD.
protected static int SCANNER_STATE_DTD_EXTERNAL
          Scanner state: open DTD external subset.
protected static int SCANNER_STATE_DTD_EXTERNAL_DECLS
          Scanner state: DTD external declarations.
protected static int SCANNER_STATE_DTD_INTERNAL_DECLS
          Scanner state: DTD internal declarations.
protected static int SCANNER_STATE_NO_SUCH_ELEMENT_EXCEPTION
          Scanner state: NO MORE ELEMENTS.
protected static int SCANNER_STATE_PROLOG
          Scanner state: prolog.
protected static int SCANNER_STATE_TRAILING_MISC
          Scanner state: trailing misc.
protected static int SCANNER_STATE_XML_DECL
          Scanner state: XML declaration.
protected static java.lang.String VALIDATION_MANAGER
           
 
Fields inherited from class com.sun.xml.stream.XMLDocumentFragmentScannerImpl
cdata, DEBUG, DEBUG_COALESCE, DEBUG_CONTENT_SCANNING, DEBUG_NEXT, dtdGrammarUtil, endTag, fAdd, fAddDefaultAttr, fAttributeQName, fAttributes, fContentBuffer, fContentDriver, fCurrentElement, fDeclaredEncoding, fDocumentHandler, fDriver, fElementQName, fElementRawname, fElementStack, fElementStack2, fEmptyElement, fEntityStack, fEntityStore, fHasExternalDTD, fInScanContent, fIsCoalesce, fLastSectionWasCData, fLastSectionWasCharacterData, fLastSectionWasEntityReference, fMarkupDepth, fNamespaces, fNotifyBuiltInRefs, foundBuiltInRefs, fPIData, fPITarget, fReplaceEntityReferences, fReportCdataEvent, fScannerState, fScanToEnd, fShouldSkip, fSkip, fStandalone, fStringBuffer, fStringBuffer2, fSupportExternalEntities, fTempString, fTempString2, fVersion, NAMESPACES, NOTIFY_BUILTIN_REFS, SCANNER_STATE_ATTRIBUTE, SCANNER_STATE_ATTRIBUTE_VALUE, SCANNER_STATE_BUILT_IN_REFS, SCANNER_STATE_CDATA, SCANNER_STATE_CHAR_REFERENCE, SCANNER_STATE_CHARACTER_DATA, SCANNER_STATE_COMMENT, SCANNER_STATE_CONTENT, SCANNER_STATE_DOCTYPE, SCANNER_STATE_END_ELEMENT_TAG, SCANNER_STATE_END_OF_INPUT, SCANNER_STATE_PI, SCANNER_STATE_REFERENCE, SCANNER_STATE_ROOT_ELEMENT, SCANNER_STATE_START_ELEMENT_TAG, SCANNER_STATE_START_OF_MARKUP, SCANNER_STATE_TERMINATED, SCANNER_STATE_TEXT_DECL, xmlDecl
 
Fields inherited from class com.sun.xml.stream.XMLScanner
attributeValueCache, DEBUG_ATTR_NORMALIZATION, ENTITY_MANAGER, ERROR_REPORTER, fAmpSymbol, fAposSymbol, fAttributeCacheInitDone, fAttributeCacheUsedCount, fCharRefLiteral, fEncodingSymbol, fEntityDepth, fEntityManager, fEntityScanner, fErrorReporter, fEvent, fGtSymbol, fLtSymbol, fNotifyCharRefs, fPropertyManager, fQuotSymbol, fReportEntity, fResourceIdentifier, fScanningAttribute, fStandaloneSymbol, fStringBufferIndex, fSymbolTable, fValidation, fVersionSymbol, NOTIFY_CHAR_REFS, stringBufferCache, SYMBOL_TABLE, VALIDATION
 
Constructor Summary
XMLDocumentScannerImpl()
          Default constructor.
 
Method Summary
protected  XMLDocumentFragmentScannerImpl.Driver createContentDriver()
          Creates a content driver.
 void endEntity(java.lang.String name)
          This method notifies the end of an entity.
 java.lang.Boolean getFeatureDefault(java.lang.String featureId)
          Returns the default state for a feature, or null if this component does not want to report a default value for this feature.
 java.lang.Object getPropertyDefault(java.lang.String propertyId)
          Returns the default state for a property, or null if this component does not want to report a default value for this property.
 java.lang.String[] getRecognizedFeatures()
          Returns a list of feature identifiers that are recognized by this component.
 java.lang.String[] getRecognizedProperties()
          Returns a list of property identifiers that are recognized by this component.
protected  java.lang.String getScannerStateName(int state)
          Returns the scanner state name.
 int getScannetState()
          return the state of the scanner
 int next()
          return the next state on the input
 void reset(PropertyManager propertyManager)
           
 void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
          Resets the component.
protected  boolean scanDoctypeDecl()
          Scans a doctype declaration.
 void setFeature(java.lang.String featureId, boolean state)
          Sets the state of a feature.
 void setInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)
          Sets the input source.
 void setProperty(java.lang.String propertyId, java.lang.Object value)
          Sets the value of a property.
 void startEntity(java.lang.String name, org.apache.xerces.xni.XMLResourceIdentifier identifier, java.lang.String encoding)
          This method notifies of the start of an entity.
 
Methods inherited from class com.sun.xml.stream.XMLDocumentFragmentScannerImpl
getAttributeIterator, getCharacterData, getComment, getDocumentHandler, getDriverName, getEntityName, getPIData, getPITarget, hasAttributes, isStandAlone, scanAttribute, scanCDATASection, scanCharReference, scanComment, scanContent, scanDocument, scanEndElement, scanEntityReference, scanPIData, scanStartElement, scanXMLDeclOrTextDecl, setDocumentHandler, setDriver, setScannerState, skipElement
 
Methods inherited from class com.sun.xml.stream.XMLScanner
getFeature, isInvalid, isInvalidLiteral, isValidNameChar, isValidNameStartChar, isValidNCName, normalizeWhitespace, reportFatalError, scanAttributeValue, scanCharReferenceValue, scanComment, scanExternalID, scanPI, scanPseudoAttribute, scanPubidLiteral, scanSurrogates, scanXMLDeclOrTextDecl, setPropertyManager, versionSupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCANNER_STATE_XML_DECL

protected static final int SCANNER_STATE_XML_DECL
Scanner state: XML declaration.

See Also:
Constant Field Values

SCANNER_STATE_PROLOG

protected static final int SCANNER_STATE_PROLOG
Scanner state: prolog.

See Also:
Constant Field Values

SCANNER_STATE_TRAILING_MISC

protected static final int SCANNER_STATE_TRAILING_MISC
Scanner state: trailing misc.

See Also:
Constant Field Values

SCANNER_STATE_DTD_INTERNAL_DECLS

protected static final int SCANNER_STATE_DTD_INTERNAL_DECLS
Scanner state: DTD internal declarations.

See Also:
Constant Field Values

SCANNER_STATE_DTD_EXTERNAL

protected static final int SCANNER_STATE_DTD_EXTERNAL
Scanner state: open DTD external subset.

See Also:
Constant Field Values

SCANNER_STATE_DTD_EXTERNAL_DECLS

protected static final int SCANNER_STATE_DTD_EXTERNAL_DECLS
Scanner state: DTD external declarations.

See Also:
Constant Field Values

SCANNER_STATE_NO_SUCH_ELEMENT_EXCEPTION

protected static final int SCANNER_STATE_NO_SUCH_ELEMENT_EXCEPTION
Scanner state: NO MORE ELEMENTS.

See Also:
Constant Field Values

LOAD_EXTERNAL_DTD

protected static final java.lang.String LOAD_EXTERNAL_DTD
Feature identifier: load external DTD.

See Also:
Constant Field Values

DISALLOW_DOCTYPE_DECL_FEATURE

protected static final java.lang.String DISALLOW_DOCTYPE_DECL_FEATURE
Feature identifier: load external DTD.

See Also:
Constant Field Values

DTD_SCANNER

protected static final java.lang.String DTD_SCANNER
Property identifier: DTD scanner.

See Also:
Constant Field Values

VALIDATION_MANAGER

protected static final java.lang.String VALIDATION_MANAGER
See Also:
Constant Field Values

fDTDScanner

protected org.apache.xerces.xni.parser.XMLDTDScanner fDTDScanner
DTD scanner.


fDTDDecl

protected org.apache.xerces.util.XMLStringBuffer fDTDDecl

fReadingDTD

protected boolean fReadingDTD

fEndOfDocument

protected boolean fEndOfDocument

fDoctypeName

protected java.lang.String fDoctypeName
Doctype name.


fDoctypePublicId

protected java.lang.String fDoctypePublicId
Doctype declaration public identifier.


fDoctypeSystemId

protected java.lang.String fDoctypeSystemId
Doctype declaration system identifier.


fNamespaceContext

protected org.apache.xerces.xni.NamespaceContext fNamespaceContext
Namespace support.


fLoadExternalDTD

protected boolean fLoadExternalDTD
Load external DTD.


fDisallowDoctype

protected boolean fDisallowDoctype
Disallow doctype declaration.


fSeenDoctypeDecl

protected boolean fSeenDoctypeDecl
Seen doctype declaration.


fBindNamespaces

protected boolean fBindNamespaces

fScanEndElement

protected boolean fScanEndElement

fScannerLastState

protected int fScannerLastState

fXMLDeclDriver

protected XMLDocumentFragmentScannerImpl.Driver fXMLDeclDriver
XML declaration driver.


fPrologDriver

protected XMLDocumentFragmentScannerImpl.Driver fPrologDriver
Prolog driver.


fDTDDriver

protected XMLDocumentFragmentScannerImpl.Driver fDTDDriver
DTD driver.


fTrailingMiscDriver

protected XMLDocumentFragmentScannerImpl.Driver fTrailingMiscDriver
Trailing miscellaneous section driver.


fStartPos

protected int fStartPos

fEndPos

protected int fEndPos

fSeenInternalSubset

protected boolean fSeenInternalSubset

DOCTYPE

public static final char[] DOCTYPE

COMMENTSTRING

public static final char[] COMMENTSTRING

fReadingAttributes

protected boolean fReadingAttributes

fScannerBufferlistener

protected XMLDocumentScannerImpl.XMLBufferListenerImpl fScannerBufferlistener
Constructor Detail

XMLDocumentScannerImpl

public XMLDocumentScannerImpl()
Default constructor.

Method Detail

setInputSource

public void setInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)
                    throws java.io.IOException
Sets the input source.

Specified by:
setInputSource in interface org.apache.xerces.xni.parser.XMLDocumentScanner
Overrides:
setInputSource in class XMLDocumentFragmentScannerImpl
Parameters:
inputSource - The input source.
Throws:
java.io.IOException - Thrown on i/o error.

reset

public void reset(PropertyManager propertyManager)
Overrides:
reset in class XMLDocumentFragmentScannerImpl

getScannetState

public int getScannetState()
return the state of the scanner


next

public int next()
         throws java.io.IOException,
                org.apache.xerces.xni.XNIException
return the next state on the input

Specified by:
next in interface org.apache.xerces.xni.parser.XMLDocumentScanner
Overrides:
next in class XMLDocumentFragmentScannerImpl
Returns:
int
Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

reset

public void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
           throws org.apache.xerces.xni.parser.XMLConfigurationException
Resets the component. The component can query the component manager about any features and properties that affect the operation of the component.

Specified by:
reset in interface org.apache.xerces.xni.parser.XMLComponent
Overrides:
reset in class XMLDocumentFragmentScannerImpl
Parameters:
componentManager - The component manager.
Throws:
SAXException - Thrown by component on initialization error. For example, if a feature or property is required for the operation of the component, the component manager may throw a SAXNotRecognizedException or a SAXNotSupportedException.
org.apache.xerces.xni.parser.XMLConfigurationException

getRecognizedFeatures

public java.lang.String[] getRecognizedFeatures()
Returns a list of feature identifiers that are recognized by this component. This method may return null if no features are recognized by this component.

Specified by:
getRecognizedFeatures in interface org.apache.xerces.xni.parser.XMLComponent
Overrides:
getRecognizedFeatures in class XMLDocumentFragmentScannerImpl

setFeature

public void setFeature(java.lang.String featureId,
                       boolean state)
                throws org.apache.xerces.xni.parser.XMLConfigurationException
Sets the state of a feature. This method is called by the component manager any time after reset when a feature changes state.

Note: Components should silently ignore features that do not affect the operation of the component.

Specified by:
setFeature in interface org.apache.xerces.xni.parser.XMLComponent
Overrides:
setFeature in class XMLDocumentFragmentScannerImpl
Parameters:
featureId - The feature identifier.
state - The state of the feature.
Throws:
SAXNotRecognizedException - The component should not throw this exception.
SAXNotSupportedException - The component should not throw this exception.
org.apache.xerces.xni.parser.XMLConfigurationException - Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.

getRecognizedProperties

public java.lang.String[] getRecognizedProperties()
Returns a list of property identifiers that are recognized by this component. This method may return null if no properties are recognized by this component.

Specified by:
getRecognizedProperties in interface org.apache.xerces.xni.parser.XMLComponent
Overrides:
getRecognizedProperties in class XMLDocumentFragmentScannerImpl

setProperty

public void setProperty(java.lang.String propertyId,
                        java.lang.Object value)
                 throws org.apache.xerces.xni.parser.XMLConfigurationException
Sets the value of a property. This method is called by the component manager any time after reset when a property changes value.

Note: Components should silently ignore properties that do not affect the operation of the component.

Specified by:
setProperty in interface org.apache.xerces.xni.parser.XMLComponent
Overrides:
setProperty in class XMLDocumentFragmentScannerImpl
Parameters:
propertyId - The property identifier.
value - The value of the property.
Throws:
SAXNotRecognizedException - The component should not throw this exception.
SAXNotSupportedException - The component should not throw this exception.
org.apache.xerces.xni.parser.XMLConfigurationException - Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.

getFeatureDefault

public java.lang.Boolean getFeatureDefault(java.lang.String featureId)
Returns the default state for a feature, or null if this component does not want to report a default value for this feature.

Specified by:
getFeatureDefault in interface org.apache.xerces.xni.parser.XMLComponent
Overrides:
getFeatureDefault in class XMLDocumentFragmentScannerImpl
Parameters:
featureId - The feature identifier.
Since:
Xerces 2.2.0

getPropertyDefault

public java.lang.Object getPropertyDefault(java.lang.String propertyId)
Returns the default state for a property, or null if this component does not want to report a default value for this property.

Specified by:
getPropertyDefault in interface org.apache.xerces.xni.parser.XMLComponent
Overrides:
getPropertyDefault in class XMLDocumentFragmentScannerImpl
Parameters:
propertyId - The property identifier.
Since:
Xerces 2.2.0

startEntity

public void startEntity(java.lang.String name,
                        org.apache.xerces.xni.XMLResourceIdentifier identifier,
                        java.lang.String encoding)
                 throws org.apache.xerces.xni.XNIException
This method notifies of the start of an entity. The DTD has the pseudo-name of "[dtd]" parameter entity names start with '%'; and general entities are just specified by their name.

Specified by:
startEntity in interface XMLEntityHandler
Overrides:
startEntity in class XMLDocumentFragmentScannerImpl
Parameters:
name - The name of the entity.
identifier - The resource identifier.
encoding - The auto-detected IANA encoding name of the entity stream. This value will be null in those situations where the entity encoding is not auto-detected (e.g. internal entities or a document entity that is parsed from a java.io.Reader).
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

endEntity

public void endEntity(java.lang.String name)
               throws java.io.IOException,
                      org.apache.xerces.xni.XNIException
This method notifies the end of an entity. The DTD has the pseudo-name of "[dtd]" parameter entity names start with '%'; and general entities are just specified by their name.

Specified by:
endEntity in interface XMLEntityHandler
Overrides:
endEntity in class XMLDocumentFragmentScannerImpl
Parameters:
name - The name of the entity.
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.
java.io.IOException

createContentDriver

protected XMLDocumentFragmentScannerImpl.Driver createContentDriver()
Creates a content driver.

Overrides:
createContentDriver in class XMLDocumentFragmentScannerImpl

scanDoctypeDecl

protected boolean scanDoctypeDecl()
                           throws java.io.IOException,
                                  org.apache.xerces.xni.XNIException
Scans a doctype declaration.

Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

getScannerStateName

protected java.lang.String getScannerStateName(int state)
Returns the scanner state name.

Overrides:
getScannerStateName in class XMLDocumentFragmentScannerImpl


Copyright ? 2002-2003 Apache XML Project. All Rights Reserved.