1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.services.sanity.SanityManager; 25 26 33 34 public class TableElementNode extends QueryTreeNode 35 { 36 42 public static final int AT_UNKNOWN = 0; 43 public static final int AT_ADD_FOREIGN_KEY_CONSTRAINT = 1; 44 public static final int AT_ADD_PRIMARY_KEY_CONSTRAINT = 2; 45 public static final int AT_ADD_UNIQUE_CONSTRAINT = 3; 46 public static final int AT_ADD_CHECK_CONSTRAINT = 4; 47 public static final int AT_DROP_CONSTRAINT = 5; 48 public static final int AT_MODIFY_COLUMN = 6; 49 public static final int AT_DROP_COLUMN = 7; 50 51 52 58 String name; 59 int elementType; 64 70 75 76 public void init(Object name) 77 { 78 this.name = (String ) name; 79 } 80 81 86 87 public void init(Object name, Object elementType) 88 { 89 this.name = (String ) name; 90 this.elementType = ((Integer ) elementType).intValue(); 91 } 92 93 99 100 public String toString() 101 { 102 if (SanityManager.DEBUG) 103 { 104 return "name: " + name + "\n" + 105 super.toString(); 106 } 107 else 108 { 109 return ""; 110 } 111 } 112 113 118 boolean hasPrimaryKeyConstraint() 119 { 120 return false; 121 } 122 123 128 boolean hasUniqueKeyConstraint() 129 { 130 return false; 131 } 132 133 138 boolean hasForeignKeyConstraint() 139 { 140 return false; 141 } 142 143 148 boolean hasCheckConstraint() 149 { 150 return false; 151 } 152 153 158 boolean hasConstraint() 159 { 160 return false; 161 } 162 163 168 public String getName() 169 { 170 return name; 171 } 172 173 178 int getElementType() 179 { 180 if ( hasForeignKeyConstraint() ) { return AT_ADD_FOREIGN_KEY_CONSTRAINT; } 181 else if ( hasPrimaryKeyConstraint() ) { return AT_ADD_PRIMARY_KEY_CONSTRAINT; } 182 else if ( hasUniqueKeyConstraint() ) { return AT_ADD_UNIQUE_CONSTRAINT; } 183 else if ( hasCheckConstraint() ) { return AT_ADD_CHECK_CONSTRAINT; } 184 else if ( this instanceof ConstraintDefinitionNode ) { return AT_DROP_CONSTRAINT; } 185 else if ( this instanceof ModifyColumnNode ) { return AT_MODIFY_COLUMN; } 186 else { return elementType; } 187 } 188 189 } 190 | Popular Tags |