Class FlattenMojo.SaxHeaderCommentHandler

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.ext.EntityResolver2, org.xml.sax.ext.LexicalHandler
    Enclosing class:
    FlattenMojo

    private class FlattenMojo.SaxHeaderCommentHandler
    extends org.xml.sax.ext.DefaultHandler2
    This class is a simple SAX handler that extracts the first comment located before the root tag in an XML document.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String headerComment  
      private boolean rootTagSeen
      true if root tag has already been visited, false otherwise.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void comment​(char[] ch, int start, int length)
      java.lang.String getHeaderComment()  
      void startElement​(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attrs)
      • Methods inherited from class org.xml.sax.ext.DefaultHandler2

        attributeDecl, elementDecl, endCDATA, endDTD, endEntity, externalEntityDecl, getExternalSubset, internalEntityDecl, resolveEntity, resolveEntity, startCDATA, startDTD, startEntity
      • Methods inherited from class org.xml.sax.helpers.DefaultHandler

        characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • rootTagSeen

        private boolean rootTagSeen
        true if root tag has already been visited, false otherwise.
    • Constructor Detail

      • SaxHeaderCommentHandler

        SaxHeaderCommentHandler()
        The constructor.
    • Method Detail

      • getHeaderComment

        public java.lang.String getHeaderComment()
        Returns:
        the XML comment from the header of the document or null if not present.
      • comment

        public void comment​(char[] ch,
                            int start,
                            int length)
        Specified by:
        comment in interface org.xml.sax.ext.LexicalHandler
        Overrides:
        comment in class org.xml.sax.ext.DefaultHandler2
      • startElement

        public void startElement​(java.lang.String uri,
                                 java.lang.String localName,
                                 java.lang.String qName,
                                 org.xml.sax.Attributes attrs)
        Specified by:
        startElement in interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class org.xml.sax.helpers.DefaultHandler