Interface SimpleSAXHandler<T>

  • All Known Implementing Classes:
    AbstractSimpleSAXHandler

    public interface SimpleSAXHandler<T>
    This is a simplified handler for SAX XML parsers. It can be used with a SimpleSAXParser. The handler receives XML events from a SAX parser and constructs an object of a specified type. If the parser completes without errors, the object can be obtained with getObject().
    • Method Detail

      • startElement

        void startElement​(String name,
                          Attributes atts,
                          List<String> parents)
                   throws ParseException
        Called when the start tag of a new element is found.
        Parameters:
        name - the name of the element
        atts - the attributes defined in the start tag
        parents - the parents of the new element (ending with the direct parent)
        Throws:
        ParseException - if the content is invalid
      • endElement

        void endElement​(String name,
                        List<String> parents)
                 throws ParseException
        Called when the end tag of a new element is found.
        Parameters:
        name - the name of the element
        parents - the parents of the element (ending with the direct parent)
        Throws:
        ParseException - if the content is invalid
      • characters

        void characters​(String ch,
                        List<String> parents)
                 throws ParseException
        Called when text content is found. This method is called when the text node is completed, so all consecutive characters are included in one string. It also includes all whitespace.
        Parameters:
        ch - the text
        parents - the names of the elements that are parents of the text node (ending with the direct parent)
        Throws:
        ParseException - if the content is invalid
      • getObject

        T getObject()
        Returns the object that was constructed from the XML code. This method can be called if the parser completed without errors.
        Returns:
        the object