/** * Returns the first method that matches the specified name and parameter types. The overriding methods have priority. * The method is chosen from all the methods of the current class and all its superclasses and superinterfaces. * @return the matching method or null if no matching method has been found. */ protected static Method getMethod(Class target, String methodName, Class[] types) { if(types == null) types=new Class[0]; Method[] methods = getAllMethods(target); methods: for(int i = 0; i < methods.length; i++) { Method m= methods[i]; if(!methodName.equals(m.getName())) continue; Class[] parameters = m.getParameterTypes(); if (types.length != parameters.length) { continue; } for(int j = 0; j < types.length; j++) { if(!parameters[j].isAssignableFrom(types[j])) { continue methods; } } return m; } return null; }
/** Called by the ProbeHandler impl. All args are strings. Needs to find a method where all parameter * types are primitive types, so the strings can be converted */ public static Method findMethod(Class target_class, String method_name, Object[] args) throws Exception { int len=args != null? args.length : 0; Method retval=null; Method[] methods=getAllMethods(target_class); for(int i=0; i < methods.length; i++) { Method m=methods[i]; if(m.getName().equals(method_name)) { Class<?>[] parameter_types=m.getParameterTypes(); if(parameter_types.length == len) { retval=m; // now check if all parameter types are primitive types: boolean all_primitive=true; for(Class<?> parameter_type: parameter_types) { if(!isPrimitiveType(parameter_type)) { all_primitive=false; break; } } if(all_primitive) return m; } } } return retval; }
if(interfaces != null) { for(Class cl: interfaces) { Method[] tmp=getAllMethods(cl); if(tmp != null) { for(Method mm: tmp)
/** * * @param target_class * @return * @throws Exception */ Method findMethod(Class target_class) throws Exception { int len=args != null? args.length : 0; Method m; Method[] methods=getAllMethods(target_class); for(int i=0; i < methods.length; i++) { m=methods[i]; if(m.getName().equals(method_name)) { if(m.getParameterTypes().length == len) return m; } } return null; }
/** * Returns the first method that matches the specified name and parameter types. The overriding methods have priority. * The method is chosen from all the methods of the current class and all its superclasses and superinterfaces. * @return the matching method or null if no matching method has been found. */ protected static Method getMethod(Class target, String methodName, Class[] types) { if(types == null) types=new Class[0]; Method[] methods = getAllMethods(target); methods: for(int i = 0; i < methods.length; i++) { Method m= methods[i]; if(!methodName.equals(m.getName())) continue; Class[] parameters = m.getParameterTypes(); if (types.length != parameters.length) { continue; } for(int j = 0; j < types.length; j++) { if(!parameters[j].isAssignableFrom(types[j])) { continue methods; } } return m; } return null; }
/** * Returns the first method that matches the specified name and parameter types. The overriding * methods have priority. The method is chosen from all the methods of the current class and all * its superclasses and superinterfaces. * * @return the matching method or null if no mathching method has been found. */ Method getMethod(Class target, String methodName, Class[] types) { if (types == null) { types = new Class[0]; } Method[] methods = getAllMethods(target); methods: for(int i = 0; i < methods.length; i++) { Method m = methods[i]; if (!methodName.equals(m.getName())) { continue; } Class[] parameters = m.getParameterTypes(); if (types.length != parameters.length) { continue; } for(int j = 0; j < types.length; j++) { if (!types[j].equals(parameters[j])) { continue methods; } } return m; } return null; }
/** Called by the ProbeHandler impl. All args are strings. Needs to find a method where all parameter * types are primitive types, so the strings can be converted */ public static Method findMethod(Class target_class, String method_name, Object[] args) throws Exception { int len=args != null? args.length : 0; Method retval=null; Method[] methods=getAllMethods(target_class); for(int i=0; i < methods.length; i++) { Method m=methods[i]; if(m.getName().equals(method_name)) { Class<?>[] parameter_types=m.getParameterTypes(); if(parameter_types.length == len) { retval=m; // now check if all parameter types are primitive types: boolean all_primitive=true; for(Class<?> parameter_type: parameter_types) { if(!isPrimitiveType(parameter_type)) { all_primitive=false; break; } } if(all_primitive) return m; } } } return retval; }
if(interfaces != null) { for(Class cl: interfaces) { Method[] tmp=getAllMethods(cl); if(tmp != null) { for(Method mm: tmp)