public class BeanUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
BeanUtil.DataPair
DataPair
Entry for Map<:String, Object>
|
| Modifier and Type | Field and Description |
|---|---|
static Object[] |
NO_ARGS
Static empty Object array to represent no parameters in reflection method call
|
| Constructor and Description |
|---|
BeanUtil() |
| Modifier and Type | Method and Description |
|---|---|
static com.googlecode.openbeans.BeanInfo |
getBeanInfo(Object bean)
Gets the
BeanInfo object which contains the information of
the properties, events and methods of the specified bean class. |
static Set<BeanUtil.DataPair> |
getDataPairSet(Object bean)
Returns bean properties as an Entry Set
|
static Object |
invoke(Method method,
Object receiver,
Object... args)
Returns the result of dynamically invoking this method.
|
static Object |
newClassInstance(String className)
Returns Object of specified class name
|
public static final Object[] NO_ARGS
public static Object invoke(Method method, Object receiver, Object... args) throws BeanException
receiver.methodName(arg1, arg2, ... , argN).
If the method is static, the receiver argument is ignored (and may be null).
If the method takes no arguments, you can pass (Object[]) null instead of
allocating an empty array.
If you're calling a varargs method, you need to pass an Object[] for the
varargs parameter: that conversion is usually done in javac, not the VM, and
the reflection machinery does not do this for you. (It couldn't, because it would be
ambiguous.)
Reflective method invocation follows the usual process for method lookup.
If an exception is thrown during the invocation it is caught and wrapped in an InvocationTargetException. This exception is then thrown.
If the invocation completes normally, the return value itself is returned. If the method is declared to return a primitive type, the return value is boxed. If the return type is void, null is returned.
method - the method to invokereceiver - the object on which to call this method (or null for static methods)args - the arguments to the methodBeanException - if this method is not accessible
if the number of arguments doesn't match the number of parameters, the receiver
is incompatible with the declaring class, or an argument could not be unboxed
or converted by a widening conversion to the corresponding parameter type
if an exception was thrown by the invoked methodpublic static com.googlecode.openbeans.BeanInfo getBeanInfo(Object bean)
BeanInfo object which contains the information of
the properties, events and methods of the specified bean class.
The Introspector will cache the BeanInfo
object. Subsequent calls to this method will be answered with the cached
data.
bean - The specified bean class.BeanInfo of the bean class.BeanExceptionpublic static Set<BeanUtil.DataPair> getDataPairSet(Object bean)
bean - The specified bean class.public static Object newClassInstance(String className)
className - BeanException - if class not found, failed to instantiate or security violatedThis documentation is licensed by Andrew Bowley under the GPLv3 License.