KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > retest > util > AbstractComparator


1 package xdoclet.retest.util;
2
3 import xdoclet.XDocletException;
4
5 import java.lang.reflect.Method JavaDoc;
6 import java.util.List JavaDoc;
7 import java.util.ArrayList JavaDoc;
8 import java.util.StringTokenizer JavaDoc;
9
10 /**
11  * @author Vincent Harcq (vincent.harcq@hubmethods.com)
12  * @created Mars 5, 2002
13  * @version $Revision: 1.2 $
14  */

15 public abstract class AbstractComparator
16 {
17
18     protected ComparisonResultSet resultSet;
19
20     public abstract ComparisonResultSet compare()
21     throws XDocletException;
22
23     public String JavaDoc shortClassName(Class JavaDoc clazz)
24     {
25         String JavaDoc name = clazz.getName();
26         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(name,".");
27         String JavaDoc ret = name;
28         while (st.hasMoreTokens()) ret = st.nextToken();
29         return ret.trim();
30     }
31
32     public String JavaDoc shortMethodName(Method JavaDoc method)
33     {
34         String JavaDoc name = "[" + shortClassName(method.getReturnType()) + "] " + method.getName() + "(" ;
35         Class JavaDoc[] params = method.getParameterTypes();
36         for (int i = 0; i< params.length;i++)
37         {
38             name += shortClassName(params[i]);
39             if ( i < params.length - 1) name += ",";
40         }
41         name += ") E{";
42         Class JavaDoc[] es = method.getExceptionTypes();
43         for (int i = 0; i< es.length;i++)
44         {
45             name += shortClassName(es[i]);
46             if ( i < es.length - 1) name += ",";
47         }
48         name += "}";
49         return name.trim();
50     }
51
52 }
53
Popular Tags