You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Néstor Boscán <ne...@tcs.com.ve> on 2005/03/12 03:07:12 UTC

How to get a Method from the method description

Hi
 
I need a way to take a method description (Ex: "java.lang.Math.abs (int)",
"java.lang.String.equals (Object)") and get the Method object. Is there a
way to do this with Collection Bean?
 
Thanks

Re: How to get a Method from the method description

Posted by Simon Kitching <sk...@apache.org>.
On Fri, 2005-03-11 at 22:07 -0400, Néstor Boscán wrote:
> Hi
>  
> I need a way to take a method description (Ex: "java.lang.Math.abs (int)",
> "java.lang.String.equals (Object)") and get the Method object. Is there a
> way to do this with Collection Bean?

I don't know of any feature in the commons-beanutils library (or any
other commons library) to do this.

However if you get any Method object and call its "toString" method,
then this returns the method signature in a string format. I believe
this string format is standard, ie won't change across different JVMs
(though you should check this). So you could do:
 * convert your string description into the standard format
 * for each method in the object
    * if method.toString().equals(signature_to_match)
       * .....

Try obtaining some Method objects and calling toString to see what the
output format looks like...

If that doesn't achieve what you want, you might look at bcel
(jakarta.apache.org/bcel) or ASM (http://asm.objectweb.org/).

Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org