1 22 package org.jboss.aop.util; 23 24 import java.lang.reflect.Method ; 25 import java.util.ArrayList ; 26 27 32 public class ReflectUtils 33 { 34 public static Class [] EMPTY_CLASS_ARRAY = new Class [0]; 35 36 public static Method [] getMethodsWithName(Class clazz, String name) 37 { 38 Method [] methods = clazz.getMethods(); 39 return getMethodsWithName(methods, name); 40 } 41 42 public static Method [] getDeclaredMethodsWithName(Class clazz, String name) 43 { 44 Method [] methods = clazz.getDeclaredMethods(); 45 return getMethodsWithName(methods, name); 46 } 47 48 private static Method [] getMethodsWithName(Method [] methods, String name) 49 { 50 ArrayList foundMethods = new ArrayList (); 51 for (int i = 0 ; i < methods.length ; i++) 52 { 53 if (methods[i].getName().equals(name)) 54 { 55 foundMethods.add(methods[i]); 56 } 57 } 58 return (Method [])foundMethods.toArray(new Method [foundMethods.size()]); 59 } 60 61 } 62 | Popular Tags |