Browse Source

-added simple respondsTo method

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@518894 13f79535-47bb-0310-9956-ffa450edef68
master
Kevin Jackson 18 years ago
parent
commit
5750c6cfc5
1 changed files with 25 additions and 1 deletions
  1. +25
    -1
      src/main/org/apache/tools/ant/util/ReflectUtil.java

+ 25
- 1
src/main/org/apache/tools/ant/util/ReflectUtil.java View File

@@ -136,4 +136,28 @@ public class ReflectUtil {
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
}
}

Loading…
Cancel
Save