Java Doc for BeanUtils.java in  » J2EE » spring-framework-2.0.6 » org » springframework » beans » 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 » J2EE » spring framework 2.0.6 » org.springframework.beans 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.beans.BeanUtils

BeanUtils
abstract public class BeanUtils (Code)
Static convenience methods for JavaBeans: for instantiating beans, checking bean property types, copying bean properties, etc.

Mainly for use within the framework, but to some degree also useful for application classes.
author:
   Rod Johnson
author:
   Juergen Hoeller
author:
   Rob Harrop





Method Summary
public static  voidcopyProperties(Object source, Object target)
     Copy the property values of the given source bean into the target bean.

Note: The source and target classes do not have to match or even be derived from each other, as long as the properties match.

public static  voidcopyProperties(Object source, Object target, Class editable)
     Copy the property values of the given source bean into the given target bean, only setting properties defined in the given "editable" class (or interface).

Note: The source and target classes do not have to match or even be derived from each other, as long as the properties match.

public static  voidcopyProperties(Object source, Object target, String[] ignoreProperties)
     Copy the property values of the given source bean into the given target bean, ignoring the given "ignoreProperties".

Note: The source and target classes do not have to match or even be derived from each other, as long as the properties match.

public static  MethodfindDeclaredMethod(Class clazz, String methodName, Class[] paramTypes)
     Find a method with the given method name and the given parameter types, declared on the given class or one of its superclasses.
public static  MethodfindDeclaredMethodWithMinimalParameters(Class clazz, String methodName)
     Find a method with the given method name and minimal parameters (best case: none), declared on the given class or one of its superclasses.
public static  MethodfindMethod(Class clazz, String methodName, Class[] paramTypes)
     Find a method with the given method name and the given parameter types, declared on the given class or one of its superclasses.
public static  MethodfindMethodWithMinimalParameters(Class clazz, String methodName)
     Find a method with the given method name and minimal parameters (best case: none), declared on the given class or one of its superclasses.
public static  PropertyDescriptorfindPropertyForMethod(Method method)
     Find a JavaBeans PropertyDescriptor for the given method, with the method either being the read method or the write method for that bean property.
public static  ClassfindPropertyType(String propertyName, Class[] beanClasses)
     Determine the bean property type for the given property from the given classes/interfaces, if possible.
public static  PropertyDescriptorgetPropertyDescriptor(Class clazz, String propertyName)
     Retrieve the JavaBeans PropertyDescriptors for the given property.
public static  PropertyDescriptor[]getPropertyDescriptors(Class clazz)
     Retrieve the JavaBeans PropertyDescriptors of a given class.
public static  ObjectinstantiateClass(Class clazz)
     Convenience method to instantiate a class using its no-arg constructor.
public static  ObjectinstantiateClass(Constructor ctor, Object[] args)
     Convenience method to instantiate a class using the given constructor.
public static  booleanisAssignable(Class targetType, Class valueType)
     Determine if the given target type is assignable from the given value type, assuming setting by reflection.
public static  booleanisAssignable(Class type, Object value)
     Determine if the given type is assignable from the given value, assuming setting by reflection.
public static  booleanisSimpleProperty(Class clazz)
     Check if the given type represents a "simple" property: a primitive, a String, a Class, or a corresponding array.
public static  MethodresolveSignature(String signature, Class clazz)
     Parse a method signature in the form methodName[([arg_list])], where arg_list is an optional, comma-separated list of fully-qualified type names, and attempts to resolve that signature against the supplied Class.

When not supplying an argument list (methodName) the method whose name matches and has the least number of parameters will be returned.




Method Detail
copyProperties
public static void copyProperties(Object source, Object target) throws BeansException(Code)
Copy the property values of the given source bean into the target bean.

Note: The source and target classes do not have to match or even be derived from each other, as long as the properties match. Any bean properties that the source bean exposes but the target bean does not will silently be ignored.

This is just a convenience method. For more complex transfer needs, consider using a full BeanWrapper.
Parameters:
  source - the source bean
Parameters:
  target - the target bean
throws:
  BeansException - if the copying failed
See Also:   BeanWrapper




copyProperties
public static void copyProperties(Object source, Object target, Class editable) throws BeansException(Code)
Copy the property values of the given source bean into the given target bean, only setting properties defined in the given "editable" class (or interface).

