public class SAXHandler
extends org.xml.sax.helpers.DefaultHandler
implements org.xml.sax.ext.LexicalHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.DTDHandler
SAXBuilder which listens for SAX events.
 People overriding this class are cautioned to ensure that the implementation of the cleanUp() method resets to a virgin state. The cleanUp() method will be called when this SAXHandler is reset(), which may happen multiple times between parses. The cleanUp() method must ensure that there are no references remaining to any external instances.
 Overriding of this class is permitted to allow for different handling of SAX
 events. Once you have created a subclass of this, you also need to create a
 custom implementation of SAXHandlerFactory to supply your instances
 to SAXBuilder
 
 If the XMLReader producing the SAX Events supports a document Locator, then
 this instance will use the locator to supply the line and column data from
 the SAX locator to the JDOMFactory. Note: the SAX
 specification for the SAX Locator indicates that the line and column
 represent the position of the end of the SAX Event. For
 example, the line and column of the simple XML <root />
 would be line 1, column 9.
org.jdom2.input.sax| Constructor and Description | 
|---|
| SAXHandler()This will create a new  SAXHandlerthat listens to SAX events
 and creates a JDOM Document. | 
| SAXHandler(JDOMFactory factory)This will create a new  SAXHandlerthat listens to SAX events
 and creates a JDOM Document. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | attributeDecl(java.lang.String eName,
             java.lang.String aName,
             java.lang.String type,
             java.lang.String valueDefault,
             java.lang.String value)This handles an attribute declaration in the internal subset. | 
| void | characters(char[] ch,
          int start,
          int length)This will report character data (within an element). | 
| void | comment(char[] ch,
       int start,
       int length)This reports that a comments is parsed. | 
| void | elementDecl(java.lang.String name,
           java.lang.String model)Handle an element declaration in a DTD. | 
| void | endCDATA()Report a CDATA section | 
| void | endDTD()This signifies that the reading of the DTD is complete. | 
| void | endElement(java.lang.String namespaceURI,
          java.lang.String localName,
          java.lang.String qName)Indicates the end of an element ( </[element name]>) is
 reached. | 
| void | endEntity(java.lang.String name) | 
| void | externalEntityDecl(java.lang.String name,
                  java.lang.String publicID,
                  java.lang.String systemID)This is called when the parser encounters an external entity declaration. | 
| protected void | flushCharacters()This will flush any characters from SAX character calls we've been
 buffering. | 
| protected void | flushCharacters(java.lang.String data)Flush the given string into the document. | 
| Element | getCurrentElement()Returns the being-parsed element. | 
| Document | getDocument()Returns the document. | 
| org.xml.sax.Locator | getDocumentLocator()Provides access to the  Locatorobject provided by the SAX parser. | 
| boolean | getExpandEntities()Returns whether or not entities will be expanded during the build. | 
| JDOMFactory | getFactory()Returns the factory used for constructing objects. | 
| boolean | getIgnoringBoundaryWhitespace()Returns whether or not the parser will eliminate element content
 containing only whitespace. | 
| boolean | getIgnoringElementContentWhitespace()Returns whether or not the parser will eliminate whitespace in element
 content (sometimes known as "ignorable whitespace") when building the
 document. | 
| void | ignorableWhitespace(char[] ch,
                   int start,
                   int length)Capture ignorable whitespace as text. | 
| void | internalEntityDecl(java.lang.String name,
                  java.lang.String value)Handle an internal entity declaration in a DTD. | 
| void | notationDecl(java.lang.String name,
            java.lang.String publicID,
            java.lang.String systemID)Handle the declaration of a Notation in a DTD | 
| void | processingInstruction(java.lang.String target,
                     java.lang.String data)This will indicate that a processing instruction has been encountered. | 
| protected void | pushElement(Element element)Pushes an element onto the tree under construction. | 
| void | reset()Restore this SAXHandler to a clean state ready for another parse round. | 
| protected void | resetSubCLass()Override this method if you are a subclasser, and you want to clear the
 state of your SAXHandler instance in preparation for a new parse. | 
| void | setDocumentLocator(org.xml.sax.Locator locator)Receives an object for locating the origin of SAX document events. | 
| void | setExpandEntities(boolean expand)This sets whether or not to expand entities during the build. | 
| void | setIgnoringBoundaryWhitespace(boolean ignoringBoundaryWhite)Specifies whether or not the parser should eliminate text() nodes
 containing only whitespace when building the document. | 
| void | setIgnoringElementContentWhitespace(boolean ignoringWhite)Specifies whether or not the parser should eliminate whitespace in element
 content (sometimes known as "ignorable whitespace") when building the
 document. | 
