1 package salto.tool.sql.data;
2
3 import java.sql.Types;
4
5
6 /***
7 * Insérez la description du type à cet endroit.
8 * Date de création : (28/01/01 17:01:21)
9 * @author : Administrator
10 */
11 public class TableColInfo {
12 protected TableInfo tableInfo = null;
13 protected String tableCat;
14 protected String tableShem;
15 protected String tableName;
16 /***
17 * nom de la colonne
18 */
19 protected String colName;
20 /***
21 * type de colonne
22 */
23 protected short colTyp;
24
25 protected String typName;
26 protected int colSize;
27 protected int decDigit;
28 protected int numPrecRadix;
29 protected int colNullable;
30 protected String colRemarks;
31 protected String colDefaultVal;
32 protected int colCharOctetLength;
33 protected int colPosition;
34 protected String colIsNullable;
35 protected boolean autoIncrement;
36 /***
37 * Constructeur par défaut de TableColInfo.
38 */
39 public TableColInfo(TableInfo tableInfo) {
40 this.tableInfo = tableInfo;
41 }
42
43 public TableColInfo() {
44 }
45 /***
46 * Construction d'un colonne à partir d'un objet déjà initialisé
47 * Ce constructeur doit normalement servir uniquement à construire une instance d'une superclasse de TableColInfo
48 */
49 public TableColInfo(TableColInfo colInfo) {
50 tableInfo = colInfo.tableInfo;
51 tableCat = colInfo.tableCat;
52 tableShem = colInfo.tableShem;
53 tableName = colInfo.tableName;
54 colName = colInfo.colName;
55 colTyp = colInfo.colTyp;
56 typName = colInfo.typName;
57 colSize = colInfo.colSize;
58 decDigit = colInfo.decDigit;
59 numPrecRadix = colInfo.numPrecRadix;
60 colNullable = colInfo.colNullable;
61 colRemarks = colInfo.colRemarks;
62 colDefaultVal = colInfo.colDefaultVal;
63 colCharOctetLength = colInfo.colCharOctetLength;
64 colPosition = colInfo.colPosition;
65 colIsNullable = colInfo.colIsNullable;
66 }
67 /***
68 * Insérez la description de la méthode à cet endroit.
69 * Date de création : (28/01/01 17:06:36)
70 * @return int
71 */
72 public int getColCharOctetLength() {
73 return colCharOctetLength;
74 }
75 /***
76 * Insérez la description de la méthode à cet endroit.
77 * Date de création : (28/01/01 17:06:36)
78 * @return java.lang.String
79 */
80 public java.lang.String getColDefaultVal() {
81 return colDefaultVal;
82 }
83 /***
84 * Insérez la description de la méthode à cet endroit.
85 * Date de création : (28/01/01 17:06:36)
86 * @return java.lang.String
87 */
88 public java.lang.String getColIsNullable() {
89 return colIsNullable;
90 }
91 /***
92 * Insérez la description de la méthode à cet endroit.
93 * Date de création : (28/01/01 17:06:36)
94 * @return java.lang.String
95 */
96 public java.lang.String getColName() {
97 return colName;
98 }
99 /***
100 * Insérez la description de la méthode à cet endroit.
101 * Date de création : (28/01/01 17:06:36)
102 * @return int
103 */
104 public int getColNullable() {
105 return colNullable;
106 }
107 /***
108 * Insérez la description de la méthode à cet endroit.
109 * Date de création : (28/01/01 17:06:36)
110 * @return int
111 */
112 public int getColPosition() {
113 return colPosition;
114 }
115 /***
116 * Insérez la description de la méthode à cet endroit.
117 * Date de création : (28/01/01 17:06:36)
118 * @return java.lang.String
119 */
120 public java.lang.String getColRemarks() {
121 return colRemarks;
122 }
123 /***
124 * Insérez la description de la méthode à cet endroit.
125 * Date de création : (28/01/01 17:06:36)
126 * @return int
127 */
128 public int getColSize() {
129 return colSize;
130 }
131 /***
132 * Insérez la description de la méthode à cet endroit.
133 * Date de création : (28/01/01 17:06:36)
134 * @return short
135 */
136 public short getColTyp() {
137 return colTyp;
138 }
139 /***
140 * Insérez la description de la méthode à cet endroit.
141 * Date de création : (28/01/01 17:06:36)
142 * @return short
143 */
144 public String getColTypName() {
145 if (colTyp == Types.ARRAY) {
146 return "ARRAY";
147 } else if (colTyp == Types.BIGINT) {
148 return "BIGINT";
149 } else if (colTyp == Types.BINARY) {
150 return "BINARY";
151 } else if (colTyp == Types.BIT) {
152 return "BIT";
153 } else if (colTyp == Types.BLOB) {
154 return "BLOB";
155 } else if (colTyp == Types.BOOLEAN) {
156 return "BOOLEAN";
157 } else if (colTyp == Types.CHAR) {
158 return "CHAR";
159 } else if (colTyp == Types.CLOB) {
160 return "CLOB";
161 } else if (colTyp == Types.DATALINK) {
162 return "DATALINK";
163 } else if (colTyp == Types.DATE) {
164 return "DATE";
165 } else if (colTyp == Types.DECIMAL) {
166 return "DECIMAL";
167 } else if (colTyp == Types.DISTINCT) {
168 return "DISTINCT";
169 } else if (colTyp == Types.DOUBLE) {
170 return "DOUBLE";
171 } else if (colTyp == Types.FLOAT) {
172 return "FLOAT";
173 } else if (colTyp == Types.INTEGER) {
174 return "INTEGER";
175 } else if (colTyp == Types.JAVA_OBJECT) {
176 return "JAVA_OBJECT";
177 } else if (colTyp == Types.LONGVARBINARY) {
178 return "LONGVARBINARY";
179 } else if (colTyp == Types.LONGVARCHAR) {
180 return "LONGVARCHAR";
181 } else if (colTyp == Types.NULL) {
182 return "NULL";
183 } else if (colTyp == Types.NUMERIC) {
184 return "NUMERIC";
185 } else if (colTyp == Types.REAL) {
186 return "REAL";
187 } else if (colTyp == Types.REF) {
188 return "REF";
189 } else if (colTyp == Types.TIME) {
190 return "TIME";
191 } else if (colTyp == Types.TIMESTAMP) {
192 return "TIMESTAMP";
193 } else if (colTyp == Types.TINYINT) {
194 return "TINYINT";
195 } else if (colTyp == Types.VARBINARY) {
196 return "VARBINARY";
197 } else if (colTyp == Types.VARCHAR) {
198 return "VARCHAR";
199 }
200 return "OTHER";
201 }
202 /***
203 * Insérez la description de la méthode à cet endroit.
204 * Date de création : (28/01/01 17:06:36)
205 * @return int
206 */
207 public int getDecDigit() {
208 return decDigit;
209 }
210 /***
211 * Insérez la description de la méthode à cet endroit.
212 * Date de création : (28/01/01 17:06:36)
213 * @return int
214 */
215 public int getNumPrecRadix() {
216 return numPrecRadix;
217 }
218 /***
219 * Insérez la description de la méthode à cet endroit.
220 * Date de création : (28/01/01 17:06:36)
221 * @return java.lang.String
222 */
223 public java.lang.String getTableCat() {
224 return tableCat;
225 }
226 /***
227 * Insérez la description de la méthode à cet endroit.
228 * Date de création : (28/01/01 17:06:36)
229 * @return java.lang.String
230 */
231 public java.lang.String getTableName() {
232 return tableName;
233 }
234 /***
235 * Insérez la description de la méthode à cet endroit.
236 * Date de création : (28/01/01 17:06:36)
237 * @return java.lang.String
238 */
239 public java.lang.String getTableShem() {
240 return tableShem;
241 }
242 /***
243 * Insérez la description de la méthode à cet endroit.
244 * Date de création : (28/01/01 17:06:36)
245 * @return java.lang.String
246 */
247 public java.lang.String getTypName() {
248 return typName;
249 }
250 /***
251 * Insérez la description de la méthode à cet endroit.
252 * Date de création : (28/01/01 17:06:36)
253 * @param newColCharOctetLength int
254 */
255 public void setColCharOctetLength(int newColCharOctetLength) {
256 colCharOctetLength = newColCharOctetLength;
257 }
258 /***
259 * Insérez la description de la méthode à cet endroit.
260 * Date de création : (28/01/01 17:06:36)
261 * @param newColDefaultVal java.lang.String
262 */
263 public void setColDefaultVal(java.lang.String newColDefaultVal) {
264 colDefaultVal = newColDefaultVal;
265 }
266 /***
267 * Insérez la description de la méthode à cet endroit.
268 * Date de création : (28/01/01 17:06:36)
269 * @param newColIsNullable java.lang.String
270 */
271 public void setColIsNullable(java.lang.String newColIsNullable) {
272 colIsNullable = newColIsNullable;
273 }
274 /***
275 * Insérez la description de la méthode à cet endroit.
276 * Date de création : (28/01/01 17:06:36)
277 * @param newColName java.lang.String
278 */
279 public void setColName(java.lang.String newColName) {
280 colName = newColName;
281 }
282 /***
283 * Insérez la description de la méthode à cet endroit.
284 * Date de création : (28/01/01 17:06:36)
285 * @param newColNullable int
286 */
287 public void setColNullable(int newColNullable) {
288 colNullable = newColNullable;
289 }
290 /***
291 * Insérez la description de la méthode à cet endroit.
292 * Date de création : (28/01/01 17:06:36)
293 * @param newColPosition int
294 */
295 public void setColPosition(int newColPosition) {
296 colPosition = newColPosition;
297 }
298 /***
299 * Insérez la description de la méthode à cet endroit.
300 * Date de création : (28/01/01 17:06:36)
301 * @param newColRemarks java.lang.String
302 */
303 public void setColRemarks(java.lang.String newColRemarks) {
304 colRemarks = newColRemarks;
305 }
306 /***
307 * Insérez la description de la méthode à cet endroit.
308 * Date de création : (28/01/01 17:06:36)
309 * @param newColSize int
310 */
311 public void setColSize(int newColSize) {
312 colSize = newColSize;
313 }
314 /***
315 * Insérez la description de la méthode à cet endroit.
316 * Date de création : (28/01/01 17:06:36)
317 * @param newColTyp short
318 */
319 public void setColTyp(short newColTyp) {
320 colTyp = newColTyp;
321 }
322 /***
323 * Insérez la description de la méthode à cet endroit.
324 * Date de création : (28/01/01 17:06:36)
325 * @param newDecDigit int
326 */
327 public void setDecDigit(int newDecDigit) {
328 decDigit = newDecDigit;
329 }
330 /***
331 * Insérez la description de la méthode à cet endroit.
332 * Date de création : (28/01/01 17:06:36)
333 * @param newNumPrecRadix int
334 */
335 public void setNumPrecRadix(int newNumPrecRadix) {
336 numPrecRadix = newNumPrecRadix;
337 }
338 /***
339 * Insérez la description de la méthode à cet endroit.
340 * Date de création : (28/01/01 17:06:36)
341 * @param newTableCat java.lang.String
342 */
343 public void setTableCat(java.lang.String newTableCat) {
344 tableCat = newTableCat;
345 }
346 /***
347 * Insérez la description de la méthode à cet endroit.
348 * Date de création : (28/01/01 17:06:36)
349 * @param newTableName java.lang.String
350 */
351 public void setTableName(java.lang.String newTableName) {
352 tableName = newTableName;
353 }
354 /***
355 * Insérez la description de la méthode à cet endroit.
356 * Date de création : (28/01/01 17:06:36)
357 * @param newTableShem java.lang.String
358 */
359 public void setTableShem(java.lang.String newTableShem) {
360 tableShem = newTableShem;
361 }
362 /***
363 * Insérez la description de la méthode à cet endroit.
364 * Date de création : (28/01/01 17:06:36)
365 * @param newTypName java.lang.String
366 */
367 public void setTypName(java.lang.String newTypName) {
368 typName = newTypName;
369 }
370
371
372 public String createJavaTypName() {
373 if (colTyp == java.sql.Types.DATE
374 || colTyp == java.sql.Types.TIME
375 || colTyp == java.sql.Types.TIMESTAMP) {
376 return "Timestamp";
377 }
378 if (colTyp == java.sql.Types.NUMERIC
379 || colTyp == java.sql.Types.FLOAT
380 || colTyp == java.sql.Types.DECIMAL
381 || colTyp == java.sql.Types.REAL) {
382 if (decDigit > 0)
383 return "Double";
384 else
385 return "Integer";
386 }
387 if (colTyp == java.sql.Types.CHAR
388 || colTyp == java.sql.Types.LONGVARCHAR
389 || colTyp == java.sql.Types.VARCHAR
390 || typName.equalsIgnoreCase("nvarchar"))
391 return "String";
392 if (colTyp == java.sql.Types.BIT)
393 return "Boolean";
394 if (colTyp == java.sql.Types.TINYINT)
395 return "Byte";
396 if (colTyp == java.sql.Types.SMALLINT)
397 return "Short";
398 if (colTyp == java.sql.Types.INTEGER)
399 return "Integer";
400 if (colTyp == java.sql.Types.BIGINT)
401 return "Long";
402 if (colTyp == java.sql.Types.REAL || colTyp == java.sql.Types.FLOAT)
403 return "Float";
404 if (colTyp == java.sql.Types.DOUBLE)
405 return "Double";
406 if (colTyp == java.sql.Types.BINARY
407 || colTyp == java.sql.Types.VARBINARY
408 || colTyp == java.sql.Types.LONGVARBINARY)
409 return "byte[]";
410 return typName;
411 }
412
413 protected int pkColSeq = -1;
414
415
416 /***
417 * Insérez la description de la méthode à cet endroit.
418 * Date de création : (30/09/01 11:00:16)
419 * @return int
420 */
421 public int getPkColSeq() {
422 return pkColSeq;
423 }
424
425 /***
426 * Insérez la description de la méthode à cet endroit.
427 * Date de création : (30/09/01 11:00:16)
428 * @param newPkColSeq int
429 */
430 public void setPkColSeq(int newPkColSeq) {
431 pkColSeq = newPkColSeq;
432 }
433
434 /***
435 * Gets the tableInfo.
436 * @return Returns a TableInfo
437 */
438 public TableInfo getTableInfo() {
439 return tableInfo;
440 }
441
442 /***
443 * Sets the tableInfo.
444 * @param tableInfo The tableInfo to set
445 */
446 public void setTableInfo(TableInfo tableInfo) {
447 this.tableInfo = tableInfo;
448 }
449
450 /***
451 * @return
452 */
453 public boolean isAutoIncrement() {
454 return autoIncrement;
455 }
456
457 /***
458 * @param b
459 */
460 public void setAutoIncrement(boolean b) {
461 autoIncrement = b;
462 }
463
464 }