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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class(package private) static final class(package private) final classSimple helper class that converts from Stax API into SAX EntityResolver call(s) -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final booleanprotected AttributeCollectorprotected intNumber of attributes accessible viaAttributesandAttributes2interfaces, for the current start element.protected final ReaderConfigprotected ContentHandlerprotected DeclHandlerprotected DTDHandlerprotected InputElementStackprotected Stringprotected EntityResolverprotected ErrorHandlerprotected booleanprotected LexicalHandlerprotected intNeed to keep track of number of namespaces, if namespace declarations are to be reported along with attributes (seemFeatNsPrefixes).protected BasicStreamReaderSince 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 booleanprotected final WstxInputFactoryWe will need the factory reference mostly for constructing underlying stream reader we use.protected String -
Constructor Summary
ConstructorsConstructorDescriptionWstxSAXParser(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
Modifier and TypeMethodDescriptionvoidvoiddtdComment(char[] data, int offset, int len) voiddtdElementDecl(String name, String model) voiddtdExternalEntityDecl(String name, String publicId, String systemId) voiddtdInternalEntityDecl(String name, String value) voiddtdNotationDecl(String name, String publicId, String systemId, URL baseURL) voiddtdProcessingInstruction(String target, String data) booleanvoiddtdSkippedEntity(String name) voiddtdUnparsedEntityDecl(String name, String publicId, String systemId, String notationName, URL baseURL) private final voidfireAuxEvent(int type, boolean inTree) private final voidThis is the actual "tight event loop" that will send all events between start and end document events.private final voidintbooleangetFeature(String name) intintintintgetLocalName(int index) final ParsergetProperty(String name) getQName(int index) final ReaderConfigAccessor used to allow configuring all standard Stax configuration settings that the underlying reader uses.getType(int index) getURI(int index) getValue(int index) final XMLReaderbooleanisDeclared(int index) booleanisDeclared(String qName) booleanisDeclared(String uri, String localName) booleanbooleanisSpecified(int index) booleanisSpecified(String qName) booleanisSpecified(String uri, String localName) booleanvoidvoidparse(InputSource input) voidparse(InputSource is, HandlerBase hb) voidparse(InputSource is, DefaultHandler dh) voidsetContentHandler(ContentHandler handler) voidsetDocumentHandler(DocumentHandler handler) voidsetDTDHandler(DTDHandler handler) voidsetEntityResolver(EntityResolver resolver) voidsetErrorHandler(ErrorHandler handler) voidsetFeature(String name, boolean value) voidvoidsetProperty(String name, Object value) private voidthrowNoSuchAttribute(int index) private voidprivate voidthrowSaxException(String msg)
-
Field Details
-
FEAT_DEFAULT_NS_PREFIXES
static final boolean FEAT_DEFAULT_NS_PREFIXES- See Also:
-
mStaxFactory
We will need the factory reference mostly for constructing underlying stream reader we use. -
mConfig
-
mFeatNsPrefixes
protected boolean mFeatNsPrefixes -
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
-
mElemStack
-
mEncoding
-
mXmlVersion
-
mStandalone
protected boolean mStandalone -
mContentHandler
-
mDTDHandler
-
mEntityResolver
-
mErrorHandler
-
mLexicalHandler
-
mDeclHandler
-
mAttrCount
protected int mAttrCountNumber 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 mNsCountNeed to keep track of number of namespaces, if namespace declarations are to be reported along with attributes (seemFeatNsPrefixes).
-
-
Constructor Details
-
WstxSAXParser
NOTE: this was a protected constructor for versions 4.0 and 3.2; changed to public in 4.1
-
WstxSAXParser
public WstxSAXParser()
-
-
Method Details
-
getParser
-
getXMLReader
- Specified by:
getXMLReaderin classSAXParser
-
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
- 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
- Overrides:
parsein classSAXParser- Throws:
SAXExceptionIOException
-
parse
- Overrides:
parsein classSAXParser- Throws:
SAXExceptionIOException
-
getContentHandler
- Specified by:
getContentHandlerin interfaceXMLReader
-
getDTDHandler
- Specified by:
getDTDHandlerin interfaceXMLReader
-
getEntityResolver
- Specified by:
getEntityResolverin interfaceXMLReader
-
getErrorHandler
- Specified by:
getErrorHandlerin interfaceXMLReader
-
getFeature
- Specified by:
getFeaturein interfaceXMLReader- Throws:
SAXNotRecognizedException
-
setContentHandler
- Specified by:
setContentHandlerin interfaceXMLReader
-
setDTDHandler
- Specified by:
setDTDHandlerin interfaceParser- Specified by:
setDTDHandlerin interfaceXMLReader
-
setEntityResolver
- Specified by:
setEntityResolverin interfaceParser- Specified by:
setEntityResolverin interfaceXMLReader
-
setErrorHandler
- 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
- Specified by:
parsein interfaceParser- Specified by:
parsein interfaceXMLReader- Throws:
SAXException
-
parse
- Specified by:
parsein interfaceParser- Specified by:
parsein interfaceXMLReader- Throws:
SAXException
-
fireEvents
This is the actual "tight event loop" that will send all events between start and end document events. Although we could use the stream reader here, there's not much as it mostly just forwards requests to the scanner: and so we can as well just copy the little code stream reader's next() method has. -
fireAuxEvent
private final void fireAuxEvent(int type, boolean inTree) throws IOException, SAXException, XMLStreamException -
fireStartTag
- Throws:
SAXException
-
setDocumentHandler
- Specified by:
setDocumentHandlerin interfaceParser
-
setLocale
-
getIndex
- Specified by:
getIndexin interfaceAttributes
-
getIndex
- Specified by:
getIndexin interfaceAttributes
-
getLength
public int getLength()- Specified by:
getLengthin interfaceAttributes
-
getLocalName
- Specified by:
getLocalNamein interfaceAttributes
-
getQName
- Specified by:
getQNamein interfaceAttributes
-
getType
- Specified by:
getTypein interfaceAttributes
-
getType
- Specified by:
getTypein interfaceAttributes
-
getType
- Specified by:
getTypein interfaceAttributes
-
getURI
- Specified by:
getURIin interfaceAttributes
-
getValue
- Specified by:
getValuein interfaceAttributes
-
getValue
- Specified by:
getValuein interfaceAttributes
-
getValue
- Specified by:
getValuein interfaceAttributes
-
isDeclared
public boolean isDeclared(int index) - Specified by:
isDeclaredin interfaceAttributes2
-
isDeclared
- Specified by:
isDeclaredin interfaceAttributes2
-
isDeclared
- Specified by:
isDeclaredin interfaceAttributes2
-
isSpecified
public boolean isSpecified(int index) - Specified by:
isSpecifiedin interfaceAttributes2
-
isSpecified
- Specified by:
isSpecifiedin interfaceAttributes2
-
isSpecified
- Specified by:
isSpecifiedin interfaceAttributes2
-
getColumnNumber
public int getColumnNumber()- Specified by:
getColumnNumberin interfaceLocator
-
getLineNumber
public int getLineNumber()- Specified by:
getLineNumberin interfaceLocator
-
getPublicId
- Specified by:
getPublicIdin interfaceLocator
-
getSystemId
- Specified by:
getSystemIdin interfaceLocator
-
getEncoding
- Specified by:
getEncodingin interfaceLocator2
-
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
- Specified by:
dtdProcessingInstructionin interfaceDTDEventListener
-
dtdSkippedEntity
- 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
- Specified by:
attributeDeclin interfaceDTDEventListener
-
dtdElementDecl
- Specified by:
dtdElementDeclin interfaceDTDEventListener
-
dtdExternalEntityDecl
- Specified by:
dtdExternalEntityDeclin interfaceDTDEventListener
-
dtdInternalEntityDecl
- Specified by:
dtdInternalEntityDeclin interfaceDTDEventListener
-
throwSaxException
- Throws:
SAXException
-
throwSaxException
- Throws:
SAXException
-
throwNoSuchAttribute
private void throwNoSuchAttribute(int index)
-