Note: The source and target classes do not have to match or even be derived from each other, as long as the properties match. Any bean properties that the source bean exposes but the target bean does not will silently be ignored.

This is just a convenience method. For more complex transfer needs, consider using a full BeanWrapper.
Parameters:
  source - the source bean
Parameters:
  target - the target bean
Parameters:
  editable - the class (or interface) to restrict property setting to
throws:
  BeansException - if the copying failed
See Also:   BeanWrapper




copyProperties
public static void copyProperties(Object source, Object target, String[] ignoreProperties) throws BeansException(Code)
Copy the property values of the given source bean into the given target bean, ignoring the given "ignoreProperties".

Note: The source and target classes do not have to match or even be derived from each other, as long as the properties match. Any bean properties that the source bean exposes but the target bean does not will silently be ignored.

This is just a convenience method. For more complex transfer needs, consider using a full BeanWrapper.
Parameters:
  source - the source bean
Parameters:
  target - the target bean
Parameters:
  ignoreProperties - array of property names to ignore
throws:
  BeansException - if the copying failed
See Also:   BeanWrapper




findDeclaredMethod
public static Method findDeclaredMethod(Class clazz, String methodName, Class[] paramTypes)(Code)
Find a method with the given method name and the given parameter types, declared on the given class or one of its superclasses. Will return a public, protected, package access, or private method.

Checks Class.getDeclaredMethod, cascading upwards to all superclasses.
Parameters:
  clazz - the class to check
Parameters:
  methodName - the name of the method to find
Parameters:
  paramTypes - the parameter types of the method to find the Method object, or null if not found
See Also:   java.lang.Class.getDeclaredMethod




findDeclaredMethodWithMinimalParameters
public static Method findDeclaredMethodWithMinimalParameters(Class clazz, String methodName) throws IllegalArgumentException(Code)
Find a method with the given method name and minimal parameters (best case: none), declared on the given class or one of its superclasses. Will return a public, protected, package access, or private method.

Checks Class.getDeclaredMethods, cascading upwards to all superclasses.
Parameters:
  clazz - the class to check
Parameters:
  methodName - the name of the method to find the Method object, or null if not found
throws:
  IllegalArgumentException - if methods of the given name were found butcould not be resolved to a unique method with minimal parameters
See Also:   java.lang.Class.getDeclaredMethods




findMethod
public static Method findMethod(Class clazz, String methodName, Class[] paramTypes)(Code)
Find a method with the given method name and the given parameter types, declared on the given class or one of its superclasses. Prefers public methods, but will return a protected, package access, or private method too.

Checks Class.getMethod first, falling back to findDeclaredMethod. This allows to find public methods without issues even in environments with restricted Java security settings.
Parameters:
  clazz - the class to check
Parameters:
  methodName - the name of the method to find
Parameters:
  paramTypes - the parameter types of the method to find the Method object, or null if not found
See Also:   java.lang.Class.getMethod
See Also:   BeanUtils.findDeclaredMethod




findMethodWithMinimalParameters
public static Method findMethodWithMinimalParameters(Class clazz, String methodName) throws IllegalArgumentException(Code)
Find a method with the given method name and minimal parameters (best case: none), declared on the given class or one of its superclasses. Prefers public methods, but will return a protected, package access, or private method too.

Checks Class.getMethods first, falling back to findDeclaredMethodWithMinimalParameters. This allows to find public methods without issues even in environments with restricted Java security settings.
Parameters:
  clazz - the class to check
Parameters:
  methodName - the name of the method to find the Method object, or null if not found
throws:
  IllegalArgumentException - if methods of the given name were found butcould not be resolved to a unique method with minimal parameters
See Also:   java.lang.Class.getMethods
See Also:   BeanUtils.findDeclaredMethodWithMinimalParameters




findPropertyForMethod
public static PropertyDescriptor findPropertyForMethod(Method method) throws BeansException(Code)
Find a JavaBeans PropertyDescriptor for the given method, with the method either being the read method or the write method for that bean property.
Parameters:
  method - the method to find a corresponding PropertyDescriptor for the corresponding PropertyDescriptor, or null if none
throws:
  BeansException - if PropertyDescriptor lookup fails



