Class AbstractSAXParser
- java.lang.Object
-
- org.htmlunit.cyberneko.xerces.parsers.XMLParser
-
- org.htmlunit.cyberneko.xerces.parsers.AbstractXMLDocumentParser
-
- org.htmlunit.cyberneko.xerces.parsers.AbstractSAXParser
-
- All Implemented Interfaces:
XMLDocumentHandler,org.xml.sax.XMLReader
- Direct Known Subclasses:
SAXParser
public abstract class AbstractSAXParser extends AbstractXMLDocumentParser implements org.xml.sax.XMLReader
This is the base class of all SAX parsers. It implements both the SAX1 and SAX2 parser functionality, while the actual pipeline is defined in the parser configuration.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractSAXParser.AttributesProxyprotected static classAbstractSAXParser.LocatorProxy
-
Field Summary
Fields Modifier and Type Field Description private AbstractSAXParser.AttributesProxyfAttributesProxyprotected org.xml.sax.ContentHandlerfContentHandlerContent handler.protected org.xml.sax.DTDHandlerfDTDHandlerDTD handler.protected org.xml.sax.ext.LexicalHandlerfLexicalHandlerLexical handler.protected booleanfLexicalHandlerParameterEntitiesLexical handler parameter entities.protected NamespaceContextfNamespaceContextNamespace contextprotected booleanfNamespacePrefixesNamespace prefixes.protected booleanfNamespacesNamespaces.protected booleanfStandaloneStandalone document declaration.protected booleanfUseEntityResolver2Use EntityResolver2.protected java.lang.StringfVersionprotected static java.lang.StringLEXICAL_HANDLERProperty id: lexical handler.protected static java.lang.StringNAMESPACESFeature identifier: namespaces.private static java.lang.String[]RECOGNIZED_FEATURESRecognized features.private static java.lang.String[]RECOGNIZED_PROPERTIESRecognized properties.-
Fields inherited from class org.htmlunit.cyberneko.xerces.parsers.XMLParser
ERROR_HANDLER, parserConfiguration_
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSAXParser(XMLParserConfiguration config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(XMLString text, Augmentations augs)Character content.voidcomment(XMLString text, Augmentations augs)A comment.voiddoctypeDecl(java.lang.String rootElement, java.lang.String publicId, java.lang.String systemId, Augmentations augs)Notifies of the presence of the DOCTYPE line in the document.voidendCDATA(Augmentations augs)The end of a CDATA section.voidendDocument(Augmentations augs)The end of the document.voidendElement(QName element, Augmentations augs)The end of an element.protected voidendNamespaceMapping()Send endPrefixMapping eventsorg.xml.sax.ContentHandlergetContentHandler()Return the current content handler.org.xml.sax.DTDHandlergetDTDHandler()Return the current DTD handler.org.xml.sax.EntityResolvergetEntityResolver()Return the current entity resolver.org.xml.sax.ErrorHandlergetErrorHandler()Return the current error handler.booleangetFeature(java.lang.String featureId)Query the state of a feature.protected org.xml.sax.ext.LexicalHandlergetLexicalHandler()java.lang.ObjectgetProperty(java.lang.String propertyId)Query the value of a property.voidparse(java.lang.String systemId)Parses the input source specified by the given system identifier.voidparse(org.xml.sax.InputSource inputSource)voidprocessingInstruction(java.lang.String target, XMLString data, Augmentations augs)A processing instruction.voidreset()Reset all components before parsing.voidsetContentHandler(org.xml.sax.ContentHandler contentHandler)Allow an application to register a content event handler.voidsetDTDHandler(org.xml.sax.DTDHandler dtdHandler)Allow an application to register a DTD event handler.voidsetEntityResolver(org.xml.sax.EntityResolver resolver)voidsetErrorHandler(org.xml.sax.ErrorHandler errorHandler)Allow an application to register an error event handler.voidsetFeature(java.lang.String featureId, boolean state)Set the state of any feature in a SAX2 parser.protected voidsetLexicalHandler(org.xml.sax.ext.LexicalHandler handler)Set the lexical event handler.voidsetProperty(java.lang.String propertyId, java.lang.Object value)Set the value of any property in a SAX2 parser.voidstartCDATA(Augmentations augs)The start of a CDATA section.voidstartDocument(XMLLocator locator, java.lang.String encoding, NamespaceContext namespaceContext, Augmentations augs)The start of the document.voidstartElement(QName element, XMLAttributes attributes, Augmentations augs)The start of an element.protected voidstartNamespaceMapping()Send startPrefixMapping eventsvoidxmlDecl(java.lang.String version, java.lang.String encoding, java.lang.String standalone, Augmentations augs)Notifies of the presence of an XMLDecl line in the document.-
Methods inherited from class org.htmlunit.cyberneko.xerces.parsers.AbstractXMLDocumentParser
emptyElement, getDocumentSource, setDocumentSource
-
-
-
-
Field Detail
-
NAMESPACES
protected static final java.lang.String NAMESPACES
Feature identifier: namespaces.- See Also:
- Constant Field Values
-
RECOGNIZED_FEATURES
private static final java.lang.String[] RECOGNIZED_FEATURES
Recognized features.
-
LEXICAL_HANDLER
protected static final java.lang.String LEXICAL_HANDLER
Property id: lexical handler.- See Also:
- Constant Field Values
-
RECOGNIZED_PROPERTIES
private static final java.lang.String[] RECOGNIZED_PROPERTIES
Recognized properties.
-
fNamespaces
protected boolean fNamespaces
Namespaces.
-
fNamespacePrefixes
protected boolean fNamespacePrefixes
Namespace prefixes.
-
fLexicalHandlerParameterEntities
protected boolean fLexicalHandlerParameterEntities
Lexical handler parameter entities.
-
fStandalone
protected boolean fStandalone
Standalone document declaration.
-
fUseEntityResolver2
protected boolean fUseEntityResolver2
Use EntityResolver2.
-
fContentHandler
protected org.xml.sax.ContentHandler fContentHandler
Content handler.
-
fNamespaceContext
protected NamespaceContext fNamespaceContext
Namespace context
-
fDTDHandler
protected org.xml.sax.DTDHandler fDTDHandler
DTD handler.
-
fLexicalHandler
protected org.xml.sax.ext.LexicalHandler fLexicalHandler
Lexical handler.
-
fVersion
protected java.lang.String fVersion
-
fAttributesProxy
private final AbstractSAXParser.AttributesProxy fAttributesProxy
-
-
Constructor Detail
-
AbstractSAXParser
protected AbstractSAXParser(XMLParserConfiguration config)
-
-
Method Detail
-
startDocument
public void startDocument(XMLLocator locator, java.lang.String encoding, NamespaceContext namespaceContext, Augmentations augs) throws XNIException
The start of the document.- Specified by:
startDocumentin interfaceXMLDocumentHandler- Overrides:
startDocumentin classAbstractXMLDocumentParser- Parameters:
locator- The document locator, or null if the document location cannot be reported during the parsing of this document. However, it is strongly recommended that a locator be supplied that can at least report the system identifier of the document.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).namespaceContext- The namespace context in effect at the start of this document. This object represents the current context. Implementors of this class are responsible for copying the namespace bindings from the the current context (and its parent contexts) if that information is important.augs- Additional information that may include infoset augmentations- Throws:
XNIException- Thrown by handler to signal an error.
-
xmlDecl
public void xmlDecl(java.lang.String version, java.lang.String encoding, java.lang.String standalone, Augmentations augs) throws XNIExceptionNotifies of the presence of an XMLDecl line in the document. If present, this method will be called immediately following the startDocument call.- Specified by:
xmlDeclin interfaceXMLDocumentHandler- Overrides:
xmlDeclin classAbstractXMLDocumentParser- Parameters:
version- The XML version.encoding- The IANA encoding name of the document, or null if not specified.standalone- The standalone value, or null if not specified.augs- Additional information that may include infoset augmentations- Throws:
XNIException- Thrown by handler to signal an error.
-
doctypeDecl
public void doctypeDecl(java.lang.String rootElement, java.lang.String publicId, java.lang.String systemId, Augmentations augs) throws XNIExceptionNotifies of the presence of the DOCTYPE line in the document.- Specified by:
doctypeDeclin interfaceXMLDocumentHandler- Overrides:
doctypeDeclin classAbstractXMLDocumentParser- Parameters:
rootElement- The name of the root element.publicId- The public identifier if an external DTD or null if the external DTD is specified using SYSTEM.systemId- The system identifier if an external DTD, null otherwise.augs- Additional information that may include infoset augmentations- Throws:
XNIException- Thrown by handler to signal an error.
-
startElement
public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException
The start of an element. If the document specifies the start element by using an empty tag, then the startElement method will immediately be followed by the endElement method, with no intervening methods.- Specified by:
startElementin interfaceXMLDocumentHandler- Overrides:
startElementin classAbstractXMLDocumentParser- Parameters:
element- The name of the element.attributes- The element attributes.augs- Additional information that may include infoset augmentations- Throws:
XNIException- Thrown by handler to signal an error.
-
characters
public void characters(XMLString text, Augmentations augs) throws XNIException
Character content.- Specified by:
charactersin interfaceXMLDocumentHandler- Overrides:
charactersin classAbstractXMLDocumentParser- Parameters:
text- The content.augs- Additional information that may include infoset augmentations- Throws:
XNIException- Thrown by handler to signal an error.
-
endElement
public void endElement(QName element, Augmentations augs) throws XNIException
The end of an element.- Specified by:
endElementin interfaceXMLDocumentHandler- Overrides:
endElementin classAbstractXMLDocumentParser- Parameters:
element- The name of the element.augs- Additional information that may include infoset augmentations- Throws:
XNIException- Thrown by handler to signal an error.
-
startCDATA
public void startCDATA(Augmentations augs) throws XNIException
The start of a CDATA section.- Specified by:
startCDATAin interfaceXMLDocumentHandler- Overrides:
startCDATAin classAbstractXMLDocumentParser- Parameters:
augs- Additional information that may include infoset augmentations- Throws:
XNIException- Thrown by handler to signal an error.
-
endCDATA
public void endCDATA(Augmentations augs) throws XNIException
The end of a CDATA section.- Specified by:
endCDATAin interfaceXMLDocumentHandler- Overrides:
endCDATAin classAbstractXMLDocumentParser- Parameters:
augs- Additional information that may include infoset augmentations- Throws:
XNIException- Thrown by handler to signal an error.
-
comment
public void comment(XMLString text, Augmentations augs) throws XNIException
A comment.- Specified by:
commentin interfaceXMLDocumentHandler- Overrides:
commentin classAbstractXMLDocumentParser- Parameters:
text- The text in the comment.augs- Additional information that may include infoset augmentations- Throws:
XNIException- Thrown by application to signal an error.
-
processingInstruction
public void processingInstruction(java.lang.String target, XMLString data, Augmentations augs) throws XNIExceptionA processing instruction. Processing instructions consist of a target name and, optionally, text data. The data is only meaningful to the application.Typically, a processing instruction's data will contain a series of pseudo-attributes. These pseudo-attributes follow the form of element attributes but are not parsed or presented to the application as anything other than text. The application is responsible for parsing the data.
- Specified by:
processingInstructionin interfaceXMLDocumentHandler- Overrides:
processingInstructionin classAbstractXMLDocumentParser- Parameters:
target- The target.data- The data or null if none specified.augs- Additional information that may include infoset augmentations- Throws:
XNIException- Thrown by handler to signal an error.
-
endDocument
public void endDocument(Augmentations augs) throws XNIException
The end of the document.- Specified by:
endDocumentin interfaceXMLDocumentHandler- Overrides:
endDocumentin classAbstractXMLDocumentParser- Parameters:
augs- Additional information that may include infoset augmentations- Throws:
XNIException- Thrown by handler to signal an error.
-
parse
public void parse(java.lang.String systemId) throws org.xml.sax.SAXException, java.io.IOExceptionParses the input source specified by the given system identifier.This method is equivalent to the following:
parse(new InputSource(systemId));
- Specified by:
parsein interfaceorg.xml.sax.XMLReader- Parameters:
systemId- The system identifier (URI).- Throws:
org.xml.sax.SAXException- Throws exception on SAX error.java.io.IOException- Throws exception on i/o error.
-
parse
public void parse(org.xml.sax.InputSource inputSource) throws org.xml.sax.SAXException, java.io.IOException- Specified by:
parsein interfaceorg.xml.sax.XMLReader- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
setEntityResolver
public void setEntityResolver(org.xml.sax.EntityResolver resolver)
- Specified by:
setEntityResolverin interfaceorg.xml.sax.XMLReader
-
getEntityResolver
public org.xml.sax.EntityResolver getEntityResolver()
Return the current entity resolver.- Specified by:
getEntityResolverin interfaceorg.xml.sax.XMLReader- Returns:
- The current entity resolver, or null if none has been registered.
- See Also:
setEntityResolver(org.xml.sax.EntityResolver)
-
setErrorHandler
public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
Allow an application to register an error event handler.If the application does not register an error handler, all error events reported by the SAX parser will be silently ignored; however, normal processing may not continue. It is highly recommended that all SAX applications implement an error handler to avoid unexpected bugs.
Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
- Specified by:
setErrorHandlerin interfaceorg.xml.sax.XMLReader- Parameters:
errorHandler- The error handler.- See Also:
getErrorHandler()
-
getErrorHandler
public org.xml.sax.ErrorHandler getErrorHandler()
Return the current error handler.- Specified by:
getErrorHandlerin interfaceorg.xml.sax.XMLReader- Returns:
- The current error handler, or null if none has been registered.
- See Also:
setErrorHandler(org.xml.sax.ErrorHandler)
-
setDTDHandler
public void setDTDHandler(org.xml.sax.DTDHandler dtdHandler)
Allow an application to register a DTD event handler.If the application does not register a DTD handler, all DTD events reported by the SAX parser will be silently ignored.
Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
- Specified by:
setDTDHandlerin interfaceorg.xml.sax.XMLReader- Parameters:
dtdHandler- The DTD handler.- See Also:
getDTDHandler()
-
setContentHandler
public void setContentHandler(org.xml.sax.ContentHandler contentHandler)
Allow an application to register a content event handler.If the application does not register a content handler, all content events reported by the SAX parser will be silently ignored.
Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
- Specified by:
setContentHandlerin interfaceorg.xml.sax.XMLReader- Parameters:
contentHandler- The content handler.- See Also:
getContentHandler()
-
getContentHandler
public org.xml.sax.ContentHandler getContentHandler()
Return the current content handler.- Specified by:
getContentHandlerin interfaceorg.xml.sax.XMLReader- Returns:
- The current content handler, or null if none has been registered.
- See Also:
setContentHandler(org.xml.sax.ContentHandler)
-
getDTDHandler
public org.xml.sax.DTDHandler getDTDHandler()
Return the current DTD handler.- Specified by:
getDTDHandlerin interfaceorg.xml.sax.XMLReader- Returns:
- The current DTD handler, or null if none has been registered.
- See Also:
setDTDHandler(org.xml.sax.DTDHandler)
-
setFeature
public void setFeature(java.lang.String featureId, boolean state) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionSet the state of any feature in a SAX2 parser. The parser might not recognize the feature, and if it does recognize it, it might not be able to fulfill the request.- Specified by:
setFeaturein interfaceorg.xml.sax.XMLReader- Parameters:
featureId- The unique identifier (URI) of the feature.state- The requested state of the feature (true or false).- Throws:
org.xml.sax.SAXNotRecognizedException- If the requested feature is not known.org.xml.sax.SAXNotSupportedException- If the requested feature is known, but the requested state is not supported.
-
getFeature
public boolean getFeature(java.lang.String featureId) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionQuery the state of a feature.Query the current state of any feature in a SAX2 parser. The parser might not recognize the feature.
- Specified by:
getFeaturein interfaceorg.xml.sax.XMLReader- Parameters:
featureId- The unique identifier (URI) of the feature being set.- Returns:
- The current state of the feature.
- Throws:
org.xml.sax.SAXNotRecognizedException- If the requested feature is not known.org.xml.sax.SAXNotSupportedException- If the requested feature is known but not supported.
-
setProperty
public void setProperty(java.lang.String propertyId, java.lang.Object value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionSet the value of any property in a SAX2 parser. The parser might not recognize the property, and if it does recognize it, it might not support the requested value.- Specified by:
setPropertyin interfaceorg.xml.sax.XMLReader- Parameters:
propertyId- The unique identifier (URI) of the property being set.value- The value to which the property is being set.- Throws:
org.xml.sax.SAXNotRecognizedException- If the requested property is not known.org.xml.sax.SAXNotSupportedException- If the requested property is known, but the requested value is not supported.
-
getProperty
public java.lang.Object getProperty(java.lang.String propertyId) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionQuery the value of a property.Return the current value of a property in a SAX2 parser. The parser might not recognize the property.
- Specified by:
getPropertyin interfaceorg.xml.sax.XMLReader- Parameters:
propertyId- The unique identifier (URI) of the property being set.- Returns:
- The current value of the property.
- Throws:
org.xml.sax.SAXNotRecognizedException- If the requested property is not known.org.xml.sax.SAXNotSupportedException- If the requested property is known but not supported.
-
setLexicalHandler
protected void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler) throws org.xml.sax.SAXNotSupportedExceptionSet the lexical event handler.This method is the equivalent to the property:
http://xml.org/sax/properties/lexical-handler
- Parameters:
handler- lexical event handler- Throws:
org.xml.sax.SAXNotSupportedException- on error- See Also:
getLexicalHandler(),setProperty(String, Object)
-
getLexicalHandler
protected org.xml.sax.ext.LexicalHandler getLexicalHandler()
- Returns:
- the lexical handler.
- See Also:
setLexicalHandler(LexicalHandler)
-
startNamespaceMapping
protected final void startNamespaceMapping() throws org.xml.sax.SAXExceptionSend startPrefixMapping events- Throws:
org.xml.sax.SAXException- on error
-
endNamespaceMapping
protected final void endNamespaceMapping() throws org.xml.sax.SAXExceptionSend endPrefixMapping events- Throws:
org.xml.sax.SAXException- on error
-
reset
public void reset() throws XNIExceptionReset all components before parsing.- Overrides:
resetin classXMLParser- Throws:
XNIException- Thrown if an error occurs during initialization.
-
-