KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > clirr > ant > ChangeCounter


1 //////////////////////////////////////////////////////////////////////////////
2
// Clirr: compares two versions of a java library for binary compatibility
3
// Copyright (C) 2003 - 2005 Lars Kühne
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

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
27 final class ChangeCounter extends DiffListenerAdapter
28 {
29     private int binInfos = 0;
30     private int binWarnings = 0;
31     private int binErrors = 0;
32
33     private int srcInfos = 0;
34     private int srcWarnings = 0;
35     private int srcErrors = 0;
36
37
38     public ChangeCounter()
39     {
40     }
41
42     public int getBinInfos()
43     {
44         return binInfos;
45     }
46
47     public int getBinWarnings()
48     {
49         return binWarnings;
50     }
51
52     public int getBinErrors()
53     {
54         return binErrors;
55     }
56
57     public int getSrcInfos()
58     {
59         return srcInfos;
60     }
61
62     public int getSrcWarnings()
63     {
64         return srcWarnings;
65     }
66
67     public int getSrcErrors()
68     {
69         return srcErrors;
70     }
71
72     public void reportDiff(ApiDifference difference)
73     {
74         final Severity binSeverity = difference.getBinaryCompatibilitySeverity();
75         if (Severity.ERROR.equals(binSeverity))
76         {
77             binErrors += 1;
78         }
79         else if (Severity.WARNING.equals(binSeverity))
80         {
81             binWarnings += 1;
82         }
83         else if (Severity.INFO.equals(binSeverity))
84         {
85             binInfos += 1;
86         }
87
88         final Severity srcSeverity = difference.getSourceCompatibilitySeverity();
89         if (Severity.ERROR.equals(srcSeverity))
90         {
91             srcErrors += 1;
92         }
93         else if (Severity.WARNING.equals(srcSeverity))
94         {
95             srcWarnings += 1;
96         }
97         else if (Severity.INFO.equals(srcSeverity))
98         {
99             srcInfos += 1;
100         }
101
102     }
103
104 }
105
Popular Tags