KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > clirr > core > internal > checks > GenderChangeCheck


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.core.internal.checks;
21
22 import net.sf.clirr.core.Severity;
23 import net.sf.clirr.core.Message;
24 import net.sf.clirr.core.internal.AbstractDiffReporter;
25 import net.sf.clirr.core.internal.ApiDiffDispatcher;
26 import net.sf.clirr.core.internal.ClassChangeCheck;
27 import net.sf.clirr.core.spi.JavaType;
28
29 /**
30  * Detects gender changes (a class became an interface or vice versa).
31  *
32  * @author lkuehne
33  */

34 public final class GenderChangeCheck
35     extends AbstractDiffReporter
36     implements ClassChangeCheck
37 {
38     private static final Message MSG_GENDER_CLASS_TO_INTERFACE = new Message(2000);
39     private static final Message MSG_GENDER_INTERFACE_TO_CLASS = new Message(2001);
40
41     /**
42      * Create a new instance of this check.
43      * @param dispatcher the diff dispatcher that distributes the detected changes to the listeners.
44      */

45     public GenderChangeCheck(ApiDiffDispatcher dispatcher)
46     {
47         super(dispatcher);
48     }
49
50
51     /** {@inheritDoc} */
52     public boolean check(JavaType baseLine, JavaType current)
53     {
54         if (!baseLine.isInterface() && current.isInterface())
55         {
56             log(MSG_GENDER_CLASS_TO_INTERFACE,
57                 getSeverity(baseLine, Severity.ERROR),
58                 baseLine.getName(), null, null, null);
59         }
60         else if (baseLine.isInterface() && !current.isInterface())
61         {
62             log(MSG_GENDER_INTERFACE_TO_CLASS,
63                 getSeverity(baseLine, Severity.ERROR),
64                 baseLine.getName(), null, null, null);
65         }
66
67         return true;
68     }
69 }
70
Popular Tags