| void | skippedEntity(java.lang.String name)This indicates that an unresolvable entity reference has been
 encountered, normally because the external DTD subset has not been read. | 
| void | startCDATA()Report a CDATA section | 
| void | startDocument() | 
| void | startDTD(java.lang.String name,
        java.lang.String publicID,
        java.lang.String systemID)This will signify that a DTD is being parsed, and can be used to ensure
 that comments and other lexical structures in the DTD are not added to
 the JDOM  Documentobject. | 
| void | startElement(java.lang.String namespaceURI,
            java.lang.String localName,
            java.lang.String qName,
            org.xml.sax.Attributes atts)This reports the occurrence of an actual element. | 
| void | startEntity(java.lang.String name) | 
| void | startPrefixMapping(java.lang.String prefix,
                  java.lang.String uri)This will add the prefix mapping to the JDOM  Documentobject. | 
| void | unparsedEntityDecl(java.lang.String name,
                  java.lang.String publicID,
                  java.lang.String systemID,
                  java.lang.String notationName)Handler for unparsed entity declarations in the DTD | 
public SAXHandler()
SAXHandler that listens to SAX events
 and creates a JDOM Document. The objects will be constructed using the
 default factory.public SAXHandler(JDOMFactory factory)
SAXHandler that listens to SAX events
 and creates a JDOM Document. The objects will be constructed using the
 provided factory.factory - JDOMFactory to be used for constructing objectsprotected void resetSubCLass()
public final void reset()
protected void pushElement(Element element)
element - root element under which content will be builtpublic Document getDocument()
Document - Document that was builtpublic JDOMFactory getFactory()
JDOMFactory - the factory used for constructing
         objects.SAXHandler(org.jdom2.JDOMFactory)public void setExpandEntities(boolean expand)
EntityRef objects. The default is
 true.expand - boolean indicating whether entity expansion should
        occur.public boolean getExpandEntities()
boolean - whether entity expansion will occur during
         build.setExpandEntities(boolean)public void setIgnoringElementContentWhitespace(boolean ignoringWhite)
false.ignoringWhite - Whether to ignore ignorable whitespacepublic void setIgnoringBoundaryWhitespace(boolean ignoringBoundaryWhite)
SAXBuilder.setIgnoringBoundaryWhitespace(boolean).ignoringBoundaryWhite - Whether to ignore only whitespace contentpublic boolean getIgnoringBoundaryWhitespace()
boolean - whether only whitespace content will be
         ignored during build.setIgnoringBoundaryWhitespace(boolean)public boolean getIgnoringElementContentWhitespace()
boolean - whether ignorable whitespace will be
         ignored during build.setIgnoringElementContentWhitespace(boolean)public void startDocument()
startDocument in interface org.xml.sax.ContentHandlerstartDocument in class org.xml.sax.helpers.DefaultHandlerpublic void externalEntityDecl(java.lang.String name,
                               java.lang.String publicID,
                               java.lang.String systemID)
                        throws org.xml.sax.SAXException
externalEntityDecl in interface org.xml.sax.ext.DeclHandlername - entity namepublicID - public idsystemID - system idorg.xml.sax.SAXException - when things go wrongpublic void attributeDecl(java.lang.String eName,
                          java.lang.String aName,
                          java.lang.String type,
                          java.lang.String valueDefault,
                          java.lang.String value)
attributeDecl in interface org.xml.sax.ext.DeclHandlereName - String element name of attributeaName - String attribute nametype - String attribute typevalueDefault - String default value of attributevalue - String value of attributepublic void elementDecl(java.lang.String name,
                        java.lang.String model)
elementDecl in interface org.xml.sax.ext.DeclHandlername - String name of elementmodel - String model of the element in DTD syntaxpublic void internalEntityDecl(java.lang.String name,
                               java.lang.String value)
internalEntityDecl in interface org.xml.sax.ext.DeclHandlername - String name of entityvalue - String value of the entitypublic void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
processingInstruction in interface org.xml.sax.ContentHandlerprocessingInstruction in class org.xml.sax.helpers.DefaultHandlertarget - String target of PIdata - String containing all data sent to the PI. This
        typically looks like one or more attribute value pairs.org.xml.sax.SAXException - when things go wrongpublic void skippedEntity(java.lang.String name)
                   throws org.xml.sax.SAXException
skippedEntity in interface org.xml.sax.ContentHandlerskippedEntity in class org.xml.sax.helpers.DefaultHandlername - String name of entityorg.xml.sax.SAXException - when things go wrongpublic void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Document
 object.startPrefixMapping in interface org.xml.sax.ContentHandlerstartPrefixMapping in class org.xml.sax.helpers.DefaultHandlerprefix - String namespace prefix.uri - String namespace URI.org.xml.sax.SAXExceptionpublic void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
