KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > ddl > impl > CreateTable


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.lib.ddl.impl;
21
22 import java.util.*;
23 import org.netbeans.lib.ddl.*;
24 import org.netbeans.lib.ddl.impl.*;
25
26 /**
27 * Interface of database action command. Instances should remember connection
28 * information of DatabaseSpecification and use it in execute() method. This is a base interface
29 * used heavily for sub-interfacing (it is not subclassing :)
30 *
31 * @author Slavek Psenicka
32 */

33 public class CreateTable extends ColumnListCommand
34 {
35     static final long serialVersionUID =-6731725400393279232L;
36     public TableColumn createColumn(String JavaDoc name)
37     throws ClassNotFoundException JavaDoc, IllegalAccessException JavaDoc, InstantiationException JavaDoc
38     {
39         return specifyColumn(TableColumn.COLUMN, name, Specification.CREATE_TABLE);
40     }
41
42     public TableColumn createColumn(String JavaDoc type, String JavaDoc name)
43     throws ClassNotFoundException JavaDoc, IllegalAccessException JavaDoc, InstantiationException JavaDoc
44     {
45         return specifyColumn(type, name, Specification.CREATE_TABLE);
46     }
47
48     public TableColumn createUniqueColumn(String JavaDoc name)
49     throws ClassNotFoundException JavaDoc, IllegalAccessException JavaDoc, InstantiationException JavaDoc
50     {
51         TableColumn col = specifyColumn(TableColumn.UNIQUE, name, Specification.CREATE_TABLE);
52         col.setObjectName(name+"_UQ"); // NOI18N
53
return col;
54     }
55
56     public TableColumn createPrimaryKeyColumn(String JavaDoc name)
57     throws ClassNotFoundException JavaDoc, IllegalAccessException JavaDoc, InstantiationException JavaDoc
58     {
59         TableColumn col = specifyColumn(TableColumn.PRIMARY_KEY, name, Specification.CREATE_TABLE);
60         col.setObjectName(name+"_PK"); // NOI18N
61
return col;
62     }
63
64     public TableColumn createForeignKeyColumn(String JavaDoc name, String JavaDoc rtablename, String JavaDoc rcolumnname)
65     throws ClassNotFoundException JavaDoc, IllegalAccessException JavaDoc, InstantiationException JavaDoc
66     {
67         TableColumn col = specifyColumn(TableColumn.FOREIGN_KEY, name, Specification.CREATE_TABLE);
68         col.setObjectName(name+"_FK"); // NOI18N
69
col.setReferencedTableName(rtablename);
70         col.setReferencedColumnName(rcolumnname);
71         return col;
72     }
73
74     public TableColumn createCheckColumn(String JavaDoc name, String JavaDoc expression)
75     throws ClassNotFoundException JavaDoc, IllegalAccessException JavaDoc, InstantiationException JavaDoc
76     {
77         TableColumn col = specifyColumn(TableColumn.CHECK, name, Specification.CREATE_TABLE);
78         col.setObjectName(name+"_CH"); // NOI18N
79
col.setCheckCondition(expression);
80         return col;
81     }
82
83     public TableColumn createUniqueConstraint(String JavaDoc columnname)
84     throws ClassNotFoundException JavaDoc, IllegalAccessException JavaDoc, InstantiationException JavaDoc
85     {
86         TableColumn col = specifyColumn(TableColumn.UNIQUE_CONSTRAINT, columnname, Specification.CREATE_TABLE);
87         col.setObjectName(columnname+"_UQ"); // NOI18N
88
return col;
89     }
90
91     public TableColumn createCheckConstraint(String JavaDoc name, String JavaDoc expression)
92     throws ClassNotFoundException JavaDoc, IllegalAccessException JavaDoc, InstantiationException JavaDoc
93     {
94         TableColumn col = specifyColumn(TableColumn.CHECK_CONSTRAINT, name, Specification.CREATE_TABLE);
95         col.setObjectName(name+"_CH"); // NOI18N
96
col.setCheckCondition(expression);
97         return col;
98     }
99
100     public TableColumn createPrimaryKeyConstraint(String JavaDoc columnname)
101     throws ClassNotFoundException JavaDoc, IllegalAccessException JavaDoc, InstantiationException JavaDoc
102     {
103         TableColumn col = specifyColumn(TableColumn.PRIMARY_KEY_CONSTRAINT, columnname, Specification.CREATE_TABLE);
104         col.setObjectName(columnname+"_PK"); // NOI18N
105
return col;
106     }
107
108     public TableColumn createForeignKeyConstraint(String JavaDoc columnname, String JavaDoc rtablename, String JavaDoc rcolumnname)
109     throws ClassNotFoundException JavaDoc, IllegalAccessException JavaDoc, InstantiationException JavaDoc
110     {
111         TableColumn col = specifyColumn(TableColumn.FOREIGN_KEY_CONSTRAINT, columnname, Specification.CREATE_TABLE);
112         col.setObjectName(columnname+"_FK"); // NOI18N
113
col.setReferencedTableName(rtablename);
114         col.setReferencedColumnName(rcolumnname);
115         return col;
116     }
117 }
118
119 /*
120 * <<Log>>
121 * 6 Gandalf 1.5 10/22/99 Ian Formanek NO SEMANTIC CHANGE - Sun
122 * Microsystems Copyright in File Comment
123 * 5 Gandalf 1.4 9/10/99 Slavek Psenicka
124 * 4 Gandalf 1.3 8/17/99 Ian Formanek Generated serial version
125 * UID
126 * 3 Gandalf 1.2 5/14/99 Slavek Psenicka new version
127 * 2 Gandalf 1.1 4/23/99 Slavek Psenicka new version
128 * 1 Gandalf 1.0 4/6/99 Slavek Psenicka
129 * $
130 */

131
Popular Tags