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 AttributeCollectormAttrCollectorprotected intmAttrCountNumber of attributes accessible viaAttributesandAttributes2interfaces, for the current start element.protected ReaderConfigmConfigprotected ContentHandlermContentHandlerprotected DTDHandlermDTDHandlerprotected InputElementStackmElemStackprotected StringmEncodingprotected booleanmFeatNsPrefixesprotected intmNsCountNeed to keep track of number of namespaces, if namespace declarations are to be reported along with attributes (seemFeatNsPrefixes).protected BasicStreamReadermScannerSince 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 booleanmStandaloneprotected WstxInputFactorymStaxFactoryWe will need the factory reference mostly for constructing underlying stream reader we use.protected StringmXmlVersion
-
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
-
mAttrCount
protected int mAttrCount
Number of attributes accessible viaAttributesandAttributes2interfaces, 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:
getXMLReaderin 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:
isNamespaceAwarein classSAXParser
-
isValidating
public boolean isValidating()
- Specified by:
isValidatingin classSAXParser
-
getProperty
public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException
- Specified by:
getPropertyin interfaceXMLReader- Specified by:
getPropertyin classSAXParser- Throws:
SAXNotRecognizedExceptionSAXNotSupportedException
-
setProperty
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
- Specified by:
setPropertyin interfaceXMLReader- Specified by:
setPropertyin classSAXParser- Throws:
SAXNotRecognizedExceptionSAXNotSupportedException
-
parse
public void parse(InputSource is, HandlerBase hb) throws SAXException, IOException
- Overrides:
parsein classSAXParser- Throws:
SAXExceptionIOException
-
parse
public void parse(InputSource is, DefaultHandler dh) throws SAXException, IOException
- Overrides:
parsein classSAXParser- Throws:
SAXExceptionIOException
-
getContentHandler
public ContentHandler getContentHandler()
- Specified by:
getContentHandlerin interfaceXMLReader
-
getDTDHandler
public DTDHandler getDTDHandler()
- Specified by:
getDTDHandlerin interfaceXMLReader
-
getEntityResolver
public EntityResolver getEntityResolver()
- Specified by:
getEntityResolverin interfaceXMLReader
-
getErrorHandler
public ErrorHandler getErrorHandler()
- Specified by:
getErrorHandlerin interfaceXMLReader
-
getFeature
public boolean getFeature(String name) throws SAXNotRecognizedException
- Specified by:
getFeaturein interfaceXMLReader- Throws:
SAXNotRecognizedException
-
setContentHandler
public void setContentHandler(ContentHandler handler)
- Specified by:
setContentHandlerin interfaceXMLReader
-
setDTDHandler
public void setDTDHandler(DTDHandler handler)
- Specified by:
setDTDHandlerin interfaceParser- Specified by:
setDTDHandlerin interfaceXMLReader
-
setEntityResolver
public void setEntityResolver(EntityResolver resolver)
- Specified by:
setEntityResolverin interfaceParser- Specified by:
setEntityResolverin interfaceXMLReader
-
setErrorHandler
public void setErrorHandler(ErrorHandler handler)
- Specified by:
setErrorHandlerin interfaceParser- Specified by:
setErrorHandlerin interfaceXMLReader
-
setFeature
public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException
- Specified by:
setFeaturein interfaceXMLReader- Throws:
SAXNotRecognizedExceptionSAXNotSupportedException
-
parse
public void parse(InputSource input) throws SAXException
- Specified by:
parsein interfaceParser- Specified by:
parsein interfaceXMLReader- Throws:
SAXException
-
parse
public void parse(String systemId) throws SAXException
- Specified by:
parsein interfaceParser- Specified by:
parsein interfaceXMLReader- Throws:
SAXException
-
setDocumentHandler
public void setDocumentHandler(DocumentHandler handler)
- Specified by:
setDocumentHandlerin interfaceParser
-
getIndex
public int getIndex(String qName)
- Specified by:
getIndexin interfaceAttributes
-
getIndex
public int getIndex(String uri, String localName)
- Specified by:
getIndexin interfaceAttributes
-
getLength
public int getLength()
- Specified by:
getLengthin interfaceAttributes
-
getLocalName
public String getLocalName(int index)
- Specified by:
getLocalNamein interfaceAttributes
-
getQName
public String getQName(int index)
- Specified by:
getQNamein interfaceAttributes
-
getType
public String getType(int index)
- Specified by:
getTypein interfaceAttributes
-
getType
public String getType(String qName)
- Specified by:
getTypein interfaceAttributes
-
getType
public String getType(String uri, String localName)
- Specified by:
getTypein interfaceAttributes
-
getURI
public String getURI(int index)
- Specified by:
getURIin interfaceAttributes
-
getValue
public String getValue(int index)
- Specified by:
getValuein interfaceAttributes
-
getValue
public String getValue(String qName)
- Specified by:
getValuein interfaceAttributes
-
getValue
public String getValue(String uri, String localName)
- Specified by:
getValuein interfaceAttributes
-
isDeclared
public boolean isDeclared(int index)
- Specified by:
isDeclaredin interfaceAttributes2
-
isDeclared
public boolean isDeclared(String qName)
- Specified by:
isDeclaredin interfaceAttributes2
-
isDeclared
public boolean isDeclared(String uri, String localName)
- Specified by:
isDeclaredin interfaceAttributes2
-
isSpecified
public boolean isSpecified(int index)
- Specified by:
isSpecifiedin interfaceAttributes2
-
isSpecified
public boolean isSpecified(String qName)
- Specified by:
isSpecifiedin interfaceAttributes2
-
isSpecified
public boolean isSpecified(String uri, String localName)
- Specified by:
isSpecifiedin interfaceAttributes2
-
getColumnNumber
public int getColumnNumber()
- Specified by:
getColumnNumberin interfaceLocator
-
getLineNumber
public int getLineNumber()
- Specified by:
getLineNumberin interfaceLocator
-
getPublicId
public String getPublicId()
- Specified by:
getPublicIdin interfaceLocator
-
getSystemId
public String getSystemId()
- Specified by:
getSystemIdin interfaceLocator
-
getEncoding
public String getEncoding()
- Specified by:
getEncodingin interfaceLocator2
-
getXMLVersion
public String getXMLVersion()
- Specified by:
getXMLVersionin interfaceLocator2
-
dtdReportComments
public boolean dtdReportComments()
- Specified by:
dtdReportCommentsin 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:
dtdCommentin interfaceDTDEventListener
-
dtdProcessingInstruction
public void dtdProcessingInstruction(String target, String data)
- Specified by:
dtdProcessingInstructionin interfaceDTDEventListener
-
dtdSkippedEntity
public void dtdSkippedEntity(String name)
- Specified by:
dtdSkippedEntityin interfaceDTDEventListener
-
dtdNotationDecl
public void dtdNotationDecl(String name, String publicId, String systemId, URL baseURL) throws XMLStreamException
- Specified by:
dtdNotationDeclin interfaceDTDEventListener- Throws:
XMLStreamException
-
dtdUnparsedEntityDecl
public void dtdUnparsedEntityDecl(String name, String publicId, String systemId, String notationName, URL baseURL) throws XMLStreamException
- Specified by:
dtdUnparsedEntityDeclin interfaceDTDEventListener- Throws:
XMLStreamException
-
attributeDecl
public void attributeDecl(String eName, String aName, String type, String mode, String value)
- Specified by:
attributeDeclin interfaceDTDEventListener
-
dtdElementDecl
public void dtdElementDecl(String name, String model)
- Specified by:
dtdElementDeclin interfaceDTDEventListener
-
dtdExternalEntityDecl
public void dtdExternalEntityDecl(String name, String publicId, String systemId)
- Specified by:
dtdExternalEntityDeclin interfaceDTDEventListener
-
dtdInternalEntityDecl
public void dtdInternalEntityDecl(String name, String value)
- Specified by:
dtdInternalEntityDeclin interfaceDTDEventListener
-
-