001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.lib.ddl.impl;
043:
044: import java.util.*;
045: import org.netbeans.lib.ddl.*;
046: import org.netbeans.lib.ddl.impl.*;
047:
048: /**
049: * Interface of database action command. Instances should remember connection
050: * information of DatabaseSpecification and use it in execute() method. This is a base interface
051: * used heavily for sub-interfacing (it is not subclassing :)
052: *
053: * @author Slavek Psenicka
054: */
055: public class CreateTable extends ColumnListCommand {
056: static final long serialVersionUID = -6731725400393279232L;
057:
058: public CreateTable() {
059: setNewObject(true);
060: }
061:
062: public TableColumn createColumn(String name)
063: throws ClassNotFoundException, IllegalAccessException,
064: InstantiationException {
065: return specifyColumn(TableColumn.COLUMN, name,
066: Specification.CREATE_TABLE, true, true);
067: }
068:
069: public TableColumn createColumn(String type, String name)
070: throws ClassNotFoundException, IllegalAccessException,
071: InstantiationException {
072: return specifyColumn(type, name, Specification.CREATE_TABLE,
073: true, true);
074: }
075:
076: public TableColumn createUniqueColumn(String name)
077: throws ClassNotFoundException, IllegalAccessException,
078: InstantiationException {
079: TableColumn col = specifyColumn(TableColumn.UNIQUE, name,
080: Specification.CREATE_TABLE, true, true);
081: col.setObjectName(name + "_UQ"); // NOI18N
082: return col;
083: }
084:
085: public TableColumn createPrimaryKeyColumn(String name)
086: throws ClassNotFoundException, IllegalAccessException,
087: InstantiationException {
088: TableColumn col = specifyColumn(TableColumn.PRIMARY_KEY, name,
089: Specification.CREATE_TABLE, true, true);
090: col.setObjectName(name + "_PK"); // NOI18N
091: return col;
092: }
093:
094: public TableColumn createForeignKeyColumn(String name,
095: String rtablename, String rcolumnname)
096: throws ClassNotFoundException, IllegalAccessException,
097: InstantiationException {
098: TableColumn col = specifyColumn(TableColumn.FOREIGN_KEY, name,
099: Specification.CREATE_TABLE, true, true);
100: col.setObjectName(name + "_FK"); // NOI18N
101: col.setReferencedTableName(rtablename);
102: col.setReferencedColumnName(rcolumnname);
103: return col;
104: }
105:
106: public TableColumn createCheckColumn(String name, String expression)
107: throws ClassNotFoundException, IllegalAccessException,
108: InstantiationException {
109: TableColumn col = specifyColumn(TableColumn.CHECK, name,
110: Specification.CREATE_TABLE, true, true);
111: col.setObjectName(name + "_CH"); // NOI18N
112: col.setCheckCondition(expression);
113: return col;
114: }
115:
116: public TableColumn createUniqueConstraint(String columnname)
117: throws ClassNotFoundException, IllegalAccessException,
118: InstantiationException {
119: TableColumn col = specifyColumn(TableColumn.UNIQUE_CONSTRAINT,
120: columnname, Specification.CREATE_TABLE, true, true);
121: col.setObjectName(columnname + "_UQ"); // NOI18N
122: return col;
123: }
124:
125: public TableColumn createCheckConstraint(String name,
126: String expression) throws ClassNotFoundException,
127: IllegalAccessException, InstantiationException {
128: TableColumn col = specifyColumn(TableColumn.CHECK_CONSTRAINT,
129: name, Specification.CREATE_TABLE, true, true);
130: col.setObjectName(name + "_CH"); // NOI18N
131: col.setCheckCondition(expression);
132: return col;
133: }
134:
135: public TableColumn createPrimaryKeyConstraint(String columnname)
136: throws ClassNotFoundException, IllegalAccessException,
137: InstantiationException {
138: TableColumn col = specifyColumn(
139: TableColumn.PRIMARY_KEY_CONSTRAINT, columnname,
140: Specification.CREATE_TABLE, true, true);
141: col.setObjectName(columnname + "_PK"); // NOI18N
142: return col;
143: }
144:
145: public TableColumn createForeignKeyConstraint(String columnname,
146: String rtablename, String rcolumnname)
147: throws ClassNotFoundException, IllegalAccessException,
148: InstantiationException {
149: TableColumn col = specifyColumn(
150: TableColumn.FOREIGN_KEY_CONSTRAINT, columnname,
151: Specification.CREATE_TABLE, true, true);
152: col.setObjectName(columnname + "_FK"); // NOI18N
153: col.setReferencedTableName(rtablename);
154: col.setReferencedColumnName(rcolumnname);
155: return col;
156: }
157: }
158:
159: /*
160: * <<Log>>
161: * 6 Gandalf 1.5 10/22/99 Ian Formanek NO SEMANTIC CHANGE - Sun
162: * Microsystems Copyright in File Comment
163: * 5 Gandalf 1.4 9/10/99 Slavek Psenicka
164: * 4 Gandalf 1.3 8/17/99 Ian Formanek Generated serial version
165: * UID
166: * 3 Gandalf 1.2 5/14/99 Slavek Psenicka new version
167: * 2 Gandalf 1.1 4/23/99 Slavek Psenicka new version
168: * 1 Gandalf 1.0 4/6/99 Slavek Psenicka
169: * $
170: */
|