Java Doc for MethodUtils.java in  » Library » Apache-commons-beanutils-1.8.0-BETA-src » org » apache » commons » beanutils » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache commons beanutils 1.8.0 BETA src » org.apache.commons.beanutils 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.beanutils.MethodUtils

MethodUtils
public class MethodUtils (Code)

Utility reflection methods focussed on methods in general rather than properties in particular.

Known Limitations

Accessing Public Methods In A Default Access Superclass

There is an issue when invoking public methods contained in a default access superclass. Reflection locates these methods fine and correctly assigns them as public. However, an IllegalAccessException is thrown if the method is invoked.

MethodUtils contains a workaround for this situation. It will attempt to call setAccessible on this method. If this call succeeds, then the method can be invoked as normal. This call will only succeed when the application has sufficient security privilages. If this call fails then a warning will be logged and the method may fail.


author:
   Craig R. McClanahan
author:
   Ralph Schaer
author:
   Chris Audley
author:
   Rey François
author:
   Gregor Raýman
author:
   Jan Sorensen
author:
   Robert Burrell Donkin




Method Summary
public static  MethodgetAccessibleMethod(Class clazz, String methodName, Class parameterType)
    

Return an accessible method (that is, one that can be invoked via reflection) with given name and a single parameter.

public static  MethodgetAccessibleMethod(Class clazz, String methodName, Class[] parameterTypes)
    

Return an accessible method (that is, one that can be invoked via reflection) with given name and parameters.

public static  MethodgetAccessibleMethod(Method method)
    

Return an accessible method (that is, one that can be invoked via reflection) that implements the specified Method.

public static  MethodgetMatchingAccessibleMethod(Class clazz, String methodName, Class[] parameterTypes)
    

Find an accessible method that matches the given name and has compatible parameters.

public static  ClassgetPrimitiveType(Class wrapperType)
     Gets the class for the primitive type corresponding to the primitive wrapper class given. For example, an instance of Boolean.class returns a boolean.class.
public static  ClassgetPrimitiveWrapper(Class primitiveType)
     Gets the wrapper object class for the given primitive type class.
public static  ObjectinvokeExactMethod(Object object, String methodName, Object arg)
    

Invoke a method whose parameter type matches exactly the object type.

This is a convenient wrapper for MethodUtils.invokeExactMethod(Object object,String methodName,Object[] args) .

public static  ObjectinvokeExactMethod(Object object, String methodName, Object[] args)
    
public static  ObjectinvokeExactMethod(Object object, String methodName, Object[] args, Class[] parameterTypes)
    
public static  ObjectinvokeExactStaticMethod(Class objectClass, String methodName, Object[] args, Class[] parameterTypes)
    
public static  ObjectinvokeExactStaticMethod(Class objectClass, String methodName, Object arg)
    

Invoke a static method whose parameter type matches exactly the object type.

This is a convenient wrapper for MethodUtils.invokeExactStaticMethod(Class objectClass,String methodName,Object[] args) .

public static  ObjectinvokeExactStaticMethod(Class objectClass, String methodName, Object[] args)
    
public static  ObjectinvokeMethod(Object object, String methodName, Object arg)
    

Invoke a named method whose parameter type matches the object type.

The behaviour of this method is less deterministic than invokeExactMethod(). It loops through all methods with names that match and then executes the first it finds with compatable parameters.

This method supports calls to methods taking primitive parameters via passing in wrapping classes.

public static  ObjectinvokeMethod(Object object, String methodName, Object[] args)
    

Invoke a named method whose parameter type matches the object type.

The behaviour of this method is less deterministic than MethodUtils.invokeExactMethod(Object object,String methodName,Object[] args) .

public static  ObjectinvokeMethod(Object object, String methodName, Object[] args, Class[] parameterTypes)
    

Invoke a named method whose parameter type matches the object type.

The behaviour of this method is less deterministic than MethodUtils.invokeExactMethod(Object object,String methodName,Object[] args,Class[] parameterTypes) .

public static  ObjectinvokeStaticMethod(Class objectClass, String methodName, Object arg)
    

Invoke a named static method whose parameter type matches the object type.

The behaviour of this method is less deterministic than MethodUtils.invokeExactMethod(Object,String,Object[],Class[]) .

public static  ObjectinvokeStaticMethod(Class objectClass, String methodName, Object[] args)
    

Invoke a named static method whose parameter type matches the object type.

The behaviour of this method is less deterministic than MethodUtils.invokeExactMethod(Object object,String methodName,Object[] args) .

