Class DefaultContentHandler
java.lang.Object
com.aquima.interactions.foundation.xml.parsing.DefaultContentHandler
- All Implemented Interfaces:
ContentHandler
Default SAX2 ContentHandler base class. Does nothing (all handling methods are empty).
Subclass this and override the methods you need, then set this class as the ContentHandler for the SAX parser. This way you don't have to implement the methods you don't need, because this base class has an implementation.
This contenthandler also has a special method to be able to use sub-contenthandlers easily.
Some stuff is implemented here: the location handler and some methods to get a location string / exception.
- Since:
- 5.0
- Author:
- IdJ
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
characters
(char[] chars, int start, int length) void
void
endElement
(String namespaceUri, String localName, String qname) void
endPrefixMapping
(String prefix) Returns a string of the current location.void
ignorableWhitespace
(char[] chars, int start, int length) void
parseError
(String msg) Throws a SAXException with location string.void
processingInstruction
(String target, String data) void
SAX2 document locator, called when parser starts.void
skippedEntity
(String name) void
void
startElement
(String namespaceUri, String localName, String qname, Attributes attrs) void
startPrefixMapping
(String prefix, String uri) void
subHandlerFinished
(String nsUri, String localName, String qname) called by a subhandler when it is done, it will supply the data of the last XML element.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
DefaultContentHandler
public DefaultContentHandler()
-
-
Method Details
-
setDocumentLocator
SAX2 document locator, called when parser starts.- Specified by:
setDocumentLocator
in interfaceContentHandler
- Parameters:
loc
- The document locator that should be used.
-
parseError
Throws a SAXException with location string. You can use this yourself when you discover additional problems while parsing the XML. Your Content Handler can call this.parseError("something's wrong") and bail out easily.- Parameters:
msg
- Message containing the cause of the error.- Throws:
SAXException
- This exception is always thrown containing the message and the location in the XML.
-
getLocationString
Returns a string of the current location.- Returns:
- a string of the current location.
-
startDocument
- Specified by:
startDocument
in interfaceContentHandler
- Throws:
SAXException
-
endDocument
- Specified by:
endDocument
in interfaceContentHandler
- Throws:
SAXException
-
startPrefixMapping
- Specified by:
startPrefixMapping
in interfaceContentHandler
- Throws:
SAXException
-
endPrefixMapping
- Specified by:
endPrefixMapping
in interfaceContentHandler
- Throws:
SAXException
-
startElement
public void startElement(String namespaceUri, String localName, String qname, Attributes attrs) throws SAXException - Specified by:
startElement
in interfaceContentHandler
- Throws:
SAXException
-
endElement
- Specified by:
endElement
in interfaceContentHandler
- Throws:
SAXException
-
characters
- Specified by:
characters
in interfaceContentHandler
- Throws:
SAXException
-
ignorableWhitespace
- Specified by:
ignorableWhitespace
in interfaceContentHandler
- Throws:
SAXException
-
processingInstruction
- Specified by:
processingInstruction
in interfaceContentHandler
- Throws:
SAXException
-
skippedEntity
- Specified by:
skippedEntity
in interfaceContentHandler
- Throws:
SAXException
-
subHandlerFinished
called by a subhandler when it is done, it will supply the data of the last XML element.- Parameters:
nsUri
- the namespace URI of the eltlocalName
- the local name of the eltqname
- the qualified (prefixed) name of the elt
-