Class XMLFileHandler

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

    class XMLFileHandler
    extends org.xml.sax.helpers.DefaultHandler
    A content handler for document containing Log4J events logged using the XMLLayout class. It will create events and add them to a supplied model.
    Version:
    1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.StringBuffer mBuf
      buffer for collecting text
      private java.lang.String mCategoryName
      the category of the event
      private Level mLevel
      the priority (level) of the event
      private java.lang.String mLocationDetails
      the location details for the event
      private java.lang.String mMessage
      the msg for the event
      private MyTableModel mModel
      where to put the events
      private java.lang.String mNDC
      the NDC for the event
      private int mNumEvents
      the number of events in the document
      private java.lang.String mThreadName
      the thread for the event
      private java.lang.String[] mThrowableStrRep
      the throwable details the event
      private long mTimeStamp
      the time of the event
      private static java.lang.String TAG_EVENT
      represents the event tag
      private static java.lang.String TAG_LOCATION_INFO
      represents the location info tag
      private static java.lang.String TAG_MESSAGE
      represents the message tag
      private static java.lang.String TAG_NDC
      represents the ndc tag
      private static java.lang.String TAG_THROWABLE
      represents the throwable tag
    • Constructor Summary

      Constructors 
      Constructor Description
      XMLFileHandler​(MyTableModel aModel)
      Creates a new XMLFileHandler instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void addEvent()
      Add an event to the model
      void characters​(char[] aChars, int aStart, int aLength)  
      void endElement​(java.lang.String aNamespaceURI, java.lang.String aLocalName, java.lang.String aQName)  
      (package private) int getNumEvents()  
      private void resetData()
      Reset the data for an event
      void startDocument()  
      void startElement​(java.lang.String aNamespaceURI, java.lang.String aLocalName, java.lang.String aQName, org.xml.sax.Attributes aAtts)  
      • Methods inherited from class org.xml.sax.helpers.DefaultHandler

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

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

      • TAG_EVENT

        private static final java.lang.String TAG_EVENT
        represents the event tag
        See Also:
        Constant Field Values
      • TAG_MESSAGE

        private static final java.lang.String TAG_MESSAGE
        represents the message tag
        See Also:
        Constant Field Values
      • TAG_NDC

        private static final java.lang.String TAG_NDC
        represents the ndc tag
        See Also:
        Constant Field Values
      • TAG_THROWABLE

        private static final java.lang.String TAG_THROWABLE
        represents the throwable tag
        See Also:
        Constant Field Values
      • TAG_LOCATION_INFO

        private static final java.lang.String TAG_LOCATION_INFO
        represents the location info tag
        See Also:
        Constant Field Values
      • mModel

        private final MyTableModel mModel
        where to put the events
      • mNumEvents

        private int mNumEvents
        the number of events in the document
      • mTimeStamp

        private long mTimeStamp
        the time of the event
      • mLevel

        private Level mLevel
        the priority (level) of the event
      • mCategoryName

        private java.lang.String mCategoryName
        the category of the event
      • mNDC

        private java.lang.String mNDC
        the NDC for the event
      • mThreadName

        private java.lang.String mThreadName
        the thread for the event
      • mMessage

        private java.lang.String mMessage
        the msg for the event
      • mThrowableStrRep

        private java.lang.String[] mThrowableStrRep
        the throwable details the event
      • mLocationDetails

        private java.lang.String mLocationDetails
        the location details for the event
      • mBuf

        private final java.lang.StringBuffer mBuf
        buffer for collecting text
    • Constructor Detail

      • XMLFileHandler

        XMLFileHandler​(MyTableModel aModel)
        Creates a new XMLFileHandler instance.
        Parameters:
        aModel - where to add the events
    • Method Detail

      • startDocument

        public void startDocument()
                           throws org.xml.sax.SAXException
        Specified by:
        startDocument in interface org.xml.sax.ContentHandler
        Overrides:
        startDocument in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
        See Also:
        DefaultHandler
      • characters

        public void characters​(char[] aChars,
                               int aStart,
                               int aLength)
        Specified by:
        characters in interface org.xml.sax.ContentHandler
        Overrides:
        characters in class org.xml.sax.helpers.DefaultHandler
        See Also:
        DefaultHandler
      • endElement

        public void endElement​(java.lang.String aNamespaceURI,
                               java.lang.String aLocalName,
                               java.lang.String aQName)
        Specified by:
        endElement in interface org.xml.sax.ContentHandler
        Overrides:
        endElement in class org.xml.sax.helpers.DefaultHandler
        See Also:
        DefaultHandler
      • startElement

        public void startElement​(java.lang.String aNamespaceURI,
                                 java.lang.String aLocalName,
                                 java.lang.String aQName,
                                 org.xml.sax.Attributes aAtts)
        Specified by:
        startElement in interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class org.xml.sax.helpers.DefaultHandler
        See Also:
        DefaultHandler
      • getNumEvents

        int getNumEvents()
        Returns:
        the number of events in the document
      • addEvent

        private void addEvent()
        Add an event to the model
      • resetData

        private void resetData()
        Reset the data for an event