Author: kevj Date: Fri Mar 16 02:08:12 2007 New Revision: 518894 URL: http://svn.apache.org/viewvc?view=rev&rev=518894 Log: -added simple respondsTo method
Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/ReflectUtil.java Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/ReflectUtil.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/ReflectUtil.java?view=diff&rev=518894&r1=518893&r2=518894 ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/util/ReflectUtil.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/util/ReflectUtil.java Fri Mar 16 02:08:12 2007 @@ -136,4 +136,28 @@ throw new BuildException(t); } } -} + + /** + * A method to test if an object responds to a given + * message (method call) + * @param o the object + * @param methodName the method to check for + * @return + * @throws BuildException + */ + public static boolean resondsTo(Object o, String methodName) + throws BuildException { + try { + Method[] methods = o.getClass().getMethods(); + for(int i=0; i<methods.length; i++) { + if(methods[i].getName() == methodName) { + return true; + } + } + return false; + } catch(Exception t) { + throwBuildException(t); + } + return false;//not reached + } +} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]