1 18 package org.apache.geronimo.interop.util; 19 20 import java.lang.reflect.Constructor ; 21 import java.lang.reflect.Method ; 22 import java.util.ArrayList ; 23 import java.util.Iterator ; 24 25 26 public class ExceptionList extends ArrayList { 27 public ExceptionList() { 28 } 29 30 public ExceptionList(Constructor template) { 31 Class [] types = template.getExceptionTypes(); 32 add(types); 33 } 34 35 public ExceptionList(Method template) { 36 Class [] types = template.getExceptionTypes(); 37 add(types); 38 } 39 40 public ExceptionList(Class [] types) { 41 add(types); 42 } 43 44 public void add(Class [] types) { 45 int n = types.length; 46 for (int i = 0; i < n; i++) { 47 Class type = types[i]; 48 if (ExceptionUtil.isUserException(type)) { 49 add(type); 50 } 51 } 52 } 53 54 public ExceptionList add(String type) { 55 super.add(type); 56 return this; 57 } 58 59 public ExceptionList add(Class type) { 60 return add(JavaType.getName(type)); 61 } 62 63 public String toString() { 64 if (size() == 0) { 65 return ""; 66 } 67 StringBuffer sb = new StringBuffer (" throws "); 68 int comma = 0; 69 for (Iterator i = iterator(); i.hasNext(); comma++) { 70 String type = (String ) i.next(); 71 if (comma > 0) { 72 sb.append(", "); 73 } 74 sb.append(type); 75 } 76 return sb.toString(); 77 } 78 } 79 | Popular Tags |