commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niall Pemberton <niall.pember...@gmail.com>
Subject Re: questions about commons-beanutils
Date Tue, 09 Mar 2010 10:56:28 GMT
On Tue, Mar 9, 2010 at 8:41 AM, Allen Yuan <allenyuan.bit@gmail.com> 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: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message