01: /*
02: * Hammurapi
03: * Automated Java code review system.
04: * Copyright (C) 2004 Hammurapi Group
05: *
06: * This program is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU General Public License as published by
08: * the Free Software Foundation; either version 2 of the License, or
09: * (at your option) any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: *
20: * URL: http://www.hammurapi.org
21: * e-Mail: support@hammurapi.biz
22: */
23:
24: package org.hammurapi.results.simple;
25:
26: import java.io.Serializable;
27: import java.util.Collection;
28: import java.util.LinkedList;
29: import java.util.List;
30:
31: import org.hammurapi.HammurapiException;
32: import org.hammurapi.Violation;
33: import org.hammurapi.Waiver;
34: import org.hammurapi.WaiverEntry;
35: import org.hammurapi.WaiverSet;
36: import org.hammurapi.results.DetailedResults;
37:
38: /**
39: *
40: * @author Pavel Vlasov
41: * @version $Revision: 1.2 $
42: */
43: public class SimpleDetailedResults extends SimpleNamedResults implements
44: DetailedResults {
45: /**
46: * Comment for <code>serialVersionUID</code>
47: */
48: private static final long serialVersionUID = 4368844541348791240L;
49: private List violations = new LinkedList();
50: private List waivedViolations = new LinkedList();
51: private List incompleteMessages = new LinkedList();
52:
53: SimpleDetailedResults(String name, WaiverSet waiverSet) {
54: super (name, waiverSet);
55: }
56:
57: public Waiver addViolation(final Violation violation)
58: throws HammurapiException {
59: final Waiver waiver = super .addViolation(violation);
60: if (waiver == null) {
61: violations.add(violation);
62: } else {
63: waivedViolations.add(new WaiverEntry() {
64: /**
65: * Comment for <code>serialVersionUID</code>
66: */
67: private static final long serialVersionUID = -6057980823743605352L;
68:
69: public Waiver getWaiver() {
70: return waiver;
71: }
72:
73: public Violation getViolation() {
74: return violation;
75: }
76: });
77: }
78: return waiver;
79: }
80:
81: public Collection getViolations() {
82: return violations;
83:
84: }
85:
86: public int getViolationsNumber() {
87: return violations.size() + super .getViolationsNumber();
88: }
89:
90: public Collection getWaivedViolations() {
91: return waivedViolations;
92: }
93:
94: }
|