01: //////////////////////////////////////////////////////////////////////////////
02: // Clirr: compares two versions of a java library for binary compatibility
03: // Copyright (C) 2003 - 2005 Lars Kühne
04: //
05: // This library is free software; you can redistribute it and/or
06: // modify it under the terms of the GNU Lesser General Public
07: // License as published by the Free Software Foundation; either
08: // version 2.1 of the License, or (at your option) any later version.
09: //
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:
20: package net.sf.clirr.ant;
21:
22: import net.sf.clirr.core.ApiDifference;
23: import net.sf.clirr.core.Severity;
24: import net.sf.clirr.core.DiffListenerAdapter;
25:
26: final class ChangeCounter extends DiffListenerAdapter {
27: private int binInfos = 0;
28: private int binWarnings = 0;
29: private int binErrors = 0;
30:
31: private int srcInfos = 0;
32: private int srcWarnings = 0;
33: private int srcErrors = 0;
34:
35: public ChangeCounter() {
36: }
37:
38: public int getBinInfos() {
39: return binInfos;
40: }
41:
42: public int getBinWarnings() {
43: return binWarnings;
44: }
45:
46: public int getBinErrors() {
47: return binErrors;
48: }
49:
50: public int getSrcInfos() {
51: return srcInfos;
52: }
53:
54: public int getSrcWarnings() {
55: return srcWarnings;
56: }
57:
58: public int getSrcErrors() {
59: return srcErrors;
60: }
61:
62: public void reportDiff(ApiDifference difference) {
63: final Severity binSeverity = difference
64: .getBinaryCompatibilitySeverity();
65: if (Severity.ERROR.equals(binSeverity)) {
66: binErrors += 1;
67: } else if (Severity.WARNING.equals(binSeverity)) {
68: binWarnings += 1;
69: } else if (Severity.INFO.equals(binSeverity)) {
70: binInfos += 1;
71: }
72:
73: final Severity srcSeverity = difference
74: .getSourceCompatibilitySeverity();
75: if (Severity.ERROR.equals(srcSeverity)) {
76: srcErrors += 1;
77: } else if (Severity.WARNING.equals(srcSeverity)) {
78: srcWarnings += 1;
79: } else if (Severity.INFO.equals(srcSeverity)) {
80: srcInfos += 1;
81: }
82:
83: }
84:
85: }
|