public static  ObjectinvokeStaticMethod(Class objectClass, String methodName, Object[] args, Class[] parameterTypes)
    

Invoke a named static method whose parameter type matches the object type.

The behaviour of this method is less deterministic than MethodUtils.invokeExactStaticMethod(Class objectClass,String methodName,Object[] args,Class[] parameterTypes) .

final public static  booleanisAssignmentCompatible(Class parameterType, Class parameterization)
    

Determine whether a type can be used as a parameter in a method invocation.

public static  ClasstoNonPrimitiveClass(Class clazz)
     Find a non primitive representation for given primitive class.
Parameters:
  clazz - the class to find a representation for, not null the original class if it not a primitive.



Method Detail
getAccessibleMethod
public static Method getAccessibleMethod(Class clazz, String methodName, Class parameterType)(Code)

Return an accessible method (that is, one that can be invoked via reflection) with given name and a single parameter. If no such method can be found, return null. Basically, a convenience wrapper that constructs a Class array for you.


Parameters:
  clazz - get method from this class
Parameters:
  methodName - get method with this name
Parameters:
  parameterType - taking this type of parameter The accessible method



getAccessibleMethod
public static Method getAccessibleMethod(Class clazz, String methodName, Class[] parameterTypes)(Code)

Return an accessible method (that is, one that can be invoked via reflection) with given name and parameters. If no such method can be found, return null. This is just a convenient wrapper for MethodUtils.getAccessibleMethod(Method method) .


Parameters:
  clazz - get method from this class
Parameters:
  methodName - get method with this name
Parameters:
  parameterTypes - with these parameters types The accessible method



getAccessibleMethod
public static Method getAccessibleMethod(Method method)(Code)

Return an accessible method (that is, one that can be invoked via reflection) that implements the specified Method. If no such method can be found, return null.


Parameters:
  method - The method that we wish to call The accessible method



getMatchingAccessibleMethod
public static Method getMatchingAccessibleMethod(Class clazz, String methodName, Class[] parameterTypes)(Code)

Find an accessible method that matches the given name and has compatible parameters. Compatible parameters mean that every method parameter is assignable from the given parameters. In other words, it finds a method with the given name that will take the parameters given.

This method is slightly undeterminstic since it loops through methods names and return the first matching method.

This method is used by MethodUtils.invokeMethod(Object object,String methodName,Object[] args,Class[] parameterTypes) .

This method can match primitive parameter by passing in wrapper classes. For example, a Boolean will match a primitive boolean parameter.
Parameters:
  clazz - find method in this class
Parameters:
  methodName - find method with this name
Parameters:
  parameterTypes - find method with compatible parameters The accessible method




getPrimitiveType
public static Class getPrimitiveType(Class wrapperType)(Code)
Gets the class for the primitive type corresponding to the primitive wrapper class given. For example, an instance of Boolean.class returns a boolean.class.
Parameters:
  wrapperType - the the primitive type class corresponding to the given wrapper class,null if no match is found



getPrimitiveWrapper
public static Class getPrimitiveWrapper(Class primitiveType)(Code)
Gets the wrapper object class for the given primitive type class. For example, passing boolean.class returns Boolean.class
Parameters:
  primitiveType - the primitive type class for which a match is to be found the wrapper type associated with the given primitive or null if no match is found



invokeExactMethod
public static Object invokeExactMethod(Object object, String methodName, Object arg) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException(Code)

Invoke a method whose parameter type matches exactly the object type.

This is a convenient wrapper for MethodUtils.invokeExactMethod(Object object,String methodName,Object[] args) .


Parameters:
  object - invoke method on this object
Parameters:
  methodName - get method with this name
Parameters:
  arg - use this argument The value returned by the invoked method
throws:
  NoSuchMethodException - if there is no such accessible method
throws:
  InvocationTargetException - wraps an exception thrown by themethod invoked
throws:
  IllegalAccessException - if the requested method is not accessiblevia reflection



