Package com.ctc.wstx.sax
Class WstxSAXParser
- java.lang.Object
-
- javax.xml.parsers.SAXParser
-
- com.ctc.wstx.sax.WstxSAXParser
-
- All Implemented Interfaces:
DTDEventListener
,Attributes
,Attributes2
,Locator2
,Locator
,Parser
,XMLReader
public class WstxSAXParser extends SAXParser implements Parser, XMLReader, Attributes2, Locator2, DTDEventListener
This class implements parser part of JAXP and SAX interfaces; and effectively offers an alternative to using Stax input factory / stream reader combination.
-
-
Field Summary
Fields Modifier and Type Field Description protected AttributeCollector
mAttrCollector
protected int
mAttrCount
Number of attributes accessible viaAttributes
andAttributes2
interfaces, for the current start element.protected ReaderConfig
mConfig
protected ContentHandler
mContentHandler
protected DeclHandler
mDeclHandler
protected DTDHandler
mDTDHandler
protected InputElementStack
mElemStack
protected String
mEncoding
protected EntityResolver
mEntityResolver
protected ErrorHandler
mErrorHandler
protected boolean
mFeatNsPrefixes
protected LexicalHandler
mLexicalHandler
protected int
mNsCount
Need to keep track of number of namespaces, if namespace declarations are to be reported along with attributes (seemFeatNsPrefixes
).protected BasicStreamReader
mScanner
Since the stream reader would mostly be just a wrapper around the underlying scanner (its main job is to implement Stax interface), we can and should just use the scanner.protected boolean
mStandalone
protected WstxInputFactory
mStaxFactory
We will need the factory reference mostly for constructing underlying stream reader we use.protected String
mXmlVersion
-
Constructor Summary
Constructors Constructor Description WstxSAXParser()
WstxSAXParser(WstxInputFactory sf, boolean nsPrefixes)
NOTE: this was a protected constructor for versions 4.0 and 3.2; changed to public in 4.1
-
Method Summary
-
-
-
Field Detail
-
mStaxFactory
protected final WstxInputFactory mStaxFactory
We will need the factory reference mostly for constructing underlying stream reader we use.
-
mConfig
protected final ReaderConfig mConfig
-
mFeatNsPrefixes
protected boolean mFeatNsPrefixes
-
mScanner
protected BasicStreamReader mScanner
Since the stream reader would mostly be just a wrapper around the underlying scanner (its main job is to implement Stax interface), we can and should just use the scanner. In effect, this class is then a replacement of BasicStreamReader, when using SAX interfaces.
-
mAttrCollector
protected AttributeCollector mAttrCollector
-
mElemStack
protected InputElementStack mElemStack
-
mEncoding
protected String mEncoding
-
mXmlVersion
protected String mXmlVersion
-
mStandalone
protected boolean mStandalone
-
mContentHandler
protected ContentHandler mContentHandler
-
mDTDHandler
protected DTDHandler mDTDHandler
-
mEntityResolver
protected EntityResolver mEntityResolver
-
mErrorHandler
protected ErrorHandler mErrorHandler
-
mLexicalHandler
protected LexicalHandler mLexicalHandler
-
mDeclHandler
protected DeclHandler mDeclHandler
-
mAttrCount
protected int mAttrCount
Number of attributes accessible viaAttributes
andAttributes2
interfaces, for the current start element.Note: does not include namespace declarations, even they are to be reported as attributes.
-
mNsCount
protected int mNsCount
Need to keep track of number of namespaces, if namespace declarations are to be reported along with attributes (seemFeatNsPrefixes
).
-
-
Constructor Detail
-
WstxSAXParser
public WstxSAXParser(WstxInputFactory sf, boolean nsPrefixes)
NOTE: this was a protected constructor for versions 4.0 and 3.2; changed to public in 4.1
-
WstxSAXParser
public WstxSAXParser()
-
-
Method Detail
-
getXMLReader
public final XMLReader getXMLReader()
- Specified by:
getXMLReader
in classSAXParser
-
getStaxConfig
public final ReaderConfig getStaxConfig()
Accessor used to allow configuring all standard Stax configuration settings that the underlying reader uses.- Since:
- 4.0.8
-
isNamespaceAware
public boolean isNamespaceAware()
- Specified by:
isNamespaceAware
in classSAXParser
-
isValidating
public boolean isValidating()
- Specified by:
isValidating
in classSAXParser
-
getProperty
public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException
- Specified by:
getProperty
in interfaceXMLReader
- Specified by:
getProperty
in classSAXParser
- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
setProperty
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
- Specified by:
setProperty
in interfaceXMLReader
- Specified by:
setProperty
in classSAXParser
- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
parse
public void parse(InputSource is, HandlerBase hb) throws SAXException, IOException
- Overrides:
parse
in classSAXParser
- Throws:
SAXException
IOException
-
parse
public void parse(InputSource is, DefaultHandler dh) throws SAXException, IOException
- Overrides:
parse
in classSAXParser
- Throws:
SAXException
IOException
-
getContentHandler
public ContentHandler getContentHandler()
- Specified by:
getContentHandler
in interfaceXMLReader
-
getDTDHandler
public DTDHandler getDTDHandler()
- Specified by:
getDTDHandler
in interfaceXMLReader
-
getEntityResolver
public EntityResolver getEntityResolver()
- Specified by:
getEntityResolver
in interfaceXMLReader
-
getErrorHandler
public ErrorHandler getErrorHandler()
- Specified by:
getErrorHandler
in interfaceXMLReader
-
getFeature
public boolean getFeature(String name) throws SAXNotRecognizedException
- Specified by:
getFeature
in interfaceXMLReader
- Throws:
SAXNotRecognizedException
-
setContentHandler
public void setContentHandler(ContentHandler handler)
- Specified by:
setContentHandler
in interfaceXMLReader
-
setDTDHandler
public void setDTDHandler(DTDHandler handler)
- Specified by:
setDTDHandler
in interfaceParser
- Specified by:
setDTDHandler
in interfaceXMLReader
-
setEntityResolver
public void setEntityResolver(EntityResolver resolver)
- Specified by:
setEntityResolver
in interfaceParser
- Specified by:
setEntityResolver
in interfaceXMLReader
-
setErrorHandler
public void setErrorHandler(ErrorHandler handler)
- Specified by:
setErrorHandler
in interfaceParser
- Specified by:
setErrorHandler
in interfaceXMLReader
-
setFeature
public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException
- Specified by:
setFeature
in interfaceXMLReader
- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
parse
public void parse(InputSource input) throws SAXException
- Specified by:
parse
in interfaceParser
- Specified by:
parse
in interfaceXMLReader
- Throws:
SAXException
-
parse
public void parse(String systemId) throws SAXException
- Specified by:
parse
in interfaceParser
- Specified by:
parse
in interfaceXMLReader
- Throws:
SAXException
-
setDocumentHandler
public void setDocumentHandler(DocumentHandler handler)
- Specified by:
setDocumentHandler
in interfaceParser
-
getIndex
public int getIndex(String qName)
- Specified by:
getIndex
in interfaceAttributes
-
getIndex
public int getIndex(String uri, String localName)
- Specified by:
getIndex
in interfaceAttributes
-
getLength
public int getLength()
- Specified by:
getLength
in interfaceAttributes
-
getLocalName
public String getLocalName(int index)
- Specified by:
getLocalName
in interfaceAttributes
-
getQName
public String getQName(int index)
- Specified by:
getQName
in interfaceAttributes
-
getType
public String getType(int index)
- Specified by:
getType
in interfaceAttributes
-
getType
public String getType(String qName)
- Specified by:
getType
in interfaceAttributes
-
getType
public String getType(String uri, String localName)
- Specified by:
getType
in interfaceAttributes
-
getURI
public String getURI(int index)
- Specified by:
getURI
in interfaceAttributes
-
getValue
public String getValue(int index)
- Specified by:
getValue
in interfaceAttributes
-
getValue
public String getValue(String qName)
- Specified by:
getValue
in interfaceAttributes
-
getValue
public String getValue(String uri, String localName)
- Specified by:
getValue
in interfaceAttributes
-
isDeclared
public boolean isDeclared(int index)
- Specified by:
isDeclared
in interfaceAttributes2
-
isDeclared
public boolean isDeclared(String qName)
- Specified by:
isDeclared
in interfaceAttributes2
-
isDeclared
public boolean isDeclared(String uri, String localName)
- Specified by:
isDeclared
in interfaceAttributes2
-
isSpecified
public boolean isSpecified(int index)
- Specified by:
isSpecified
in interfaceAttributes2
-
isSpecified
public boolean isSpecified(String qName)
- Specified by:
isSpecified
in interfaceAttributes2
-
isSpecified
public boolean isSpecified(String uri, String localName)
- Specified by:
isSpecified
in interfaceAttributes2
-
getColumnNumber
public int getColumnNumber()
- Specified by:
getColumnNumber
in interfaceLocator
-
getLineNumber
public int getLineNumber()
- Specified by:
getLineNumber
in interfaceLocator
-
getPublicId
public String getPublicId()
- Specified by:
getPublicId
in interfaceLocator
-
getSystemId
public String getSystemId()
- Specified by:
getSystemId
in interfaceLocator
-
getEncoding
public String getEncoding()
- Specified by:
getEncoding
in interfaceLocator2
-
getXMLVersion
public String getXMLVersion()
- Specified by:
getXMLVersion
in interfaceLocator2
-
dtdReportComments
public boolean dtdReportComments()
- Specified by:
dtdReportComments
in interfaceDTDEventListener
- Returns:
- True, if there is a listener interested in getting comment events within DTD subset (since that's optional)
-
dtdComment
public void dtdComment(char[] data, int offset, int len)
- Specified by:
dtdComment
in interfaceDTDEventListener
-
dtdProcessingInstruction
public void dtdProcessingInstruction(String target, String data)
- Specified by:
dtdProcessingInstruction
in interfaceDTDEventListener
-
dtdSkippedEntity
public void dtdSkippedEntity(String name)
- Specified by:
dtdSkippedEntity
in interfaceDTDEventListener
-
dtdNotationDecl
public void dtdNotationDecl(String name, String publicId, String systemId, URL baseURL) throws XMLStreamException
- Specified by:
dtdNotationDecl
in interfaceDTDEventListener
- Throws:
XMLStreamException
-
dtdUnparsedEntityDecl
public void dtdUnparsedEntityDecl(String name, String publicId, String systemId, String notationName, URL baseURL) throws XMLStreamException
- Specified by:
dtdUnparsedEntityDecl
in interfaceDTDEventListener
- Throws:
XMLStreamException
-
attributeDecl
public void attributeDecl(String eName, String aName, String type, String mode, String value)
- Specified by:
attributeDecl
in interfaceDTDEventListener
-
dtdElementDecl
public void dtdElementDecl(String name, String model)
- Specified by:
dtdElementDecl
in interfaceDTDEventListener
-
dtdExternalEntityDecl
public void dtdExternalEntityDecl(String name, String publicId, String systemId)
- Specified by:
dtdExternalEntityDecl
in interfaceDTDEventListener
-
dtdInternalEntityDecl
public void dtdInternalEntityDecl(String name, String value)
- Specified by:
dtdInternalEntityDecl
in interfaceDTDEventListener
-
-