You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by ke...@apache.org on 2007/03/16 10:08:12 UTC

svn commit: r518894 - /ant/core/trunk/src/main/org/apache/tools/ant/util/ReflectUtil.java

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: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org