KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nilostep > xlsql > sql > xlSqlRenameTable


1 /*(Header: NiLOSTEP / xlSQL)
2
3     Copyright (C) 2004 NiLOSTEP Information Sciences, all
4     rights reserved.
5     
6     This program is licensed under the terms of the GNU
7     General Public License.You should have received a copy
8     of the GNU General Public License along with this
9     program;
10 */

11
12 package com.nilostep.xlsql.sql;
13
14 import com.nilostep.xlsql.database.xlDatabase;
15 import com.nilostep.xlsql.database.*;
16
17 import java.sql.*;
18
19 /**
20  * DOCUMENT ME!
21  *
22  * @author Jim Caprioli
23  */

24 public class xlSqlRenameTable implements xlSqlCommand {
25     //~ Instance variables ·····················································
26

27     protected com.nilostep.xlsql.database.xlDatabase db;
28     protected String JavaDoc _schema;
29     protected String JavaDoc _table;
30     protected String JavaDoc _schema_old;
31     protected String JavaDoc _table_old;
32
33     /**
34      * Creates a new instance of type xlSqlRenameTable.
35      *
36      *
37      * @param database
38      * @param schema
39      * @param table
40      */

41     public xlSqlRenameTable(com.nilostep.xlsql.database.xlDatabase database, String JavaDoc schema, String JavaDoc table,
42                                         String JavaDoc schema_old, String JavaDoc table_old) {
43         if (database == null) {
44             throw new NullPointerException JavaDoc("xlSQL: database null");
45         } else {
46             db = database;
47         }
48
49         if (schema == null) {
50             throw new NullPointerException JavaDoc("xlSQL: schema null");
51         } else {
52             _schema = schema;
53         }
54
55         if (table == null) {
56             throw new NullPointerException JavaDoc("xlSQL: table null");
57         } else {
58             _table = table;
59         }
60
61         if (schema_old == null) {
62             throw new NullPointerException JavaDoc("xlSQL: schema_old null");
63         } else {
64             _schema_old = schema_old;
65         }
66
67         if (table_old == null) {
68             throw new NullPointerException JavaDoc("xlSQL: table_old null");
69         } else {
70             _table_old = table_old;
71         }
72     }
73
74     /**
75      * TODO: javadoc
76      *
77      * @return true if allowed
78      *
79      * @throws SQLException
80      */

81     public boolean execAllowed() throws SQLException {
82         boolean ret = true;
83         if (db.tableExists(_schema, _table)) {
84             ret = false;
85         }
86         return ret;
87     }
88
89     /**
90      * TODO: javadoc
91      *
92      * @throws SQLException
93      */

94     public void execute() throws SQLException {
95         db.removeTable(_schema_old, _table_old);
96         db.addSchema(_schema);
97         db.addTable(_schema, _table);
98     }
99 }
Popular Tags