ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject svn commit: r518894 - /ant/core/trunk/src/main/org/apache/tools/ant/util/ReflectUtil.java
Date Fri, 16 Mar 2007 09:08:12 GMT
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


Mime
View raw message