KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > api > AuditEvent


1 ////////////////////////////////////////////////////////////////////////////////
2
// checkstyle: Checks Java source code for adherence to a set of rules.
3
// Copyright (C) 2001-2005 Oliver Burn
4
//
5
// This library is free software; you can redistribute it and/or
6
// modify it under the terms of the GNU Lesser General Public
7
// License as published by the Free Software Foundation; either
8
// version 2.1 of the License, or (at your option) any later version.
9
//
10
// This library is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
// Lesser General Public License for more details.
14
//
15
// You should have received a copy of the GNU Lesser General Public
16
// License along with this library; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
////////////////////////////////////////////////////////////////////////////////
19
package com.puppycrawl.tools.checkstyle.api;
20
21 import java.util.EventObject JavaDoc;
22
23
24 /**
25  * Raw event for audit.
26  * <p>
27  * <i>
28  * I'm not very satisfied about the design of this event since there are
29  * optional methods that will return null in most of the case. This will
30  * need some work to clean it up especially if we want to introduce
31  * a more sequential reporting action rather than a packet error
32  * reporting. This will allow for example to follow the process quickly
33  * in an interface or a servlet (yep, that's cool to run a check via
34  * a web interface in a source repository ;-)
35  * </i>
36  * @author <a HREF="mailto:stephane.bailliez@wanadoo.fr">Stephane Bailliez</a>
37  * @see AuditListener
38  */

39 public final class AuditEvent
40     extends EventObject JavaDoc
41 {
42     /** filename event associated with **/
43     private final String JavaDoc mFileName;
44     /** message associated with the event **/
45     private final LocalizedMessage mMessage;
46
47     /**
48      * Creates a new instance.
49      * @param aSource the object that created the event
50      */

51     public AuditEvent(Object JavaDoc aSource)
52     {
53         this(aSource, null);
54     }
55
56     /**
57      * Creates a new <code>AuditEvent</code> instance.
58      * @param aSrc source of the event
59      * @param aFileName file associated with the event
60      */

61     public AuditEvent(Object JavaDoc aSrc, String JavaDoc aFileName)
62     {
63         this(aSrc, aFileName, null);
64     }
65
66     /**
67      * Creates a new <code>AuditEvent</code> instance.
68      *
69      * @param aSrc source of the event
70      * @param aFileName file associated with the event
71      * @param aMessage the actual message
72      */

73     public AuditEvent(Object JavaDoc aSrc, String JavaDoc aFileName, LocalizedMessage aMessage)
74     {
75         super(aSrc);
76         mFileName = aFileName;
77         mMessage = aMessage;
78     }
79
80     /**
81      * @return the file name currently being audited or null if there is
82      * no relation to a file.
83      */

84     public String JavaDoc getFileName()
85     {
86         return mFileName;
87     }
88
89     /**
90      * return the line number on the source file where the event occurred.
91      * This may be 0 if there is no relation to a file content.
92      * @return an integer representing the line number in the file source code.
93      */

94     public int getLine()
95     {
96         return mMessage.getLineNo();
97     }
98
99     /**
100      * return the message associated to the event.
101      * @return the event message
102      */

103     public String JavaDoc getMessage()
104     {
105         return mMessage.getMessage();
106     }
107
108     /** @return the column associated with the message **/
109     public int getColumn()
110     {
111         return mMessage.getColumnNo();
112     }
113
114     /** @return the audit event severity level **/
115     public SeverityLevel getSeverityLevel()
116     {
117         return (mMessage == null)
118             ? SeverityLevel.INFO
119             : mMessage.getSeverityLevel();
120     }
121
122     /**
123      * @return the identifier of the module that generated the event. Can return
124      * null.
125      */

126     public String JavaDoc getModuleId()
127     {
128         return mMessage.getModuleId();
129     }
130
131     /** @return the name of the source for the message **/
132     public String JavaDoc getSourceName()
133     {
134         return mMessage.getSourceName();
135     }
136
137     /** @return the localized message **/
138     public LocalizedMessage getLocalizedMessage()
139     {
140         return mMessage;
141     }
142 }
143
Popular Tags