Source Code Cross Referenced for SqlParameter.java in  » J2EE » spring-framework-2.5 » org » springframework » jdbc » core » 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.5 » org.springframework.jdbc.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2007 the original author or authors.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.springframework.jdbc.core;
018:
019:        import java.util.LinkedList;
020:        import java.util.List;
021:
022:        import org.springframework.util.Assert;
023:
024:        /**
025:         * Object to represent a SQL parameter definition.
026:         *
027:         * <p>Parameters may be anonymous, in which case "name" is <code>null</code>.
028:         * However, all parameters must define a SQL type according to {@link java.sql.Types}.
029:         *
030:         * @author Rod Johnson
031:         * @author Thomas Risberg
032:         * @author Juergen Hoeller
033:         * @see java.sql.Types
034:         */
035:        public class SqlParameter {
036:
037:            /** The name of the parameter, if any */
038:            private String name;
039:
040:            /** SQL type constant from <code>java.sql.Types</code> */
041:            private final int sqlType;
042:
043:            /** Used for types that are user-named like: STRUCT, DISTINCT, JAVA_OBJECT, named array types */
044:            private String typeName;
045:
046:            /** The scale to apply in case of a NUMERIC or DECIMAL type, if any */
047:            private Integer scale;
048:
049:            /**
050:             * Create a new anonymous SqlParameter, supplying the SQL type.
051:             * @param sqlType SQL type of the parameter according to <code>java.sql.Types</code>
052:             */
053:            public SqlParameter(int sqlType) {
054:                this .sqlType = sqlType;
055:            }
056:
057:            /**
058:             * Create a new anonymous SqlParameter, supplying the SQL type.
059:             * @param sqlType SQL type of the parameter according to <code>java.sql.Types</code>
060:             * @param typeName the type name of the parameter (optional)
061:             */
062:            public SqlParameter(int sqlType, String typeName) {
063:                this .sqlType = sqlType;
064:                this .typeName = typeName;
065:            }
066:
067:            /**
068:             * Create a new anonymous SqlParameter, supplying the SQL type.
069:             * @param sqlType SQL type of the parameter according to <code>java.sql.Types</code>
070:             * @param scale the number of digits after the decimal point
071:             * (for DECIMAL and NUMERIC types)
072:             */
073:            public SqlParameter(int sqlType, int scale) {
074:                this .sqlType = sqlType;
075:                this .scale = new Integer(scale);
076:            }
077:
078:            /**
079:             * Create a new SqlParameter, supplying name and SQL type.
080:             * @param name name of the parameter, as used in input and output maps
081:             * @param sqlType SQL type of the parameter according to <code>java.sql.Types</code>
082:             */
083:            public SqlParameter(String name, int sqlType) {
084:                this .name = name;
085:                this .sqlType = sqlType;
086:            }
087:
088:            /**
089:             * Create a new SqlParameter, supplying name and SQL type.
090:             * @param name name of the parameter, as used in input and output maps
091:             * @param sqlType SQL type of the parameter according to <code>java.sql.Types</code>
092:             * @param typeName the type name of the parameter (optional)
093:             */
094:            public SqlParameter(String name, int sqlType, String typeName) {
095:                this .name = name;
096:                this .sqlType = sqlType;
097:                this .typeName = typeName;
098:            }
099:
100:            /**
101:             * Create a new SqlParameter, supplying name and SQL type.
102:             * @param name name of the parameter, as used in input and output maps
103:             * @param sqlType SQL type of the parameter according to <code>java.sql.Types</code>
104:             * @param scale the number of digits after the decimal point
105:             * (for DECIMAL and NUMERIC types)
106:             */
107:            public SqlParameter(String name, int sqlType, int scale) {
108:                this .name = name;
109:                this .sqlType = sqlType;
110:                this .scale = new Integer(scale);
111:            }
112:
113:            /**
114:             * Copy constructor.
115:             * @param otherParam the SqlParameter object to copy from
116:             */
117:            public SqlParameter(SqlParameter otherParam) {
118:                Assert.notNull(otherParam,
119:                        "SqlParameter object must not be null");
120:                this .name = otherParam.name;
121:                this .sqlType = otherParam.sqlType;
122:                this .typeName = otherParam.typeName;
123:                this .scale = otherParam.scale;
124:            }
125:
126:            /**
127:             * Return the name of the parameter.
128:             */
129:            public String getName() {
130:                return this .name;
131:            }
132:
133:            /**
134:             * Return the SQL type of the parameter.
135:             */
136:            public int getSqlType() {
137:                return this .sqlType;
138:            }
139:
140:            /**
141:             * Return the type name of the parameter, if any.
142:             */
143:            public String getTypeName() {
144:                return this .typeName;
145:            }
146:
147:            /**
148:             * Return the scale of the parameter, if any.
149:             */
150:            public Integer getScale() {
151:                return this .scale;
152:            }
153:
154:            /**
155:             * Return whether this parameter holds input values that should be set
156:             * before execution even if they are <code>null</code>.
157:             * <p>This implementation always returns <code>true</code>.
158:             */
159:            public boolean isInputValueProvided() {
160:                return true;
161:            }
162:
163:            /**
164:             * Return whether this parameter is an implicit return parameter used during the
165:             * results preocessing of the CallableStatement.getMoreResults/getUpdateCount.
166:             * <p>This implementation always returns <code>false</code>.
167:             */
168:            public boolean isResultsParameter() {
169:                return false;
170:            }
171:
172:            /**
173:             * Convert a list of JDBC types, as defined in <code>java.sql.Types</code>,
174:             * to a List of SqlParameter objects as used in this package.
175:             */
176:            public static List sqlTypesToAnonymousParameterList(int[] types) {
177:                List result = new LinkedList();
178:                if (types != null) {
179:                    for (int i = 0; i < types.length; i++) {
180:                        result.add(new SqlParameter(types[i]));
181:                    }
182:                }
183:                return result;
184:            }
185:
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.