Class AbstractSAXParser
- All Implemented Interfaces:
XMLDocumentHandler, XMLReader
- Direct Known Subclasses:
SAXParser
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classprotected static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AbstractSAXParser.AttributesProxyprotected ContentHandlerContent handler.protected DTDHandlerDTD handler.protected LexicalHandlerLexical handler.protected booleanLexical handler parameter entities.protected NamespaceContextNamespace contextprotected booleanNamespace prefixes.protected booleanNamespaces.protected booleanStandalone document declaration.protected booleanUse EntityResolver2.protected Stringprotected static final StringProperty id: lexical handler.protected static final StringFeature identifier: namespaces.private static final String[]Recognized features.private static final String[]Recognized properties.Fields inherited from class XMLParser
ERROR_HANDLER, parserConfiguration_ -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(XMLString text, Augmentations augs) Character content.voidcomment(XMLString text, Augmentations augs) A comment.voiddoctypeDecl(String rootElement, String publicId, 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 final voidSend endPrefixMapping eventsReturn the current content handler.Return the current DTD handler.Return the current entity resolver.Return the current error handler.booleangetFeature(String featureId) Query the state of a feature.protected LexicalHandlergetProperty(String propertyId) Query the value of a property.voidParses the input source specified by the given system identifier.voidparse(InputSource inputSource) voidprocessingInstruction(String target, XMLString data, Augmentations augs) A processing instruction.voidreset()Reset all components before parsing.voidsetContentHandler(ContentHandler contentHandler) Allow an application to register a content event handler.voidsetDTDHandler(DTDHandler dtdHandler) Allow an application to register a DTD event handler.voidsetEntityResolver(EntityResolver resolver) voidsetErrorHandler(ErrorHandler errorHandler) Allow an application to register an error event handler.voidsetFeature(String featureId, boolean state) Set the state of any feature in a SAX2 parser.protected voidsetLexicalHandler(LexicalHandler handler) Set the lexical event handler.voidsetProperty(String propertyId, Object value) Set the value of any property in a SAX2 parser.voidstartCDATA(Augmentations augs) The start of a CDATA section.voidstartDocument(XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs) The start of the document.voidstartElement(QName element, XMLAttributes attributes, Augmentations augs) The start of an element.protected final voidSend startPrefixMapping eventsvoidxmlDecl(String version, String encoding, String standalone, Augmentations augs) Notifies of the presence of an XMLDecl line in the document.Methods inherited from class AbstractXMLDocumentParser
emptyElement, getDocumentSource, setDocumentSource
-
Field Details
-
NAMESPACES
-
RECOGNIZED_FEATURES
Recognized features. -
LEXICAL_HANDLER
-
RECOGNIZED_PROPERTIES
Recognized properties. -
fNamespaces
protected boolean fNamespacesNamespaces. -
fNamespacePrefixes
protected boolean fNamespacePrefixesNamespace prefixes. -
fLexicalHandlerParameterEntities
protected boolean fLexicalHandlerParameterEntitiesLexical handler parameter entities. -
fStandalone
protected boolean fStandaloneStandalone document declaration. -
fUseEntityResolver2
protected boolean fUseEntityResolver2Use EntityResolver2. -
fContentHandler
Content handler. -
fNamespaceContext
Namespace context -
fDTDHandler
DTD handler. -
fLexicalHandler
Lexical handler. -
fVersion
-
fAttributesProxy
-
-
Constructor Details
-
AbstractSAXParser
-
-
Method Details
-
startDocument
public void startDocument(XMLLocator locator, 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(String version, String encoding, String standalone, Augmentations augs) throws XNIException Notifies 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(String rootElement, String publicId, String systemId, Augmentations augs) throws XNIException Notifies 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
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
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
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
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
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(String target, XMLString data, Augmentations augs) throws XNIException A 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
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
Parses the input source specified by the given system identifier.This method is equivalent to the following:
parse(new InputSource(systemId));
- Specified by:
parsein interfaceXMLReader- Parameters:
systemId- The system identifier (URI).- Throws:
SAXException- Throws exception on SAX error.IOException- Throws exception on i/o error.
-
parse
- Specified by:
parsein interfaceXMLReader- Throws:
SAXExceptionIOException
-
setEntityResolver
- Specified by:
setEntityResolverin interfaceXMLReader
-
getEntityResolver
Return the current entity resolver.- Specified by:
getEntityResolverin interfaceXMLReader- Returns:
- The current entity resolver, or null if none has been registered.
- See Also:
-
setErrorHandler
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 interfaceXMLReader- Parameters:
errorHandler- The error handler.- See Also:
-
getErrorHandler
Return the current error handler.- Specified by:
getErrorHandlerin interfaceXMLReader- Returns:
- The current error handler, or null if none has been registered.
- See Also:
-
setDTDHandler
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 interfaceXMLReader- Parameters:
dtdHandler- The DTD handler.- See Also:
-
setContentHandler
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 interfaceXMLReader- Parameters:
contentHandler- The content handler.- See Also:
-
getContentHandler
Return the current content handler.- Specified by:
getContentHandlerin interfaceXMLReader- Returns:
- The current content handler, or null if none has been registered.
- See Also:
-
getDTDHandler
Return the current DTD handler.- Specified by:
getDTDHandlerin interfaceXMLReader- Returns:
- The current DTD handler, or null if none has been registered.
- See Also:
-
setFeature
public void setFeature(String featureId, boolean state) throws SAXNotRecognizedException, SAXNotSupportedException Set 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 interfaceXMLReader- Parameters:
featureId- The unique identifier (URI) of the feature.state- The requested state of the feature (true or false).- Throws:
SAXNotRecognizedException- If the requested feature is not known.SAXNotSupportedException- If the requested feature is known, but the requested state is not supported.
-
getFeature
public boolean getFeature(String featureId) throws SAXNotRecognizedException, SAXNotSupportedException Query 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 interfaceXMLReader- Parameters:
featureId- The unique identifier (URI) of the feature being set.- Returns:
- The current state of the feature.
- Throws:
SAXNotRecognizedException- If the requested feature is not known.SAXNotSupportedException- If the requested feature is known but not supported.
-
setProperty
public void setProperty(String propertyId, Object value) throws SAXNotRecognizedException, SAXNotSupportedException Set 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 interfaceXMLReader- Parameters:
propertyId- The unique identifier (URI) of the property being set.value- The value to which the property is being set.- Throws:
SAXNotRecognizedException- If the requested property is not known.SAXNotSupportedException- If the requested property is known, but the requested value is not supported.
-
getProperty
public Object getProperty(String propertyId) throws SAXNotRecognizedException, SAXNotSupportedException Query 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 interfaceXMLReader- Parameters:
propertyId- The unique identifier (URI) of the property being set.- Returns:
- The current value of the property.
- Throws:
SAXNotRecognizedException- If the requested property is not known.SAXNotSupportedException- If the requested property is known but not supported.
-
setLexicalHandler
Set 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:
SAXNotSupportedException- on error- See Also:
-
getLexicalHandler
- Returns:
- the lexical handler.
- See Also:
-
startNamespaceMapping
Send startPrefixMapping events- Throws:
SAXException- on error
-
endNamespaceMapping
Send endPrefixMapping events- Throws:
SAXException- on error
-
reset
Reset all components before parsing.- Overrides:
resetin classXMLParser- Throws:
XNIException- Thrown if an error occurs during initialization.
-