KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > controller > sql > schema > DatabaseProcedureParameter


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
6  * Contact: sequoia@continuent.org
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  * Initial developer(s): Nicolas Modrzyk
21  * Contributor(s): Marc Wick, Emmanuel Cecchet.
22  */

23
24 package org.continuent.sequoia.controller.sql.schema;
25
26 import java.sql.Types JavaDoc;
27
28 /**
29  * Represents a parameter of a stored procedure
30  *
31  * @author <a HREF="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
32  */

33 public class DatabaseProcedureParameter
34 {
35   /** kind of column/parameter */
36
37   /** nobody knows */
38   public static final int ProcedureColumnUnknown = 0;
39   /** IN parameter */
40   public static final int ProcedureColumnIn = 1;
41   /** INOUT parameter */
42   public static final int ProcedureColumnInOut = 2;
43   /** OUT parameter */
44   public static final int ProcedureColumnOut = 3;
45   /** procedure return value */
46   public static final int ProcedureColumnReturn = 4;
47   /** procedure return value */
48   public static final int ProcedureColumnResult = 5;
49
50   /** Can it contain NULL ? */
51   /** does not allow NULL values */
52   public static final int ProcedureNoNulls = 0;
53   /** allows NULL values */
54   public static final int ProcedureNullable = 1;
55   /** nullability unknown */
56   public static final int ProcedureNullableUnknown = 2;
57
58   private String JavaDoc name;
59   private int columnType;
60   private int dataType;
61   private String JavaDoc typeName;
62   private float precision;
63   private int length;
64   private int scale;
65   private int radix;
66   private int nullable;
67   private String JavaDoc remarks;
68
69   /**
70    * Reduced version of constructor for static schemas
71    *
72    * @param name column/parameter name
73    * @param columnType kind of column/parameter
74    * @param nullable can it contain NULL?
75    */

76   public DatabaseProcedureParameter(String JavaDoc name, int columnType, int nullable)
77   {
78     this(name, columnType, Types.VARCHAR, "VARCHAR", 0, 0, 0, 0, nullable, "");
79   }
80
81   /**
82    * @param name column/parameter name
83    * @param columnType kind of column/parameter
84    * @param dataType SQL type from java.sql.Types
85    * @param typeName SQL type name, for a UDT type the type name is fully
86    * qualified
87    * @param precision precision
88    * @param length length in bytes of data
89    * @param scale scale
90    * @param radix radix
91    * @param nullable can it contain NULL?
92    * @param remarks comment describing parameter/column
93    */

94   public DatabaseProcedureParameter(String JavaDoc name, int columnType, int dataType,
95       String JavaDoc typeName, float precision, int length, int scale, int radix,
96       int nullable, String JavaDoc remarks)
97   {
98     this.name = name;
99     this.columnType = columnType;
100     this.dataType = dataType;
101     this.typeName = typeName;
102     this.precision = precision;
103     this.length = length;
104     this.scale = scale;
105     this.radix = radix;
106     this.nullable = nullable;
107     this.remarks = remarks;
108   }
109
110   /**
111    * @return Returns the columnType.
112    */

113   public final int getColumnType()
114   {
115     return columnType;
116   }
117
118   /**
119    * @param columnType The columnType to set.
120    */

121   public final void setColumnType(int columnType)
122   {
123     this.columnType = columnType;
124   }
125
126   /**
127    * @return Returns the dataType.
128    */

129   public final int getDataType()
130   {
131     return dataType;
132   }
133
134   /**
135    * @param dataType The dataType to set.
136    */

137   public final void setDataType(int dataType)
138   {
139     this.dataType = dataType;
140   }
141
142   /**
143    * @return Returns the length.
144    */

145   public final int getLength()
146   {
147     return length;
148   }
149
150   /**
151    * @param length The length to set.
152    */

153   public final void setLength(int length)
154   {
155     this.length = length;
156   }
157
158   /**
159    * @return Returns the name.
160    */

161   public final String JavaDoc getName()
162   {
163     return name;
164   }
165
166   /**
167    * @param name The name to set.
168    */

169   public final void setName(String JavaDoc name)
170   {
171     this.name = name;
172   }
173
174   /**
175    * @return Returns the nullable.
176    */

177   public final int getNullable()
178   {
179     return nullable;
180   }
181
182   /**
183    * @param nullable The nullable to set.
184    */

185   public final void setNullable(int nullable)
186   {
187     this.nullable = nullable;
188   }
189
190   /**
191    * @return Returns the precision.
192    */

193   public final float getPrecision()
194   {
195     return precision;
196   }
197
198   /**
199    * @param precision The precision to set.
200    */

201   public final void setPrecision(int precision)
202   {
203     this.precision = precision;
204   }
205
206   /**
207    * @return Returns the radix.
208    */

209   public final int getRadix()
210   {
211     return radix;
212   }
213
214   /**
215    * @param radix The radix to set.
216    */

217   public final void setRadix(int radix)
218   {
219     this.radix = radix;
220   }
221
222   /**
223    * @return Returns the remarks.
224    */

225   public final String JavaDoc getRemarks()
226   {
227     return remarks;
228   }
229
230   /**
231    * @param remarks The remarks to set.
232    */

233   public final void setRemarks(String JavaDoc remarks)
234   {
235     this.remarks = remarks;
236   }
237
238   /**
239    * @return Returns the scale.
240    */

241   public final int getScale()
242   {
243     return scale;
244   }
245
246   /**
247    * @param scale The scale to set.
248    */

249   public final void setScale(int scale)
250   {
251     this.scale = scale;
252   }
253
254   /**
255    * @return Returns the typeName.
256    */

257   public final String JavaDoc getTypeName()
258   {
259     return typeName;
260   }
261
262   /**
263    * @param typeName The typeName to set.
264    */

265   public final void setTypeName(String JavaDoc typeName)
266   {
267     this.typeName = typeName;
268   }
269
270   /**
271    * Two <code>DatabaseProcedureParameter</code> are considered equal if they
272    * have the same name and the same descriptive attributes.
273    *
274    * @param other the object to compare with
275    * @return <code>true</code> if the DatabaseProcedureParameter are equal
276    */

277   public boolean equals(Object JavaDoc other)
278   {
279     if ((other == null) || !(other instanceof DatabaseProcedureParameter))
280       return false;
281
282     DatabaseProcedureParameter p = (DatabaseProcedureParameter) other;
283
284     // first we check simple types
285
if (!(p.columnType == columnType && p.dataType == dataType
286         && p.precision == precision && p.length == length && p.scale == scale
287         && p.radix == radix && p.nullable == nullable))
288     {
289       return false;
290     }
291
292     // now we compare object types
293
if (!(name == null ? p.name == null : name.equals(p.name)))
294     {
295       return false;
296     }
297
298     if (!(typeName == null ? p.typeName == null : typeName.equals(p.typeName)))
299     {
300       return false;
301     }
302
303     return remarks == null ? p.remarks == null : remarks.equals(p.remarks);
304   }
305
306 }
Popular Tags