1 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 33 public class CreateTable extends ColumnListCommand 34 { 35 static final long serialVersionUID =-6731725400393279232L; 36 public TableColumn createColumn(String name) 37 throws ClassNotFoundException , IllegalAccessException , InstantiationException 38 { 39 return specifyColumn(TableColumn.COLUMN, name, Specification.CREATE_TABLE); 40 } 41 42 public TableColumn createColumn(String type, String name) 43 throws ClassNotFoundException , IllegalAccessException , InstantiationException 44 { 45 return specifyColumn(type, name, Specification.CREATE_TABLE); 46 } 47 48 public TableColumn createUniqueColumn(String name) 49 throws ClassNotFoundException , IllegalAccessException , InstantiationException 50 { 51 TableColumn col = specifyColumn(TableColumn.UNIQUE, name, Specification.CREATE_TABLE); 52 col.setObjectName(name+"_UQ"); return col; 54 } 55 56 public TableColumn createPrimaryKeyColumn(String name) 57 throws ClassNotFoundException , IllegalAccessException , InstantiationException 58 { 59 TableColumn col = specifyColumn(TableColumn.PRIMARY_KEY, name, Specification.CREATE_TABLE); 60 col.setObjectName(name+"_PK"); return col; 62 } 63 64 public TableColumn createForeignKeyColumn(String name, String rtablename, String rcolumnname) 65 throws ClassNotFoundException , IllegalAccessException , InstantiationException 66 { 67 TableColumn col = specifyColumn(TableColumn.FOREIGN_KEY, name, Specification.CREATE_TABLE); 68 col.setObjectName(name+"_FK"); col.setReferencedTableName(rtablename); 70 col.setReferencedColumnName(rcolumnname); 71 return col; 72 } 73 74 public TableColumn createCheckColumn(String name, String expression) 75 throws ClassNotFoundException , IllegalAccessException , InstantiationException 76 { 77 TableColumn col = specifyColumn(TableColumn.CHECK, name, Specification.CREATE_TABLE); 78 col.setObjectName(name+"_CH"); col.setCheckCondition(expression); 80 return col; 81 } 82 83 public TableColumn createUniqueConstraint(String columnname) 84 throws ClassNotFoundException , IllegalAccessException , InstantiationException 85 { 86 TableColumn col = specifyColumn(TableColumn.UNIQUE_CONSTRAINT, columnname, Specification.CREATE_TABLE); 87 col.setObjectName(columnname+"_UQ"); return col; 89 } 90 91 public TableColumn createCheckConstraint(String name, String expression) 92 throws ClassNotFoundException , IllegalAccessException , InstantiationException 93 { 94 TableColumn col = specifyColumn(TableColumn.CHECK_CONSTRAINT, name, Specification.CREATE_TABLE); 95 col.setObjectName(name+"_CH"); col.setCheckCondition(expression); 97 return col; 98 } 99 100 public TableColumn createPrimaryKeyConstraint(String columnname) 101 throws ClassNotFoundException , IllegalAccessException , InstantiationException 102 { 103 TableColumn col = specifyColumn(TableColumn.PRIMARY_KEY_CONSTRAINT, columnname, Specification.CREATE_TABLE); 104 col.setObjectName(columnname+"_PK"); return col; 106 } 107 108 public TableColumn createForeignKeyConstraint(String columnname, String rtablename, String rcolumnname) 109 throws ClassNotFoundException , IllegalAccessException , InstantiationException 110 { 111 TableColumn col = specifyColumn(TableColumn.FOREIGN_KEY_CONSTRAINT, columnname, Specification.CREATE_TABLE); 112 col.setObjectName(columnname+"_FK"); col.setReferencedTableName(rtablename); 114 col.setReferencedColumnName(rcolumnname); 115 return col; 116 } 117 } 118 119 131 | Popular Tags |