KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > innig > macker > event > MackerEvent


1 /*______________________________________________________________________________
2  *
3  * Macker http://innig.net/macker/
4  *
5  * Copyright 2002-2003 Paul Cantrell
6  *
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License version 2, as published by the
9  * Free Software Foundation. See the file LICENSE.html for more information.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the license for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
17  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
18  *______________________________________________________________________________
19  */

20  
21 package net.innig.macker.event;
22
23 import net.innig.macker.rule.Rule;
24 import net.innig.macker.rule.RuleSeverity;
25
26 import java.util.*;
27
28 public class MackerEvent
29     extends EventObject
30     {
31     public MackerEvent(
32             Rule rule,
33             String JavaDoc description,
34             List/*<String>*/ messages)
35         {
36         super(rule);
37         this.rule = rule;
38         this.description = description;
39         this.messages = Collections.unmodifiableList(new ArrayList(messages));
40         }
41     
42     public Rule getRule()
43         { return rule; }
44         
45     public String JavaDoc getDescription()
46         { return description; }
47         
48     public List/*<String>*/ getMessages()
49         { return messages; }
50     
51     public String JavaDoc toString()
52         { return getDescription(); }
53     
54     public String JavaDoc toStringVerbose()
55         {
56         //! This is completely crappy -- the PrintingListener probably should be the one to deal with this
57
final String JavaDoc CR = System.getProperty("line.separator");
58         StringBuffer JavaDoc s = new StringBuffer JavaDoc();
59         if(rule.getSeverity() != RuleSeverity.ERROR)
60             {
61             s.append(rule.getSeverity().getName().toUpperCase());
62             s.append(": ");
63             }
64         for(Iterator i = messages.iterator(); i.hasNext(); )
65             {
66             s.append(i.next().toString());
67             s.append(CR);
68             }
69         if(getDescription() != null)
70             s.append(getDescription());
71         s.append(CR);
72         return s.toString();
73         }
74     
75     private final Rule rule;
76     private final String JavaDoc description;
77     private final List/*<String>*/ messages;
78     }
79
80
Popular Tags