01: /*______________________________________________________________________________
02: *
03: * Macker http://innig.net/macker/
04: *
05: * Copyright 2002-2003 Paul Cantrell
06: *
07: * This program is free software; you can redistribute it and/or modify it under
08: * the terms of the GNU General Public License version 2, as published by the
09: * 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 extends EventObject {
29: public MackerEvent(Rule rule, String description,
30: List/*<String>*/messages) {
31: super (rule);
32: this .rule = rule;
33: this .description = description;
34: this .messages = Collections.unmodifiableList(new ArrayList(
35: messages));
36: }
37:
38: public Rule getRule() {
39: return rule;
40: }
41:
42: public String getDescription() {
43: return description;
44: }
45:
46: public List/*<String>*/getMessages() {
47: return messages;
48: }
49:
50: public String toString() {
51: return getDescription();
52: }
53:
54: public String toStringVerbose() {
55: //! This is completely crappy -- the PrintingListener probably should be the one to deal with this
56: final String CR = System.getProperty("line.separator");
57: StringBuffer s = new StringBuffer();
58: if (rule.getSeverity() != RuleSeverity.ERROR) {
59: s.append(rule.getSeverity().getName().toUpperCase());
60: s.append(": ");
61: }
62: for (Iterator i = messages.iterator(); i.hasNext();) {
63: s.append(i.next().toString());
64: s.append(CR);
65: }
66: if (getDescription() != null)
67: s.append(getDescription());
68: s.append(CR);
69: return s.toString();
70: }
71:
72: private final Rule rule;
73: private final String description;
74: private final List/*<String>*/messages;
75: }
|