Source Code Cross Referenced for DatabaseProcedureParameter.java in  » Database-JDBC-Connection-Pool » sequoia-2.10.9 » org » continuent » sequoia » common » sql » schema » 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 » sequoia 2.10.9 » org.continuent.sequoia.common.sql.schema 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Sequoia: Database clustering technology.
003:         * Copyright (C) 2002-2004 French National Institute For Research In Computer
004:         * Science And Control (INRIA).
005:         * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
006:         * Contact: sequoia@continuent.org
007:         * 
008:         * Licensed under the Apache License, Version 2.0 (the "License");
009:         * you may not use this file except in compliance with the License.
010:         * You may obtain a copy of the License at
011:         * 
012:         * http://www.apache.org/licenses/LICENSE-2.0
013:         * 
014:         * Unless required by applicable law or agreed to in writing, software
015:         * distributed under the License is distributed on an "AS IS" BASIS,
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:         * See the License for the specific language governing permissions and
018:         * limitations under the License. 
019:         *
020:         * Initial developer(s): Nicolas Modrzyk
021:         * Contributor(s): Marc Wick, Emmanuel Cecchet.
022:         */package org.continuent.sequoia.common.sql.schema;
023:
024:        import java.sql.Types;
025:
026:        import org.continuent.sequoia.common.xml.DatabasesXmlTags;
027:
028:        /**
029:         * Represents a parameter of procedure
030:         * 
031:         * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
032:         */
033:        public class DatabaseProcedureParameter {
034:            /** kind of column/parameter */
035:
036:            /** nobody knows */
037:            public static final int ProcedureColumnUnknown = 0;
038:            /** IN parameter */
039:            public static final int ProcedureColumnIn = 1;
040:            /** INOUT parameter */
041:            public static final int ProcedureColumnInOut = 2;
042:            /** OUT parameter */
043:            public static final int ProcedureColumnOut = 3;
044:            /** procedure return value */
045:            public static final int ProcedureColumnReturn = 4;
046:            /** procedure return value */
047:            public static final int ProcedureColumnResult = 5;
048:
049:            /** Can it contain NULL ? */
050:            /** does not allow NULL values */
051:            public static final int ProcedureNoNulls = 0;
052:            /** allows NULL values */
053:            public static final int ProcedureNullable = 1;
054:            /** nullability unknown */
055:            public static final int ProcedureNullableUnknown = 2;
056:
057:            private String name;
058:            private int columnType;
059:            private int dataType;
060:            private String typeName;
061:            private float precision;
062:            private int length;
063:            private int scale;
064:            private int radix;
065:            private int nullable;
066:            private String remarks;
067:
068:            /**
069:             * get null ability given a string
070:             * 
071:             * @param nullable recognized are "nonulls" and "nullable"
072:             * @return value given the java specification
073:             */
074:            public static int getNullFromString(String nullable) {
075:                if (nullable.equalsIgnoreCase(DatabasesXmlTags.VAL_noNulls))
076:                    return ProcedureNoNulls;
077:                if (nullable.equalsIgnoreCase(DatabasesXmlTags.VAL_nullable))
078:                    return ProcedureNullable;
079:                else
080:                    return ProcedureNullableUnknown;
081:            }
082:
083:            /**
084:             * get null ability given an int
085:             * 
086:             * @param nullable as an integer
087:             * @return a string conformed to dtd
088:             */
089:            public static String getNullFromInt(int nullable) {
090:                switch (nullable) {
091:                case ProcedureNoNulls:
092:                    return DatabasesXmlTags.VAL_noNulls;
093:                case ProcedureNullable:
094:                    return DatabasesXmlTags.VAL_nullable;
095:                case ProcedureNullableUnknown:
096:                default:
097:                    return DatabasesXmlTags.VAL_nullableUnknown;
098:                }
099:            }
100:
101:            /**
102:             * get column type given an int
103:             * 
104:             * @param type as an int from the java specification
105:             * @return a description as a string
106:             */
107:            public static String getColumnTypeFromInt(int type) {
108:                switch (type) {
109:                case ProcedureColumnIn:
110:                    return DatabasesXmlTags.VAL_in;
111:                case ProcedureColumnOut:
112:                    return DatabasesXmlTags.VAL_out;
113:                case ProcedureColumnInOut:
114:                    return DatabasesXmlTags.VAL_inout;
115:                case ProcedureColumnReturn:
116:                    return DatabasesXmlTags.VAL_return;
117:                case ProcedureColumnResult:
118:                    return DatabasesXmlTags.VAL_result;
119:                case ProcedureColumnUnknown:
120:                default:
121:                    return DatabasesXmlTags.VAL_unknown;
122:                }
123:            }
124:
125:            /**
126:             * get type from string
127:             * 
128:             * @param type of the parameter
129:             * @return value given the java specification
130:             */
131:            public static int getColumnTypeFromString(String type) {
132:                if (type.equalsIgnoreCase(DatabasesXmlTags.VAL_in))
133:                    return ProcedureColumnIn;
134:                if (type.equalsIgnoreCase(DatabasesXmlTags.VAL_out))
135:                    return ProcedureColumnOut;
136:                if (type.equalsIgnoreCase(DatabasesXmlTags.VAL_inout))
137:                    return ProcedureColumnInOut;
138:                if (type.equalsIgnoreCase(DatabasesXmlTags.VAL_return))
139:                    return ProcedureColumnReturn;
140:                if (type.equalsIgnoreCase(DatabasesXmlTags.VAL_result))
141:                    return ProcedureColumnResult;
142:                else
143:                    return ProcedureColumnUnknown;
144:            }
145:
146:            /**
147:             * Reduced version of constructor for static schemas
148:             * 
149:             * @param name column/parameter name
150:             * @param columnType kind of column/parameter
151:             * @param nullable can it contain NULL?
152:             */
153:            public DatabaseProcedureParameter(String name, int columnType,
154:                    int nullable) {
155:                this (name, columnType, Types.VARCHAR, "VARCHAR", 0, 0, 0, 0,
156:                        nullable, "");
157:            }
158:
159:            /**
160:             * @param name column/parameter name
161:             * @param columnType kind of column/parameter
162:             * @param dataType SQL type from java.sql.Types
163:             * @param typeName SQL type name, for a UDT type the type name is fully
164:             *          qualified
165:             * @param precision precision
166:             * @param length length in bytes of data
167:             * @param scale scale
168:             * @param radix radix
169:             * @param nullable can it contain NULL?
170:             * @param remarks comment describing parameter/column
171:             */
172:            public DatabaseProcedureParameter(String name, int columnType,
173:                    int dataType, String typeName, float precision, int length,
174:                    int scale, int radix, int nullable, String remarks) {
175:                this .name = name;
176:                this .columnType = columnType;
177:                this .dataType = dataType;
178:                this .typeName = typeName;
179:                this .precision = precision;
180:                this .length = length;
181:                this .scale = scale;
182:                this .radix = radix;
183:                this .nullable = nullable;
184:                this .remarks = remarks;
185:            }
186:
187:            /**
188:             * @return Returns the columnType.
189:             */
190:            public final int getColumnType() {
191:                return columnType;
192:            }
193:
194:            /**
195:             * @param columnType The columnType to set.
196:             */
197:            public final void setColumnType(int columnType) {
198:                this .columnType = columnType;
199:            }
200:
201:            /**
202:             * @return Returns the dataType.
203:             */
204:            public final int getDataType() {
205:                return dataType;
206:            }
207:
208:            /**
209:             * @param dataType The dataType to set.
210:             */
211:            public final void setDataType(int dataType) {
212:                this .dataType = dataType;
213:            }
214:
215:            /**
216:             * @return Returns the length.
217:             */
218:            public final int getLength() {
219:                return length;
220:            }
221:
222:            /**
223:             * @param length The length to set.
224:             */
225:            public final void setLength(int length) {
226:                this .length = length;
227:            }
228:
229:            /**
230:             * @return Returns the name.
231:             */
232:            public final String getName() {
233:                return name;
234:            }
235:
236:            /**
237:             * @param name The name to set.
238:             */
239:            public final void setName(String name) {
240:                this .name = name;
241:            }
242:
243:            /**
244:             * @return Returns the nullable.
245:             */
246:            public final int getNullable() {
247:                return nullable;
248:            }
249:
250:            /**
251:             * @param nullable The nullable to set.
252:             */
253:            public final void setNullable(int nullable) {
254:                this .nullable = nullable;
255:            }
256:
257:            /**
258:             * @return Returns the precision.
259:             */
260:            public final float getPrecision() {
261:                return precision;
262:            }
263:
264:            /**
265:             * @param precision The precision to set.
266:             */
267:            public final void setPrecision(int precision) {
268:                this .precision = precision;
269:            }
270:
271:            /**
272:             * @return Returns the radix.
273:             */
274:            public final int getRadix() {
275:                return radix;
276:            }
277:
278:            /**
279:             * @param radix The radix to set.
280:             */
281:            public final void setRadix(int radix) {
282:                this .radix = radix;
283:            }
284:
285:            /**
286:             * @return Returns the remarks.
287:             */
288:            public final String getRemarks() {
289:                return remarks;
290:            }
291:
292:            /**
293:             * @param remarks The remarks to set.
294:             */
295:            public final void setRemarks(String remarks) {
296:                this .remarks = remarks;
297:            }
298:
299:            /**
300:             * @return Returns the scale.
301:             */
302:            public final int getScale() {
303:                return scale;
304:            }
305:
306:            /**
307:             * @param scale The scale to set.
308:             */
309:            public final void setScale(int scale) {
310:                this .scale = scale;
311:            }
312:
313:            /**
314:             * @return Returns the typeName.
315:             */
316:            public final String getTypeName() {
317:                return typeName;
318:            }
319:
320:            /**
321:             * @param typeName The typeName to set.
322:             */
323:            public final void setTypeName(String typeName) {
324:                this .typeName = typeName;
325:            }
326:
327:            /**
328:             * Two <code>DatabaseProcedureParameter</code> are considered equal if they
329:             * have the same name and the same descriptive attributes.
330:             * 
331:             * @param other the object to compare with
332:             * @return <code>true</code> if the DatabaseProcedureParameter are equal
333:             */
334:            public boolean equals(Object other) {
335:                if ((other == null)
336:                        || !(other instanceof  DatabaseProcedureParameter))
337:                    return false;
338:
339:                DatabaseProcedureParameter p = (DatabaseProcedureParameter) other;
340:
341:                // first we check simple types
342:                if (!(p.columnType == columnType && p.dataType == dataType
343:                        && p.precision == precision && p.length == length
344:                        && p.scale == scale && p.radix == radix && p.nullable == nullable)) {
345:                    return false;
346:                }
347:
348:                // now we compare object types
349:                if (!(name == null ? p.name == null : name.equals(p.name))) {
350:                    return false;
351:                }
352:
353:                if (!(typeName == null ? p.typeName == null : typeName
354:                        .equals(p.typeName))) {
355:                    return false;
356:                }
357:
358:                return remarks == null ? p.remarks == null : remarks
359:                        .equals(p.remarks);
360:            }
361:
362:            /**
363:             * Get xml information about this procedure.
364:             * 
365:             * @return xml formatted information on this database procedure.
366:             */
367:            public String getXml() {
368:                StringBuffer info = new StringBuffer();
369:                info.append("<" + DatabasesXmlTags.ELT_DatabaseProcedureColumn
370:                        + " " + DatabasesXmlTags.ATT_name + "=\"" + name + "\""
371:                        + " " + DatabasesXmlTags.ATT_paramType + "=\""
372:                        + getColumnTypeFromInt(columnType) + "\"" + " "
373:                        + DatabasesXmlTags.ATT_nullable + "=\""
374:                        + getNullFromInt(nullable) + "\"/>");
375:                return info.toString();
376:            }
377:
378:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.