xmlns:[namespace prefix] and
 xsi:schemaLocation.startElement in interface org.xml.sax.ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandlernamespaceURI - String namespace URI this element is associated with,
        or an empty StringlocalName - String name of element (with no namespace prefix, if
        one is present)qName - String XML 1.0 version of element name: [namespace
        prefix]:[localName]atts - Attributes list for this elementorg.xml.sax.SAXException - when things go wrongpublic void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
characters in interface org.xml.sax.ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerch - char[] character array with character datastart - int index in array where data starts.length - int length of data.org.xml.sax.SAXExceptionpublic void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
ignorableWhitespace in interface org.xml.sax.ContentHandlerignorableWhitespace in class org.xml.sax.helpers.DefaultHandlerch - [] - char array of ignorable whitespacestart - int - starting position within arraylength - int - length of whitespace after startorg.xml.sax.SAXException - when things go wrongprotected void flushCharacters()
                        throws org.xml.sax.SAXException
org.xml.sax.SAXException - when things go wrongprotected void flushCharacters(java.lang.String data)
                        throws org.xml.sax.SAXException
data - string to flushorg.xml.sax.SAXException - if the state of the handler does not allow this.public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
</[element name]>) is
 reached. Note that the parser does not distinguish between empty elements
 and non-empty elements, so this will occur uniformly.endElement in interface org.xml.sax.ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandlernamespaceURI - String URI of namespace this element is associated
        withlocalName - String name of element without prefixqName - String name of element in XML 1.0 formorg.xml.sax.SAXException - when things go wrongpublic void startDTD(java.lang.String name,
                     java.lang.String publicID,
                     java.lang.String systemID)
              throws org.xml.sax.SAXException
Document object.startDTD in interface org.xml.sax.ext.LexicalHandlername - String name of element listed in DTDpublicID - String public ID of DTDsystemID - String system ID of DTDorg.xml.sax.SAXExceptionpublic void endDTD()
endDTD in interface org.xml.sax.ext.LexicalHandlerpublic void startEntity(java.lang.String name)
                 throws org.xml.sax.SAXException
startEntity in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXExceptionpublic void endEntity(java.lang.String name)
               throws org.xml.sax.SAXException
endEntity in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXExceptionpublic void startCDATA()
startCDATA in interface org.xml.sax.ext.LexicalHandlerpublic void endCDATA()
              throws org.xml.sax.SAXException
endCDATA in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXExceptionpublic void comment(char[] ch,
                    int start,
                    int length)
             throws org.xml.sax.SAXException
Element, or the
 Document itself if at that level.comment in interface org.xml.sax.ext.LexicalHandlerch - ch[] array of comment characters.start - int index to start reading from.length - int length of data.org.xml.sax.SAXException - if the state of the handler disallows this callpublic void notationDecl(java.lang.String name,
                         java.lang.String publicID,
                         java.lang.String systemID)
                  throws org.xml.sax.SAXException
notationDecl in interface org.xml.sax.DTDHandlernotationDecl in class org.xml.sax.helpers.DefaultHandlername - name of the notationpublicID - the public ID of the notationsystemID - the system ID of the notationorg.xml.sax.SAXExceptionpublic void unparsedEntityDecl(java.lang.String name,
                               java.lang.String publicID,
                               java.lang.String systemID,
                               java.lang.String notationName)
unparsedEntityDecl in interface org.xml.sax.DTDHandlerunparsedEntityDecl in class org.xml.sax.helpers.DefaultHandlername - String of the unparsed entity declpublicID - String of the unparsed entity declsystemID - String of the unparsed entity declnotationName - String of the unparsed entity declpublic Element getCurrentElement() throws org.xml.sax.SAXException
Element - element being built.org.xml.sax.SAXException - if the state of the handler disallows this callpublic void setDocumentLocator(org.xml.sax.Locator locator)
 JDOMFactory implementations can use the
 getDocumentLocator() method to get access to the Locator
 during parse.
 
setDocumentLocator in interface org.xml.sax.ContentHandlersetDocumentLocator in class org.xml.sax.helpers.DefaultHandlerlocator - Locator an object that can return the location of any
        SAX document event.public org.xml.sax.Locator getDocumentLocator()
Locator object provided by the SAX parser.Locator an object that can return the location of
         any SAX document event.Copyright © 2021 Jason Hunter, Brett McLaughlin. All Rights Reserved.