1 21 22 package org.apache.derby.iapi.sql.dictionary; 23 24 import org.apache.derby.iapi.sql.depend.Provider; 25 import org.apache.derby.iapi.sql.depend.Dependent; 26 27 import org.apache.derby.iapi.reference.SQLState; 28 import org.apache.derby.iapi.services.sanity.SanityManager; 29 import org.apache.derby.iapi.sql.StatementType; 30 import org.apache.derby.catalog.DependableFinder; 31 import org.apache.derby.catalog.Dependable; 32 import org.apache.derby.iapi.services.io.StoredFormatIds; 33 import org.apache.derby.iapi.error.StandardException; 34 import org.apache.derby.iapi.sql.depend.DependencyManager; 35 import org.apache.derby.iapi.sql.depend.Dependent; 36 import org.apache.derby.iapi.sql.depend.Dependency; 37 import org.apache.derby.iapi.sql.depend.Provider; 38 import org.apache.derby.iapi.services.i18n.MessageService; 39 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext; 40 import org.apache.derby.catalog.UUID; 41 42 47 48 public final class DefaultDescriptor 49 extends TupleDescriptor 50 implements UniqueTupleDescriptor, Provider, Dependent 51 { 52 private final int columnNumber; 53 private final UUID defaultUUID; 54 private final UUID tableUUID; 55 56 64 65 public DefaultDescriptor(DataDictionary dataDictionary, UUID defaultUUID, UUID tableUUID, int columnNumber) 66 { 67 super( dataDictionary ); 68 69 this.defaultUUID = defaultUUID; 70 this.tableUUID = tableUUID; 71 this.columnNumber = columnNumber; 72 } 73 74 79 public UUID getUUID() 80 { 81 return defaultUUID; 82 } 83 84 89 public UUID getTableUUID() 90 { 91 return tableUUID; 92 } 93 94 99 public int getColumnNumber() 100 { 101 return columnNumber; 102 } 103 104 109 110 public String toString() 111 { 112 if (SanityManager.DEBUG) 113 { 114 118 return "defaultUUID: " + defaultUUID + "\n" + 119 "tableUUID: " + tableUUID + "\n" + 120 "columnNumber: " + columnNumber + "\n"; 121 } 122 else 123 { 124 return ""; 125 } 126 } 127 128 134 139 public DependableFinder getDependableFinder() 140 { 141 return getDependableFinder(StoredFormatIds.DEFAULT_DESCRIPTOR_FINDER_V01_ID); 142 } 143 144 149 public String getObjectName() 150 { 151 return "default"; 152 } 153 154 159 public UUID getObjectID() 160 { 161 return defaultUUID; 162 } 163 164 169 public String getClassType() 170 { 171 return Dependable.DEFAULT; 172 } 173 174 184 public synchronized boolean isValid() 185 { 186 return true; 187 } 188 189 198 public void prepareToInvalidate(Provider p, int action, 199 LanguageConnectionContext lcc) 200 throws StandardException 201 { 202 DependencyManager dm = getDataDictionary().getDependencyManager(); 203 204 switch (action) 205 { 206 210 default: 211 DataDictionary dd = getDataDictionary(); 212 ColumnDescriptor cd = dd.getColumnDescriptorByDefaultId(defaultUUID); 213 TableDescriptor td = dd.getTableDescriptor(cd.getReferencingUUID()); 214 215 throw StandardException.newException(SQLState.LANG_PROVIDER_HAS_DEPENDENT_OBJECT, 216 dm.getActionString(action), 217 p.getObjectName(), 218 MessageService.getTextMessage( 219 SQLState.LANG_COLUMN_DEFAULT 220 ), 221 td.getQualifiedName() + "." + 222 cd.getColumnName()); 223 } 224 } 225 226 235 public void makeInvalid(int action, LanguageConnectionContext lcc) 236 throws StandardException 237 { 238 242 if (SanityManager.DEBUG) 243 { 244 DependencyManager dm; 245 246 dm = getDataDictionary().getDependencyManager(); 247 248 SanityManager.THROWASSERT("makeInvalid("+ 249 dm.getActionString(action)+ 250 ") not expected to get called"); 251 } 252 } 253 254 258 public void makeValid(LanguageConnectionContext lcc) 259 { 260 } 261 262 } 263 | Popular Tags |