Source Code Cross Referenced for DatabaseProcedure.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:         * Copyright (C) 2005 Continuent, Inc.
007:         * Contact: sequoia@continuent.org
008:         * 
009:         * Licensed under the Apache License, Version 2.0 (the "License");
010:         * you may not use this file except in compliance with the License.
011:         * You may obtain a copy of the License at
012:         * 
013:         * http://www.apache.org/licenses/LICENSE-2.0
014:         * 
015:         * Unless required by applicable law or agreed to in writing, software
016:         * distributed under the License is distributed on an "AS IS" BASIS,
017:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018:         * See the License for the specific language governing permissions and
019:         * limitations under the License. 
020:         *
021:         * Initial developer(s): Nicolas Modrzyk
022:         * Contributor(s): Emmanuel Cecchet, Edward Archibald
023:         */package org.continuent.sequoia.common.sql.schema;
024:
025:        import java.util.ArrayList;
026:
027:        import org.continuent.sequoia.common.xml.DatabasesXmlTags;
028:
029:        /**
030:         * Represents a database stored procedure and its metadata.
031:         * 
032:         * @author <a href="mailto:ed.archibald@continuent.com">Edward Archibald</a>
033:         * @author <a href="mailto:emmanuel.cecchet@continuent.com">Emmanuel Cecchet
034:         *         </a>
035:         * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
036:         */
037:        public class DatabaseProcedure {
038:            /** May return a result */
039:            public static final int ProcedureResultUnknown = 0;
040:            /** Does not return a result */
041:            public static final int ProcedureNoResult = 1;
042:            /** Returns a result */
043:            public static final int ProcedureReturnsResult = 2;
044:
045:            ArrayList parameters;
046:            private String name;
047:            private String remarks;
048:            private int procedureType;
049:            private DatabaseProcedureSemantic semantic;
050:
051:            /**
052:             * @param name of the procedure
053:             * @param remarks of the procedure
054:             * @param procedureType see above types
055:             */
056:            public DatabaseProcedure(String name, String remarks,
057:                    int procedureType) {
058:                this .name = name;
059:                this .remarks = remarks;
060:                this .procedureType = procedureType;
061:                this .parameters = new ArrayList();
062:            }
063:
064:            /**
065:             * Add a parameter to this procedure
066:             * 
067:             * @param param to add
068:             */
069:            public void addParameter(DatabaseProcedureParameter param) {
070:                parameters.add(param);
071:            }
072:
073:            /**
074:             * Build a unique key based on a stored procedure name and its number of
075:             * parameters. Please note that this is enough for some DBMS: Postgresql 8 for
076:             * instance allows full function overloading.
077:             * 
078:             * @param storedProcedureName stored procedure name
079:             * @param nbOfParameters number of parameters
080:             * @return a String representation of the key (used by HashMap in schema)
081:             */
082:            public static String buildKey(String storedProcedureName,
083:                    int nbOfParameters) {
084:                return storedProcedureName + "(" + nbOfParameters + ")";
085:            }
086:
087:            /**
088:             * Returns a unique key identifying this stored procedure.
089:             * 
090:             * @return the unique key
091:             */
092:            public String getKey() {
093:                if (procedureType == ProcedureReturnsResult)
094:                    // Strip return value from the parameter list
095:                    return buildKey(name, parameters.size() - 1);
096:                else
097:                    return buildKey(name, parameters.size());
098:            }
099:
100:            /**
101:             * @return Returns the name.
102:             */
103:            public String getName() {
104:                return name;
105:            }
106:
107:            /**
108:             * @param name The name to set.
109:             */
110:            public void setName(String name) {
111:                this .name = name;
112:            }
113:
114:            /**
115:             * @return Returns the parameters.
116:             */
117:            public ArrayList getParameters() {
118:                return parameters;
119:            }
120:
121:            /**
122:             * @param parameters The parameters to set.
123:             */
124:            public void setParameters(ArrayList parameters) {
125:                this .parameters = parameters;
126:            }
127:
128:            /**
129:             * @return Returns the procedureType.
130:             */
131:            public int getProcedureType() {
132:                return procedureType;
133:            }
134:
135:            /**
136:             * @param procedureType The procedureType to set.
137:             */
138:            public void setProcedureType(int procedureType) {
139:                this .procedureType = procedureType;
140:            }
141:
142:            /**
143:             * @return Returns the remarks.
144:             */
145:            public String getRemarks() {
146:                return remarks;
147:            }
148:
149:            /**
150:             * @param remarks The remarks to set.
151:             */
152:            public void setRemarks(String remarks) {
153:                this .remarks = remarks;
154:            }
155:
156:            /**
157:             * Returns the procedureNoResult value.
158:             * 
159:             * @return Returns the procedureNoResult.
160:             */
161:            public static int getProcedureNoResult() {
162:                return ProcedureNoResult;
163:            }
164:
165:            /**
166:             * Returns the stored procedure semantic.
167:             * 
168:             * @return Returns the semantic.
169:             */
170:            public DatabaseProcedureSemantic getSemantic() {
171:                return semantic;
172:            }
173:
174:            /**
175:             * Sets the stored procedure semantic.
176:             * 
177:             * @param semantic The semantic to set.
178:             */
179:            public void setSemantic(DatabaseProcedureSemantic semantic) {
180:                this .semantic = semantic;
181:            }
182:
183:            /**
184:             * Convert type from string to integer
185:             * 
186:             * @param type as a string
187:             * @return ProcedureNoResult or ProcedureReturnsResult or
188:             *         ProcedureResultUnknown if not found
189:             */
190:            public static int getTypeFromString(String type) {
191:                if (type.equals(DatabasesXmlTags.VAL_noResult))
192:                    return ProcedureNoResult;
193:                if (type.equals(DatabasesXmlTags.VAL_returnsResult))
194:                    return ProcedureReturnsResult;
195:                else
196:                    return ProcedureResultUnknown;
197:            }
198:
199:            /**
200:             * Convert type from integer to string
201:             * 
202:             * @param type as an int
203:             * @return string value conforms to xml tags.
204:             */
205:            public static String getTypeFromInt(int type) {
206:                switch (type) {
207:                case ProcedureNoResult:
208:                    return DatabasesXmlTags.VAL_noResult;
209:                case ProcedureReturnsResult:
210:                    return DatabasesXmlTags.VAL_returnsResult;
211:                default:
212:                    return DatabasesXmlTags.VAL_resultUnknown;
213:                }
214:            }
215:
216:            /**
217:             * Get xml information about this procedure.
218:             * 
219:             * @return xml formatted information on this database procedure.
220:             */
221:            public String getXml() {
222:                StringBuffer info = new StringBuffer();
223:                info.append("<" + DatabasesXmlTags.ELT_DatabaseProcedure + " "
224:                        + DatabasesXmlTags.ATT_name + "=\"" + name + "\" "
225:                        + DatabasesXmlTags.ATT_returnType + "=\""
226:                        + getTypeFromInt(procedureType) + "\">");
227:                for (int i = 0; i < parameters.size(); i++)
228:                    info
229:                            .append(((DatabaseProcedureParameter) parameters
230:                                    .get(i)).getXml());
231:                info
232:                        .append("</" + DatabasesXmlTags.ELT_DatabaseProcedure
233:                                + ">");
234:                return info.toString();
235:            }
236:
237:            /**
238:             * Two <code>DatabaseProcedure</code> are considered equal if they have the
239:             * same name and the same parameters.
240:             * 
241:             * @param other the object to compare with
242:             * @return <code>true</code> if the DatabaseProcedures are equal
243:             */
244:            public boolean equals(Object other) {
245:                if ((other == null) || !(other instanceof  DatabaseProcedure))
246:                    return false;
247:
248:                DatabaseProcedure p = (DatabaseProcedure) other;
249:                return getKey().equals(p.getKey());
250:            }
251:
252:            /**
253:             * @see java.lang.Object#toString()
254:             */
255:            public String toString() {
256:                return getKey() + " " + getSemantic();
257:            }
258:
259:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.