Package javanet.staxutils
Class StAXContentHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- javanet.staxutils.StAXContentHandler
-
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler,LexicalHandler
- Direct Known Subclasses:
StAXEventContentHandler,StAXStreamContentHandler
public abstract class StAXContentHandler extends DefaultHandler implements LexicalHandler
Base class for SAX-to-STAX bridge classes that provides common functionality.- Version:
- $Revision: 1.3 $
- Author:
- Christian Niles
-
-
Field Summary
Fields Modifier and Type Field Description protected StringBufferCDATABufferBuffer containing text read within the current CDATA section.protected LocatordocLocatorThe SAXLocatorprovided to the handler.protected booleanisCDATAWhether the parser is currently within a CDATA section.protected SimpleNamespaceContextnamespacesStack used to store declared namespaces.protected XMLReporterreporterThe STAXXMLReporterregistered to receive notifications.
-
Constructor Summary
Constructors Constructor Description StAXContentHandler()StAXContentHandler(XMLReporter reporter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)voidcomment(char[] ch, int start, int length)voidendCDATA()voidendDocument()voidendDTD()voidendElement(String uri, String localName, String qName)voidendEntity(String name)voidendPrefixMapping(String prefix)voiderror(SAXParseException e)voidfatalError(SAXParseException e)LocationgetCurrentLocation()static voidparseQName(String qName, String[] results)Parses an XML qualified name, and places the resulting prefix and local name in the provided String array.protected voidreportException(String type, SAXException e)Used to report aSAXExceptionto theXMLReporterregistered with this handler.voidsetDocumentLocator(Locator locator)voidsetXMLReporter(XMLReporter reporter)Sets theXMLReporterto which warning and error messages will be sent.voidstartCDATA()voidstartDocument()voidstartDTD(String name, String publicId, String systemId)voidstartElement(String uri, String localName, String qName, Attributes attributes)voidstartEntity(String name)voidstartPrefixMapping(String prefix, String uri)voidwarning(SAXParseException e)-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, unparsedEntityDecl
-
-
-
-
Field Detail
-
isCDATA
protected boolean isCDATA
Whether the parser is currently within a CDATA section.
-
CDATABuffer
protected StringBuffer CDATABuffer
Buffer containing text read within the current CDATA section.
-
namespaces
protected SimpleNamespaceContext namespaces
Stack used to store declared namespaces.
-
reporter
protected XMLReporter reporter
The STAXXMLReporterregistered to receive notifications.
-
-
Constructor Detail
-
StAXContentHandler
public StAXContentHandler()
-
StAXContentHandler
public StAXContentHandler(XMLReporter reporter)
-
-
Method Detail
-
setXMLReporter
public void setXMLReporter(XMLReporter reporter)
Sets theXMLReporterto which warning and error messages will be sent.- Parameters:
reporter- TheXMLReporterto notify of errors.
-
setDocumentLocator
public void setDocumentLocator(Locator locator)
- Specified by:
setDocumentLocatorin interfaceContentHandler- Overrides:
setDocumentLocatorin classDefaultHandler
-
getCurrentLocation
public Location getCurrentLocation()
-
error
public void error(SAXParseException e) throws SAXException
- Specified by:
errorin interfaceErrorHandler- Overrides:
errorin classDefaultHandler- Throws:
SAXException
-
fatalError
public void fatalError(SAXParseException e) throws SAXException
- Specified by:
fatalErrorin interfaceErrorHandler- Overrides:
fatalErrorin classDefaultHandler- Throws:
SAXException
-
warning
public void warning(SAXParseException e) throws SAXException
- Specified by:
warningin interfaceErrorHandler- Overrides:
warningin classDefaultHandler- Throws:
SAXException
-
startDocument
public void startDocument() throws SAXException- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classDefaultHandler- Throws:
SAXException
-
endDocument
public void endDocument() throws SAXException- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classDefaultHandler- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException
-
endElement
public void endElement(String uri, String localName, String qName) throws SAXException
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Throws:
SAXException
-
startPrefixMapping
public void startPrefixMapping(String prefix, String uri) throws SAXException
- Specified by:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin classDefaultHandler- Throws:
SAXException
-
endPrefixMapping
public void endPrefixMapping(String prefix) throws SAXException
- Specified by:
endPrefixMappingin interfaceContentHandler- Overrides:
endPrefixMappingin classDefaultHandler- Throws:
SAXException
-
startCDATA
public void startCDATA() throws SAXException- Specified by:
startCDATAin interfaceLexicalHandler- Throws:
SAXException
-
characters
public void characters(char[] ch, int start, int length) throws SAXException- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Throws:
SAXException
-
endCDATA
public void endCDATA() throws SAXException- Specified by:
endCDATAin interfaceLexicalHandler- Throws:
SAXException
-
comment
public void comment(char[] ch, int start, int length) throws SAXException- Specified by:
commentin interfaceLexicalHandler- Throws:
SAXException
-
endDTD
public void endDTD() throws SAXException- Specified by:
endDTDin interfaceLexicalHandler- Throws:
SAXException
-
endEntity
public void endEntity(String name) throws SAXException
- Specified by:
endEntityin interfaceLexicalHandler- Throws:
SAXException
-
startDTD
public void startDTD(String name, String publicId, String systemId) throws SAXException
- Specified by:
startDTDin interfaceLexicalHandler- Throws:
SAXException
-
startEntity
public void startEntity(String name) throws SAXException
- Specified by:
startEntityin interfaceLexicalHandler- Throws:
SAXException
-
reportException
protected void reportException(String type, SAXException e) throws SAXException
Used to report aSAXExceptionto theXMLReporterregistered with this handler.- Throws:
SAXException
-
parseQName
public static final void parseQName(String qName, String[] results)
Parses an XML qualified name, and places the resulting prefix and local name in the provided String array.- Parameters:
qName- The qualified name to parse.results- An array where parse results will be placed. The prefix will be placed atresults[0], and the local part atresults[1]
-
-