001 /* 002 * JBoss DNA (http://www.jboss.org/dna) 003 * See the COPYRIGHT.txt file distributed with this work for information 004 * regarding copyright ownership. Some portions may be licensed 005 * to Red Hat, Inc. under one or more contributor license agreements. 006 * See the AUTHORS.txt file in the distribution for a full listing of 007 * individual contributors. 008 * 009 * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA 010 * is licensed to you under the terms of the GNU Lesser General Public License as 011 * published by the Free Software Foundation; either version 2.1 of 012 * the License, or (at your option) any later version. 013 * 014 * JBoss DNA is distributed in the hope that it will be useful, 015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 017 * Lesser General Public License for more details. 018 * 019 * You should have received a copy of the GNU Lesser General Public 020 * License along with this software; if not, write to the Free 021 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 022 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 023 */ 024 package org.jboss.dna.common.jdbc.model.api; 025 026 import java.util.Set; 027 028 /** 029 * Provides all core database table specific metadata. 030 * 031 * @author <a href="mailto:litsenko_sergey@yahoo.com">Sergiy Litsenko</a> 032 */ 033 public interface Table extends SchemaObject { 034 035 /** 036 * Returns type of table such as: "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM". 037 * 038 * @return type of table. 039 */ 040 TableType getTableType(); 041 042 /** 043 * Sets type of table such as: "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM". 044 * 045 * @param tableType the type of table. 046 */ 047 void setTableType( TableType tableType ); 048 049 /** 050 * Gets type catalog 051 * 052 * @return types catalog (may be <code>null</code>) 053 */ 054 Catalog getTypeCatalog(); 055 056 /** 057 * Sets type catalog 058 * 059 * @param typeCatalog the types catalog (may be <code>null</code>) 060 */ 061 void setTypeCatalog( Catalog typeCatalog ); 062 063 /** 064 * Gets type schema 065 * 066 * @return types schema (may be <code>null</code>) 067 */ 068 Schema getTypeSchema(); 069 070 /** 071 * Sets type schema 072 * 073 * @param typeSchema the types schema (may be <code>null</code>) 074 */ 075 void setTypeSchema( Schema typeSchema ); 076 077 /** 078 * Gets type name 079 * 080 * @return types name (may be <code>null</code>) 081 */ 082 String getTypeName(); 083 084 /** 085 * Sets type name 086 * 087 * @param typeName types name (may be <code>null</code>) 088 */ 089 void setTypeName( String typeName ); 090 091 /** 092 * Gets name of the designated "identifier" column of a typed table (may be <code>null</code>) 093 * 094 * @return name of the designated "identifier" column of a typed table (may be <code>null</code>) 095 */ 096 String getSelfReferencingColumnName(); 097 098 /** 099 * Sets name of the designated "identifier" column of a typed table (may be <code>null</code>) 100 * 101 * @param selfReferencingColumnName the name of the designated "identifier" column of a typed table (may be <code>null</code>) 102 */ 103 void setSelfReferencingColumnName( String selfReferencingColumnName ); 104 105 /** 106 * specifies how values in getSelfReferencingColumnName () are created. Values are "SYSTEM", "USER", "DERIVED". (may be 107 * <code>null</code>) 108 * 109 * @return how values in getSelfReferencingColumnName () are created. 110 */ 111 String getReferenceGeneration(); 112 113 /** 114 * specifies how values in getSelfReferencingColumnName () are created. Values are "SYSTEM", "USER", "DERIVED". (may be 115 * <code>null</code>) 116 * 117 * @param referenceGeneration how values in getSelfReferencingColumnName () are created. 118 */ 119 void setReferenceGeneration( String referenceGeneration ); 120 121 /** 122 * Gets a set of table columns 123 * 124 * @return a set of table columns. 125 */ 126 Set<TableColumn> getColumns(); 127 128 /** 129 * Adds TableColumn 130 * 131 * @param column the TableColumn 132 */ 133 void addColumn( TableColumn column ); 134 135 /** 136 * deletes TableColumn 137 * 138 * @param column the TableColumn 139 */ 140 void deleteColumn( TableColumn column ); 141 142 /** 143 * Returns table column for specified column name or null 144 * 145 * @param columnName the name of column 146 * @return table column for specified column name or null. 147 */ 148 TableColumn findColumnByName( String columnName ); 149 150 /** 151 * Gets a table primary key 152 * 153 * @return a table primary key. 154 */ 155 PrimaryKey getPrimaryKey(); 156 157 /** 158 * Sets a table primary key 159 * 160 * @param primaryKey the table primary key. 161 */ 162 void setPrimaryKey( PrimaryKey primaryKey ); 163 164 /** 165 * Gets a set of table foreign key columns 166 * 167 * @return a set of table foreign keys. 168 */ 169 Set<ForeignKey> getForeignKeys(); 170 171 /** 172 * adds ForeignKey 173 * 174 * @param foreignKey the ForeignKey 175 */ 176 void addForeignKey( ForeignKey foreignKey ); 177 178 /** 179 * deletes ForeignKey 180 * 181 * @param foreignKey the ForeignKey 182 */ 183 void deleteForeignKey( ForeignKey foreignKey ); 184 185 /** 186 * Returns table foreign key for specified name or null 187 * 188 * @param fkName the name of foreign key 189 * @return table foreign key for specified name or null. 190 */ 191 ForeignKey findForeignKeyByName( String fkName ); 192 193 /** 194 * Gets a set of table indexes 195 * 196 * @return a set of table indexes. 197 */ 198 Set<Index> getIndexes(); 199 200 /** 201 * adds Index 202 * 203 * @param index the Index 204 */ 205 void addIndex( Index index ); 206 207 /** 208 * deletes Index 209 * 210 * @param index the Index 211 */ 212 void deleteIndex( Index index ); 213 214 /** 215 * Returns table index for specified name or null 216 * 217 * @param indexName the name of index 218 * @return table index for specified name or null. 219 */ 220 Index findIndexByName( String indexName ); 221 222 /** 223 * Gets a set of table version columns 224 * 225 * @return a set of table version columns. 226 */ 227 Set<TableColumn> getVersionColumns(); 228 229 /** 230 * adds version column 231 * 232 * @param tableColumn the TableColumn 233 */ 234 void addVersionColumn( TableColumn tableColumn ); 235 236 /** 237 * deletes version column 238 * 239 * @param tableColumn the version column 240 */ 241 void deleteVersionColumn( TableColumn tableColumn ); 242 243 /** 244 * Returns table version column for specified name or null 245 * 246 * @param columnName the name of Version Column 247 * @return table Version Column for specified name or null. 248 */ 249 TableColumn findVersionColumnByName( String columnName ); 250 251 /** 252 * Gets table privileges. 253 * 254 * @return set of table privileges 255 */ 256 Set<Privilege> getPrivileges(); 257 258 /** 259 * Adds table priviledge 260 * 261 * @param privilege the table priviledge 262 */ 263 void addPrivilege( Privilege privilege ); 264 265 /** 266 * Deletes table priviledge 267 * 268 * @param privilege the table priviledge 269 */ 270 void deletePrivilege( Privilege privilege ); 271 272 /** 273 * Searches priviledge by name 274 * 275 * @param priviledgeName the priviledge name to search 276 * @return priviledge if found, otherwise return null 277 */ 278 Privilege findPriviledgeByName( String priviledgeName ); 279 280 /** 281 * Retrieves a set of descriptions of a table's optimal set of columns that uniquely identifies a row in temporary scopes. 282 * 283 * @return BestRowIdentifier set that uniquely identifies a row in scopes. 284 */ 285 Set<BestRowIdentifier> getBestRowIdentifiers(); 286 287 /** 288 * Adds BestRowIdentifier 289 * 290 * @param bestRowIdentifier the BestRowIdentifier 291 */ 292 void addBestRowIdentifier( BestRowIdentifier bestRowIdentifier ); 293 294 /** 295 * deletes BestRowIdentifier 296 * 297 * @param bestRowIdentifier the BestRowIdentifier 298 */ 299 void deleteBestRowIdentifier( BestRowIdentifier bestRowIdentifier ); 300 301 /** 302 * Searches the BestRowIdentifier by scope 303 * 304 * @param scopeType the scope of best row identifier 305 * @return BestRowIdentifier if any 306 */ 307 BestRowIdentifier findBestRowIdentifierByScopeType( BestRowIdentifierScopeType scopeType ); 308 309 // =============================================================== 310 // ------------------- JDBC 3.0 --------------------------------- 311 // =============================================================== 312 313 /** 314 * Retrieves a description of the table hierarchies defined in a particular schema in this database. Only the immediate super 315 * type/ sub type relationship is modeled. 316 * 317 * @return super table for this table 318 * @since 1.4 (JDBC 3.0) 319 */ 320 Table getSuperTable(); 321 322 /** 323 * Sets a description of the table hierarchies defined in a particular schema in this database. Only the immediate super type/ 324 * sub type relationship is modeled. 325 * 326 * @param superTable the super table for this table 327 * @since 1.4 (JDBC 3.0) 328 */ 329 void setSuperTable( Table superTable ); 330 }