Java Doc for BeanProcessor.java in  » Database-JDBC-Connection-Pool » Database-Utilities » org » apache » commons » dbutils » 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 » Database JDBC Connection Pool » Database Utilities » org.apache.commons.dbutils 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.dbutils.BeanProcessor

BeanProcessor
public class BeanProcessor (Code)

BeanProcessor matches column names to bean property names and converts ResultSet columns into objects for those bean properties. Subclasses should override the methods in the processing chain to customize behavior.

This class is thread-safe.


See Also:   BasicRowProcessor
since:
   DbUtils 1.1


Field Summary
final protected static  intPROPERTY_NOT_FOUND
     Special array value used by mapColumnsToProperties that indicates there is no bean property that matches a column from a ResultSet.

Constructor Summary
public  BeanProcessor()
     Constructor for BeanProcessor.

Method Summary
protected  int[]mapColumnsToProperties(ResultSetMetaData rsmd, PropertyDescriptor[] props)
     The positions in the returned array represent column numbers.
protected  ObjectnewInstance(Class c)
     Factory method that returns a new instance of the given Class.
protected  ObjectprocessColumn(ResultSet rs, int index, Class propType)
     Convert a ResultSet column into an object.
public  ObjecttoBean(ResultSet rs, Class type)
     Convert a ResultSet row into a JavaBean.
public  ListtoBeanList(ResultSet rs, Class type)
     Convert a ResultSet into a List of JavaBeans.

Field Detail
PROPERTY_NOT_FOUND
final protected static int PROPERTY_NOT_FOUND(Code)
Special array value used by mapColumnsToProperties that indicates there is no bean property that matches a column from a ResultSet.




Constructor Detail
BeanProcessor
public BeanProcessor()(Code)
Constructor for BeanProcessor.




Method Detail
mapColumnsToProperties
protected int[] mapColumnsToProperties(ResultSetMetaData rsmd, PropertyDescriptor[] props) throws SQLException(Code)
The positions in the returned array represent column numbers. The values stored at each position represent the index in the PropertyDescriptor[] for the bean property that matches the column name. If no bean property was found for a column, the position is set to PROPERTY_NOT_FOUND.
Parameters:
  rsmd - The ResultSetMetaData containing column information.
Parameters:
  props - The bean property descriptors.
throws:
  SQLException - if a database access error occurs An int[] with column index to property index mappings. The 0th element is meaningless because JDBC column indexing starts at 1.



newInstance
protected Object newInstance(Class c) throws SQLException(Code)
Factory method that returns a new instance of the given Class. This is called at the start of the bean creation process and may be overridden to provide custom behavior like returning a cached bean instance.
Parameters:
  c - The Class to create an object from. A newly created object of the Class.
throws:
  SQLException - if creation failed.



processColumn
protected Object processColumn(ResultSet rs, int index, Class propType) throws SQLException(Code)
Convert a ResultSet column into an object. Simple implementations could just call rs.getObject(index) while more complex implementations could perform type manipulation to match the column's type to the bean property type.

This implementation calls the appropriate ResultSet getter method for the given property type to perform the type conversion. If the property type doesn't match one of the supported ResultSet types, getObject is called.


Parameters:
  rs - The ResultSet currently being processed. It ispositioned on a valid row before being passed into this method.
Parameters:
  index - The current column index being processed.
Parameters:
  propType - The bean property type that this column needs to beconverted into.
throws:
  SQLException - if a database access error occurs The object from the ResultSet at the given columnindex after optional type processing or null if the columnvalue was SQL NULL.



toBean
public Object toBean(ResultSet rs, Class type) throws SQLException(Code)
Convert a ResultSet row into a JavaBean. This implementation uses reflection and BeanInfo classes to match column names to bean property names. Properties are matched to columns based on several factors:
  1. The class has a writable property with the same name as a column. The name comparison is case insensitive.
  2. The column type can be converted to the property's set method parameter type with a ResultSet.get* method. If the conversion fails (ie. the property was an int and the column was a Timestamp) an SQLException is thrown.

Primitive bean properties are set to their defaults when SQL NULL is returned from the ResultSet. Numeric fields are set to 0 and booleans are set to false. Object bean properties are set to null when SQL NULL is returned. This is the same behavior as the ResultSet get* methods.


Parameters:
  rs - ResultSet that supplies the bean data
Parameters:
  type - Class from which to create the bean instance
throws:
  SQLException - if a database access error occurs the newly created bean



toBeanList
public List toBeanList(ResultSet rs, Class type) throws SQLException(Code)
Convert a ResultSet into a List of JavaBeans. This implementation uses reflection and BeanInfo classes to match column names to bean property names. Properties are matched to columns based on several factors:
  1. The class has a writable property with the same name as a column. The name comparison is case insensitive.
  2. The column type can be converted to the property's set method parameter type with a ResultSet.get* method. If the conversion fails (ie. the property was an int and the column was a Timestamp) an SQLException is thrown.

Primitive bean properties are set to their defaults when SQL NULL is returned from the ResultSet. Numeric fields are set to 0 and booleans are set to false. Object bean properties are set to null when SQL NULL is returned. This is the same behavior as the ResultSet get* methods.


Parameters:
  rs - ResultSet that supplies the bean data
Parameters:
  type - Class from which to create the bean instance
throws:
  SQLException - if a database access error occurs the newly created List of beans



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.