1 package xdoclet.retest.util; 2 3 import xdoclet.XDocletException; 4 5 import java.lang.reflect.Method ; 6 import java.util.List ; 7 import java.util.ArrayList ; 8 import java.util.StringTokenizer ; 9 10 15 public abstract class AbstractComparator 16 { 17 18 protected ComparisonResultSet resultSet; 19 20 public abstract ComparisonResultSet compare() 21 throws XDocletException; 22 23 public String shortClassName(Class clazz) 24 { 25 String name = clazz.getName(); 26 StringTokenizer st = new StringTokenizer (name,"."); 27 String ret = name; 28 while (st.hasMoreTokens()) ret = st.nextToken(); 29 return ret.trim(); 30 } 31 32 public String shortMethodName(Method method) 33 { 34 String name = "[" + shortClassName(method.getReturnType()) + "] " + method.getName() + "(" ; 35 Class [] 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 [] 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 |