findPropertyType
public static Class findPropertyType(String propertyName, Class[] beanClasses)(Code)
Determine the bean property type for the given property from the given classes/interfaces, if possible.
Parameters:
  propertyName - the name of the bean property
Parameters:
  beanClasses - the classes to check against the property type, or Object.class as fallback



getPropertyDescriptor
public static PropertyDescriptor getPropertyDescriptor(Class clazz, String propertyName) throws BeansException(Code)
Retrieve the JavaBeans PropertyDescriptors for the given property.
Parameters:
  clazz - the Class to retrieve the PropertyDescriptor for
Parameters:
  propertyName - the name of the property the corresponding PropertyDescriptor, or null if none
throws:
  BeansException - if PropertyDescriptor lookup fails



getPropertyDescriptors
public static PropertyDescriptor[] getPropertyDescriptors(Class clazz) throws BeansException(Code)
Retrieve the JavaBeans PropertyDescriptors of a given class.
Parameters:
  clazz - the Class to retrieve the PropertyDescriptors for an array of PropertyDescriptors for the given class
throws:
  BeansException - if PropertyDescriptor look fails



instantiateClass
public static Object instantiateClass(Class clazz) throws BeanInstantiationException(Code)
Convenience method to instantiate a class using its no-arg constructor. As this method doesn't try to load classes by name, it should avoid class-loading issues.

Note that this method tries to set the constructor accessible if given a non-accessible (that is, non-public) constructor.
Parameters:
  clazz - class to instantiate the new instance
throws:
  BeanInstantiationException - if the bean cannot be instantiated




instantiateClass
public static Object instantiateClass(Constructor ctor, Object[] args) throws BeanInstantiationException(Code)
Convenience method to instantiate a class using the given constructor. As this method doesn't try to load classes by name, it should avoid class-loading issues.

Note that this method tries to set the constructor accessible if given a non-accessible (that is, non-public) constructor.
Parameters:
  ctor - the constructor to instantiate
Parameters:
  args - the constructor arguments to apply the new instance
throws:
  BeanInstantiationException - if the bean cannot be instantiated




isAssignable
public static boolean isAssignable(Class targetType, Class valueType)(Code)
Determine if the given target type is assignable from the given value type, assuming setting by reflection. Considers primitive wrapper classes as assignable to the corresponding primitive types.
Parameters:
  targetType - the target type
Parameters:
  valueType - the value type that should be assigned to the target type if the target type is assignable from the value type
See Also:   org.springframework.util.ClassUtils.isAssignable(ClassClass)



isAssignable
public static boolean isAssignable(Class type, Object value)(Code)
Determine if the given type is assignable from the given value, assuming setting by reflection. Considers primitive wrapper classes as assignable to the corresponding primitive types.
Parameters:
  type - the target type
Parameters:
  value - the value that should be assigned to the type if the type is assignable from the value
See Also:   org.springframework.util.ClassUtils.isAssignableValue(ClassObject)



isSimpleProperty
public static boolean isSimpleProperty(Class clazz)(Code)
Check if the given type represents a "simple" property: a primitive, a String, a Class, or a corresponding array.

Used to determine properties to check for a "simple" dependency-check.
Parameters:
  clazz - the type to check whether the given type represent a "simple" property
See Also:   org.springframework.beans.factory.support.RootBeanDefinition.DEPENDENCY_CHECK_SIMPLE
See Also:   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.checkDependencies




resolveSignature
public static Method resolveSignature(String signature, Class clazz)(Code)
Parse a method signature in the form methodName[([arg_list])], where arg_list is an optional, comma-separated list of fully-qualified type names, and attempts to resolve that signature against the supplied Class.

When not supplying an argument list (methodName) the method whose name matches and has the least number of parameters will be returned. When supplying an argument type list, only the method whose name and argument types match will be returned.

Note then that methodName and methodName() are not resolved in the same way. The signature methodName means the method called methodName with the least number of arguments, whereas methodName() means the method called methodName with exactly 0 arguments.

If no method can be found, then null is returned.
Parameters:
  signature - the method signature as String representation
Parameters:
  clazz - the class to resolve the method signature against the resolved Method
See Also:   BeanUtils.findMethod
See Also:   BeanUtils.findMethodWithMinimalParameters




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.