Source Code Cross Referenced for TestResultSetMetaData.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 Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.commons.beanutils;
019:
020:        import java.lang.reflect.InvocationHandler;
021:        import java.lang.reflect.Method;
022:        import java.lang.reflect.Proxy;
023:        import java.sql.ResultSetMetaData;
024:        import java.sql.SQLException;
025:        import java.sql.Types;
026:
027:        /**
028:         * <p>Mock object that implements enough of
029:         * <code>java.sql.ResultSetMetaData</code>
030:         * to exercise the {@link ResultSetDynaClass} functionality.</p>
031:         *
032:         * @author Craig R. McClanahan
033:         * @version $Revision: 561644 $ $Date: 2007-08-01 05:31:50 +0100 (Wed, 01 Aug 2007) $
034:         */
035:
036:        public class TestResultSetMetaData implements  InvocationHandler {
037:
038:            // ----------------------------------------------------- Instance Variables
039:
040:            /**
041:             * <p>Array of column names and class names for metadata.</p>
042:             */
043:            protected String metadata[][] = {
044:                    { "bigDecimalProperty",
045:                            java.math.BigDecimal.class.getName() },
046:                    { "booleanProperty", Boolean.class.getName() },
047:                    { "byteProperty", Byte.class.getName() },
048:                    { "dateProperty", java.sql.Date.class.getName() },
049:                    { "doubleProperty", Double.class.getName() },
050:                    { "floatProperty", Float.class.getName() },
051:                    { "intProperty", Integer.class.getName() },
052:                    { "longProperty", Long.class.getName() },
053:                    { "nullProperty", String.class.getName() },
054:                    { "shortProperty", Short.class.getName() },
055:                    { "stringProperty", String.class.getName() },
056:                    { "timeProperty", java.sql.Time.class.getName() },
057:                    { "timestampProperty", java.sql.Timestamp.class.getName() }, };
058:
059:            /**
060:             * Factory method for creating {@link ResultSetMetaData} proxies.
061:             *
062:             * @return A result set meta data proxy
063:             */
064:            public static ResultSetMetaData createProxy() {
065:                return TestResultSetMetaData
066:                        .createProxy(new TestResultSetMetaData());
067:            }
068:
069:            /**
070:             * Factory method for creating {@link ResultSetMetaData} proxies.
071:             * @param invocationHandler Invocation Handler
072:             * @return A result set meta data proxy
073:             */
074:            public static ResultSetMetaData createProxy(
075:                    InvocationHandler invocationHandler) {
076:                ClassLoader classLoader = ResultSetMetaData.class
077:                        .getClassLoader();
078:                Class[] interfaces = new Class[] { ResultSetMetaData.class };
079:                return (ResultSetMetaData) Proxy.newProxyInstance(classLoader,
080:                        interfaces, invocationHandler);
081:            }
082:
083:            /**
084:             * Handles method invocation on the {@link ResultSetMetaData} proxy. 
085:             *
086:             * @param proxy The proxy ResultSet object
087:             * @param method the method being invoked
088:             * @param args The method arguments
089:             * @return The result of invoking the method.
090:             * @throws Throwable if an error occurs.
091:             */
092:            public Object invoke(Object proxy, Method method, Object[] args)
093:                    throws Throwable {
094:                String methodName = method.getName();
095:                if ("getColumnClassName".equals(methodName)) {
096:                    return getColumnClassName(((Integer) args[0]).intValue());
097:                }
098:                if ("getColumnCount".equals(methodName)) {
099:                    return new Integer(getColumnCount());
100:                }
101:                if ("getColumnName".equals(methodName)) {
102:                    return getColumnName(((Integer) args[0]).intValue());
103:                }
104:                if ("getColumnType".equals(methodName)) {
105:                    return getColumnType(((Integer) args[0]).intValue());
106:                }
107:
108:                throw new UnsupportedOperationException(methodName
109:                        + " not implemented");
110:            }
111:
112:            // ---------------------------------------------------- Implemented Methods
113:
114:            public String getColumnClassName(int columnIndex)
115:                    throws SQLException {
116:                return (metadata[columnIndex - 1][1]);
117:            }
118:
119:            public int getColumnCount() throws SQLException {
120:                return (metadata.length);
121:            }
122:
123:            public String getColumnName(int columnIndex) throws SQLException {
124:                return (metadata[columnIndex - 1][0]);
125:            }
126:
127:            public Integer getColumnType(int columnIndex) throws SQLException {
128:                String columnName = getColumnName(columnIndex);
129:                int sqlType = Types.OTHER;
130:                if (columnName.equals("bigDecimalProperty")) {
131:                    sqlType = Types.DECIMAL;
132:                    // Types.BOOLEAN only introduced in JDK 1.4
133:                    //        } else if (columnName.equals("booleanProperty")) {
134:                    //            sqlType = Types.BOOLEAN;
135:                } else if (columnName.equals("byteProperty")) {
136:                    sqlType = Types.TINYINT;
137:                } else if (columnName.equals("dateProperty")) {
138:                    sqlType = Types.DATE;
139:                } else if (columnName.equals("doubleProperty")) {
140:                    sqlType = Types.DOUBLE;
141:                } else if (columnName.equals("floatProperty")) {
142:                    sqlType = Types.FLOAT;
143:                } else if (columnName.equals("intProperty")) {
144:                    sqlType = Types.INTEGER;
145:                } else if (columnName.equals("longProperty")) {
146:                    sqlType = Types.BIGINT;
147:                } else if (columnName.equals("nullProperty")) {
148:                    sqlType = Types.VARCHAR;
149:                } else if (columnName.equals("shortProperty")) {
150:                    sqlType = Types.SMALLINT;
151:                } else if (columnName.equals("stringProperty")) {
152:                    sqlType = Types.VARCHAR;
153:                } else if (columnName.equals("timeProperty")) {
154:                    sqlType = Types.TIME;
155:                } else if (columnName.equals("timestampProperty")) {
156:                    sqlType = Types.TIMESTAMP;
157:                } else {
158:                    sqlType = Types.OTHER;
159:                }
160:                return new Integer(sqlType);
161:            }
162:
163:            // -------------------------------------------------- Unimplemented Methods
164:
165:            public String getCatalogName(int columnIndex) throws SQLException {
166:                throw new UnsupportedOperationException();
167:            }
168:
169:            public int getColumnDisplaySize(int columnIndex)
170:                    throws SQLException {
171:                throw new UnsupportedOperationException();
172:            }
173:
174:            public String getColumnLabel(int columnIndex) throws SQLException {
175:                throw new UnsupportedOperationException();
176:            }
177:
178:            public String getColumnTypeName(int columnIndex)
179:                    throws SQLException {
180:                throw new UnsupportedOperationException();
181:            }
182:
183:            public int getPrecision(int columnIndex) throws SQLException {
184:                throw new UnsupportedOperationException();
185:            }
186:
187:            public int getScale(int columnIndex) throws SQLException {
188:                throw new UnsupportedOperationException();
189:            }
190:
191:            public String getSchemaName(int columnIndex) throws SQLException {
192:                throw new UnsupportedOperationException();
193:            }
194:
195:            public String getTableName(int columnIndex) throws SQLException {
196:                throw new UnsupportedOperationException();
197:            }
198:
199:            public boolean isAutoIncrement(int columnIndex) throws SQLException {
200:                throw new UnsupportedOperationException();
201:            }
202:
203:            public boolean isCaseSensitive(int columnIndex) throws SQLException {
204:                throw new UnsupportedOperationException();
205:            }
206:
207:            public boolean isCurrency(int columnIndex) throws SQLException {
208:                throw new UnsupportedOperationException();
209:            }
210:
211:            public boolean isDefinitelyWritable(int columnIndex)
212:                    throws SQLException {
213:                throw new UnsupportedOperationException();
214:            }
215:
216:            public int isNullable(int columnIndex) throws SQLException {
217:                throw new UnsupportedOperationException();
218:            }
219:
220:            public boolean isReadOnly(int columnIndex) throws SQLException {
221:                throw new UnsupportedOperationException();
222:            }
223:
224:            public boolean isSearchable(int columnIndex) throws SQLException {
225:                throw new UnsupportedOperationException();
226:            }
227:
228:            public boolean isSigned(int columnIndex) throws SQLException {
229:                throw new UnsupportedOperationException();
230:            }
231:
232:            public boolean isWritable(int columnIndex) throws SQLException {
233:                throw new UnsupportedOperationException();
234:            }
235:
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.