On Tue, Mar 9, 2010 at 8:41 AM, Allen Yuan <[email protected]> wrote:
> Hi,
> There are some questions which I cannot understand about the method
> "getAccessibleMethod(Class clazz, Method method)" in the
> "org.apache.commons.beanutils.MethodUtils".
>
> First,what the difference between the "method" returned and the parameter
> "method"?
The purpose of getAccessibleMethod() is to return a method that is
publicly accessible (i.e. a public method in a public class) or to
return "null" if there is no publicly accessible method. If the method
is not public it returns null. The getAccessibleMethod(Class, Method)
implementation will either return the method passed to it (if its
declared in a public class) or if the class declaring it is not
public it will search the superclasses/interfaces for a public class
with that method declared as public. So for example you could have
something like the following:
public class Foo {
public void dosomething() {}
}
private class Bar extends Foo {
public void dosomething() {}
}
In this scenario whether you pass in the dosomething() method declared
in either Foo or Bar you should get the method declared in Foo
returned.
> Second,in this method if the clazz's modifier is not "public" we will search
> it's interfaces or superclass. Why?
I think I covered that above.
Niall
> I will appreciate you help very much.
>
> Allen.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]