KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > log4j > chainsaw > EventDetails


1 /*
2  * Copyright 1999-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.log4j.chainsaw;
17
18 import org.apache.log4j.Priority;
19 import org.apache.log4j.spi.LoggingEvent;
20
21 /**
22  * Represents the details of a logging event. It is intended to overcome the
23  * problem that a LoggingEvent cannot be constructed with purely fake data.
24  *
25  * @author <a HREF="mailto:oliver@puppycrawl.com">Oliver Burn</a>
26  * @version 1.0
27  */

28 class EventDetails {
29
30     /** the time of the event **/
31     private final long mTimeStamp;
32     /** the priority of the event **/
33     private final Priority mPriority;
34     /** the category of the event **/
35     private final String JavaDoc mCategoryName;
36     /** the NDC for the event **/
37     private final String JavaDoc mNDC;
38     /** the thread for the event **/
39     private final String JavaDoc mThreadName;
40     /** the msg for the event **/
41     private final String JavaDoc mMessage;
42     /** the throwable details the event **/
43     private final String JavaDoc[] mThrowableStrRep;
44     /** the location details for the event **/
45     private final String JavaDoc mLocationDetails;
46
47     /**
48      * Creates a new <code>EventDetails</code> instance.
49      * @param aTimeStamp a <code>long</code> value
50      * @param aPriority a <code>Priority</code> value
51      * @param aCategoryName a <code>String</code> value
52      * @param aNDC a <code>String</code> value
53      * @param aThreadName a <code>String</code> value
54      * @param aMessage a <code>String</code> value
55      * @param aThrowableStrRep a <code>String[]</code> value
56      * @param aLocationDetails a <code>String</code> value
57      */

58     EventDetails(long aTimeStamp,
59                  Priority aPriority,
60                  String JavaDoc aCategoryName,
61                  String JavaDoc aNDC,
62                  String JavaDoc aThreadName,
63                  String JavaDoc aMessage,
64                  String JavaDoc[] aThrowableStrRep,
65                  String JavaDoc aLocationDetails)
66     {
67         mTimeStamp = aTimeStamp;
68         mPriority = aPriority;
69         mCategoryName = aCategoryName;
70         mNDC = aNDC;
71         mThreadName = aThreadName;
72         mMessage = aMessage;
73         mThrowableStrRep = aThrowableStrRep;
74         mLocationDetails = aLocationDetails;
75     }
76
77     /**
78      * Creates a new <code>EventDetails</code> instance.
79      *
80      * @param aEvent a <code>LoggingEvent</code> value
81      */

82     EventDetails(LoggingEvent aEvent) {
83
84         this(aEvent.timeStamp,
85              aEvent.getLevel(),
86              aEvent.getLoggerName(),
87              aEvent.getNDC(),
88              aEvent.getThreadName(),
89              aEvent.getRenderedMessage(),
90              aEvent.getThrowableStrRep(),
91              (aEvent.getLocationInformation() == null)
92              ? null : aEvent.getLocationInformation().fullInfo);
93     }
94
95     /** @see #mTimeStamp **/
96     long getTimeStamp() {
97         return mTimeStamp;
98     }
99
100     /** @see #mPriority **/
101     Priority getPriority() {
102         return mPriority;
103     }
104
105     /** @see #mCategoryName **/
106     String JavaDoc getCategoryName() {
107         return mCategoryName;
108     }
109
110     /** @see #mNDC **/
111     String JavaDoc getNDC() {
112         return mNDC;
113     }
114
115     /** @see #mThreadName **/
116     String JavaDoc getThreadName() {
117         return mThreadName;
118     }
119
120     /** @see #mMessage **/
121     String JavaDoc getMessage() {
122         return mMessage;
123     }
124
125     /** @see #mLocationDetails **/
126     String JavaDoc getLocationDetails(){
127         return mLocationDetails;
128     }
129
130     /** @see #mThrowableStrRep **/
131     String JavaDoc[] getThrowableStrRep() {
132         return mThrowableStrRep;
133     }
134 }
135
Popular Tags