oburn       02/05/29 04:54:24

  Modified:    src/java/org/apache/log4j/chainsaw Tag: v1_2-branch
                        XMLFileHandler.java
  Log:
  PR: 9435
  Brought down changes made on the mainline to support Xerces and Crimson.
  Now support the updated version of the log4j.dtd as requested by Ceki.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.1   +21 -28    
jakarta-log4j/src/java/org/apache/log4j/chainsaw/XMLFileHandler.java
  
  Index: XMLFileHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/XMLFileHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- XMLFileHandler.java       2 May 2002 11:25:49 -0000       1.2
  +++ XMLFileHandler.java       29 May 2002 11:54:24 -0000      1.2.2.1
  @@ -37,12 +37,10 @@
       private final MyTableModel mModel;
       /** the number of events in the document **/
       private int mNumEvents;
  -    /** the current element being parsed **/
  -    private String mCurrentElement;
   
       /** the time of the event **/
       private long mTimeStamp;
  -    /** the priority of the event **/
  +    /** the priority (level) of the event **/
       private Priority mPriority;
       /** the category of the event **/
       private String mCategoryName;
  @@ -56,7 +54,8 @@
       private String[] mThrowableStrRep;
       /** the location details for the event **/
       private String mLocationDetails;
  -
  +    /** buffer for collecting text **/
  +    private final StringBuffer mBuf = new StringBuffer();
   
       /**
        * Creates a new <code>XMLFileHandler</code> instance.
  @@ -76,21 +75,7 @@
   
       /** @see DefaultHandler **/
       public void characters(char[] aChars, int aStart, int aLength) {
  -        if (mCurrentElement == TAG_NDC) {
  -            mNDC = new String(aChars, aStart, aLength);
  -        } else if (mCurrentElement == TAG_MESSAGE) {
  -            mMessage = new String(aChars, aStart, aLength);
  -        } else if (mCurrentElement == TAG_THROWABLE) {
  -            final StringTokenizer st =
  -                new StringTokenizer(new String(aChars, aStart, aLength), "\t");
  -            mThrowableStrRep = new String[st.countTokens()];
  -            if (mThrowableStrRep.length > 0) {
  -                mThrowableStrRep[0] = st.nextToken();
  -                for (int i = 1; i < mThrowableStrRep.length; i++) {
  -                    mThrowableStrRep[i] = "\t" + st.nextToken();
  -                }
  -            }
  -        }
  +        mBuf.append(String.valueOf(aChars, aStart, aLength));
       }
   
       /** @see DefaultHandler **/
  @@ -101,8 +86,20 @@
           if (TAG_EVENT.equals(aQName)) {
               addEvent();
               resetData();
  -        } else if (mCurrentElement != TAG_EVENT) {
  -            mCurrentElement = TAG_EVENT; // hack - but only thing I care about
  +        } else if (TAG_NDC.equals(aQName)) {
  +            mNDC = mBuf.toString();
  +        } else if (TAG_MESSAGE.equals(aQName)) {
  +            mMessage = mBuf.toString();
  +        } else if (TAG_THROWABLE.equals(aQName)) {
  +            final StringTokenizer st =
  +                new StringTokenizer(mBuf.toString(), "\n\t");
  +            mThrowableStrRep = new String[st.countTokens()];
  +            if (mThrowableStrRep.length > 0) {
  +                mThrowableStrRep[0] = st.nextToken();
  +                for (int i = 1; i < mThrowableStrRep.length; i++) {
  +                    mThrowableStrRep[i] = "\t" + st.nextToken();
  +                }
  +            }
           }
       }
   
  @@ -112,22 +109,18 @@
                                String aQName,
                                Attributes aAtts)
       {
  +        mBuf.setLength(0);
  +
           if (TAG_EVENT.equals(aQName)) {
               mThreadName = aAtts.getValue("thread");
               mTimeStamp = Long.parseLong(aAtts.getValue("timestamp"));
  -            mCategoryName = aAtts.getValue("category");
  +            mCategoryName = aAtts.getValue("logger");
               mPriority = Priority.toPriority(aAtts.getValue("level"));
           } else if (TAG_LOCATION_INFO.equals(aQName)) {
               mLocationDetails = aAtts.getValue("class") + "."
                   + aAtts.getValue("method")
                   + "(" + aAtts.getValue("file") + ":" + aAtts.getValue("line")
                   + ")";
  -        } else if (TAG_NDC.equals(aQName)) {
  -            mCurrentElement = TAG_NDC;
  -        } else if (TAG_MESSAGE.equals(aQName)) {
  -            mCurrentElement = TAG_MESSAGE;
  -        } else if (TAG_THROWABLE.equals(aQName)) {
  -            mCurrentElement = TAG_THROWABLE;
           }
       }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to