invokeExactMethod
public static Object invokeExactMethod(Object object, String methodName, Object[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException(Code)

Invoke a method whose parameter types match exactly the object types.

This uses reflection to invoke the method obtained from a call to getAccessibleMethod().


Parameters:
  object - invoke method on this object
Parameters:
  methodName - get method with this name
Parameters:
  args - use these arguments - treat null as empty array The value returned by the invoked method
throws:
  NoSuchMethodException - if there is no such accessible method
throws:
  InvocationTargetException - wraps an exception thrown by themethod invoked
throws:
  IllegalAccessException - if the requested method is not accessiblevia reflection



invokeExactMethod
public static Object invokeExactMethod(Object object, String methodName, Object[] args, Class[] parameterTypes) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException(Code)

Invoke a method whose parameter types match exactly the parameter types given.

This uses reflection to invoke the method obtained from a call to getAccessibleMethod().


Parameters:
  object - invoke method on this object
Parameters:
  methodName - get method with this name
Parameters:
  args - use these arguments - treat null as empty array
Parameters:
  parameterTypes - match these parameters - treat null as empty array The value returned by the invoked method
throws:
  NoSuchMethodException - if there is no such accessible method
throws:
  InvocationTargetException - wraps an exception thrown by themethod invoked
throws:
  IllegalAccessException - if the requested method is not accessiblevia reflection



invokeExactStaticMethod
public static Object invokeExactStaticMethod(Class objectClass, String methodName, Object[] args, Class[] parameterTypes) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException(Code)

Invoke a static method whose parameter types match exactly the parameter types given.

This uses reflection to invoke the method obtained from a call to MethodUtils.getAccessibleMethod(Class,String,Class[]) .


Parameters:
  objectClass - invoke static method on this class
Parameters:
  methodName - get method with this name
Parameters:
  args - use these arguments - treat null as empty array
Parameters:
  parameterTypes - match these parameters - treat null as empty array The value returned by the invoked method
throws:
  NoSuchMethodException - if there is no such accessible method
throws:
  InvocationTargetException - wraps an exception thrown by themethod invoked
throws:
  IllegalAccessException - if the requested method is not accessiblevia reflection



invokeExactStaticMethod
public static Object invokeExactStaticMethod(Class objectClass, String methodName, Object arg) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException(Code)

Invoke a static method whose parameter type matches exactly the object type.

This is a convenient wrapper for MethodUtils.invokeExactStaticMethod(Class objectClass,String methodName,Object[] args) .


Parameters:
  objectClass - invoke static method on this class
Parameters:
  methodName - get method with this name
Parameters:
  arg - use this argument The value returned by the invoked method
throws:
  NoSuchMethodException - if there is no such accessible method
throws:
  InvocationTargetException - wraps an exception thrown by themethod invoked
throws:
  IllegalAccessException - if the requested method is not accessiblevia reflection



invokeExactStaticMethod
public static Object invokeExactStaticMethod(Class objectClass, String methodName, Object[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException(Code)

Invoke a static method whose parameter types match exactly the object types.

This uses reflection to invoke the method obtained from a call to MethodUtils.getAccessibleMethod(Class,String,Class[]) .


Parameters:
  objectClass - invoke static method on this class
Parameters:
  methodName - get method with this name
Parameters:
  args - use these arguments - treat null as empty array The value returned by the invoked method
throws:
  NoSuchMethodException - if there is no such accessible method
throws:
  InvocationTargetException - wraps an exception thrown by themethod invoked
throws:
  IllegalAccessException - if the requested method is not accessiblevia reflection



invokeMethod
public static Object invokeMethod(Object object, String methodName, Object arg) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException(Code)

Invoke a named method whose parameter type matches the object type.

The behaviour of this method is less deterministic than invokeExactMethod(). It loops through all methods with names that match and then executes the first it finds with compatable parameters.

This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a Boolean class would match a boolean primitive.

This is a convenient wrapper for MethodUtils.invokeMethod(Object object,String methodName,Object[] args) .


Parameters:
  object - invoke method on this object
Parameters:
  methodName - get method with this name
Parameters:
  arg - use this argument The value returned by the invoked method
throws:
  NoSuchMethodException - if there is no such accessible method
throws:
  InvocationTargetException - wraps an exception thrown by themethod invoked
throws:
  IllegalAccessException - if the requested method is not accessiblevia reflection



invokeMethod
public static Object invokeMethod(Object object, String methodName, Object[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException(Code)

Invoke a named method whose parameter type matches the object type.

The behaviour of this method is less deterministic than MethodUtils.invokeExactMethod(Object object,String methodName,Object[] args) . It loops through all methods with names that match and then executes the first it finds with compatable parameters.

This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a Boolean class would match a boolean primitive.

This is a convenient wrapper for MethodUtils.invokeMethod(Object object,String methodName,Object[] args,Class[] parameterTypes) .


Parameters:
  object - invoke method on this object
Parameters:
  methodName - get method with this name
Parameters:
  args - use these arguments - treat null as empty array The value returned by the invoked method
throws:
  NoSuchMethodException - if there is no such accessible method
throws:
  InvocationTargetException - wraps an exception thrown by themethod invoked
throws:
  IllegalAccessException - if the requested method is not accessiblevia reflection



invokeMethod
public static Object invokeMethod(Object object, String methodName, Object[] args, Class[] parameterTypes) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException(Code)

Invoke a named method whose parameter type matches the object type.

The behaviour of this method is less deterministic than MethodUtils.invokeExactMethod(Object object,String methodName,Object[] args,Class[] parameterTypes) . It loops through all methods with names that match and then executes the first it finds with compatable parameters.

This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a Boolean class would match a boolean primitive.


Parameters:
  object - invoke method on this object
Parameters:
  methodName - get method with this name
Parameters:
  args - use these arguments - treat null as empty array
Parameters:
  parameterTypes - match these parameters - treat null as empty array The value returned by the invoked method
throws:
  NoSuchMethodException - if there is no such accessible method
throws:
  InvocationTargetException - wraps an exception thrown by themethod invoked
throws:
  IllegalAccessException - if the requested method is not accessiblevia reflection



invokeStaticMethod
public static Object invokeStaticMethod(Class objectClass, String methodName, Object arg) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException(Code)

Invoke a named static method whose parameter type matches the object type.

The behaviour of this method is less deterministic than MethodUtils.invokeExactMethod(Object,String,Object[],Class[]) . It loops through all methods with names that match and then executes the first it finds with compatable parameters.

This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a Boolean class would match a boolean primitive.

This is a convenient wrapper for MethodUtils.invokeStaticMethod(Class objectClass,String methodName,Object[] args) .


Parameters:
  objectClass - invoke static method on this class
Parameters:
  methodName - get method with this name
Parameters:
  arg - use this argument The value returned by the invoked method
throws:
  NoSuchMethodException - if there is no such accessible method
throws:
  InvocationTargetException - wraps an exception thrown by themethod invoked
throws:
  IllegalAccessException - if the requested method is not accessiblevia reflection



invokeStaticMethod
public static Object invokeStaticMethod(Class objectClass, String methodName, Object[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException(Code)

Invoke a named static method whose parameter type matches the object type.

The behaviour of this method is less deterministic than MethodUtils.invokeExactMethod(Object object,String methodName,Object[] args) . It loops through all methods with names that match and then executes the first it finds with compatable parameters.

This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a Boolean class would match a boolean primitive.

This is a convenient wrapper for MethodUtils.invokeStaticMethod(Class objectClass,String methodName,Object[] args,Class[] parameterTypes) .


Parameters:
  objectClass - invoke static method on this class
Parameters:
  methodName - get method with this name
Parameters:
  args - use these arguments - treat null as empty array The value returned by the invoked method
throws:
  NoSuchMethodException - if there is no such accessible method
throws:
  InvocationTargetException - wraps an exception thrown by themethod invoked
throws:
  IllegalAccessException - if the requested method is not accessiblevia reflection



invokeStaticMethod
public static Object invokeStaticMethod(Class objectClass, String methodName, Object[] args, Class[] parameterTypes) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException(Code)

Invoke a named static method whose parameter type matches the object type.

The behaviour of this method is less deterministic than MethodUtils.invokeExactStaticMethod(Class objectClass,String methodName,Object[] args,Class[] parameterTypes) . It loops through all methods with names that match and then executes the first it finds with compatable parameters.

This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a Boolean class would match a boolean primitive.


Parameters:
  objectClass - invoke static method on this class
Parameters:
  methodName - get method with this name
Parameters:
  args - use these arguments - treat null as empty array
Parameters:
  parameterTypes - match these parameters - treat null as empty array The value returned by the invoked method
throws:
  NoSuchMethodException - if there is no such accessible method
throws:
  InvocationTargetException - wraps an exception thrown by themethod invoked
throws:
  IllegalAccessException - if the requested method is not accessiblevia reflection



isAssignmentCompatible
final public static boolean isAssignmentCompatible(Class parameterType, Class parameterization)(Code)

Determine whether a type can be used as a parameter in a method invocation. This method handles primitive conversions correctly.

In order words, it will match a Boolean to a boolean, a Long to a long, a Float to a float, a Integer to a int, and a Double to a double. Now logic widening matches are allowed. For example, a Long will not match a int.
Parameters:
  parameterType - the type of parameter accepted by the method
Parameters:
  parameterization - the type of parameter being tested true if the assignement is compatible.




toNonPrimitiveClass
public static Class toNonPrimitiveClass(Class clazz)(Code)
Find a non primitive representation for given primitive class.
Parameters:
  clazz - the class to find a representation for, not null the original class if it not a primitive. Otherwise the wrapper class. Not null



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.