Class GenerationHelperContentHandler

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler

    public class GenerationHelperContentHandler
    extends DelegatingContentHandler
    This class is a delegating SAX ContentHandler which has the purpose to provide a few handy methods that make life easier when generating SAX events.
    • Field Detail

      • EMPTY_ATTS

        private static final org.xml.sax.Attributes EMPTY_ATTS
      • mainNamespace

        private java.lang.String mainNamespace
      • contentHandlerContext

        private java.lang.Object contentHandlerContext
    • Constructor Detail

      • GenerationHelperContentHandler

        public GenerationHelperContentHandler​(org.xml.sax.ContentHandler handler,
                                              java.lang.String mainNamespace,
                                              java.lang.Object contentHandlerContext)
        Main constructor. If the given handler also implements any of the EntityResolver, DTDHandler, LexicalHandler or ErrorHandler interfaces, these are set automatically.
        Parameters:
        handler - the SAX content handler to delegate all calls to
        mainNamespace - the main namespace used for generated XML content when abbreviated ContentHandler calls are used.
        contentHandlerContext - additional content handler context state
    • Method Detail

      • getMainNamespace

        public java.lang.String getMainNamespace()
        Returns the main namespace used for generated XML content.
        Returns:
        the main namespace
      • setMainNamespace

        public void setMainNamespace​(java.lang.String namespaceURI)
        Sets the main namespace used for generated XML content when abbreviated ContentHandler calls are used.
        Parameters:
        namespaceURI - the new main namespace URI
      • getContentHandlerContext

        public java.lang.Object getContentHandlerContext()
        Returns the context object (may be null).
        Returns:
        the context object
      • startElement

        public void startElement​(java.lang.String localName,
                                 org.xml.sax.Attributes atts)
                          throws org.xml.sax.SAXException
        Convenience method to generate a startElement SAX event.
        Parameters:
        localName - the local name of the element
        atts - the attributes
        Throws:
        org.xml.sax.SAXException - if a SAX exception occurs
      • startElement

        public void startElement​(java.lang.String localName)
                          throws org.xml.sax.SAXException
        Convenience method to generate a startElement SAX event.
        Parameters:
        localName - the local name of the element
        Throws:
        org.xml.sax.SAXException - if a SAX exception occurs
      • startElement

        public void startElement​(org.apache.xmlgraphics.util.QName qName,
                                 org.xml.sax.Attributes atts)
                          throws org.xml.sax.SAXException
        Convenience method to generate a startElement SAX event.
        Parameters:
        qName - the qualified name of the element
        atts - the attributes
        Throws:
        org.xml.sax.SAXException - if a SAX exception occurs
      • startElement

        public void startElement​(org.apache.xmlgraphics.util.QName qName)
                          throws org.xml.sax.SAXException
        Convenience method to generate a startElement SAX event.
        Parameters:
        qName - the qualified name of the element
        Throws:
        org.xml.sax.SAXException - if a SAX exception occurs
      • endElement

        public void endElement​(java.lang.String localName)
                        throws org.xml.sax.SAXException
        Convenience method to generate a endElement SAX event.
        Parameters:
        localName - the local name of the element
        Throws:
        org.xml.sax.SAXException - if a SAX exception occurs
      • endElement

        public void endElement​(org.apache.xmlgraphics.util.QName qName)
                        throws org.xml.sax.SAXException
        Convenience method to generate a startElement SAX event.
        Parameters:
        qName - the qualified name of the element
        Throws:
        org.xml.sax.SAXException - if a SAX exception occurs
      • element

        public void element​(java.lang.String localName,
                            org.xml.sax.Attributes atts)
                     throws org.xml.sax.SAXException
        Convenience method to generate an empty element with attributes.
        Parameters:
        localName - the local name of the element
        atts - the attributes
        Throws:
        org.xml.sax.SAXException - if a SAX exception occurs
      • element

        public void element​(org.apache.xmlgraphics.util.QName qName,
                            org.xml.sax.Attributes atts)
                     throws org.xml.sax.SAXException
        Convenience method to generate an empty element with attributes.
        Parameters:
        qName - the qualified name of the element
        atts - the attributes
        Throws:
        org.xml.sax.SAXException - if a SAX exception occurs