001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: /*
021: *
022: * Copyright 2005 Sun Microsystems, Inc.
023: *
024: * Licensed under the Apache License, Version 2.0 (the "License");
025: * you may not use this file except in compliance with the License.
026: * You may obtain a copy of the License at
027: *
028: * http://www.apache.org/licenses/LICENSE-2.0
029: *
030: * Unless required by applicable law or agreed to in writing, software
031: * distributed under the License is distributed on an "AS IS" BASIS,
032: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
033: * See the License for the specific language governing permissions and
034: * limitations under the License.
035: *
036: */
037: package org.netbeans.modules.jdbcwizard.builder.dbmodel;
038:
039: import java.util.List;
040: import java.util.Map;
041: import java.util.Set;
042:
043: /**
044: * Interface describing table metadata for data sources providing information in a database or
045: * database-like format. Implementing classes must support the Cloneable interface.
046: *
047: * @author
048: */
049: public interface DBTable extends Cloneable {
050:
051: /**
052: * Gets the user-defined name of this DBTable object.
053: *
054: * @return table name
055: */
056: public String getName();
057:
058: /**
059: * Gets the user-defined description String, if any, defined for this instance.
060: *
061: * @return description String, for this DBTable or null if none was defined.
062: */
063: public String getDescription();
064:
065: /**
066: * @param theColumn
067: * @return
068: */
069: public boolean addColumn(DBColumn theColumn);
070:
071: /**
072: * Gets name of the schema, if any, to which this DBTable belongs.
073: *
074: * @return schema name, or null if it doesn't belong to a schema
075: */
076: public String getSchema();
077:
078: /**
079: * Gets name of the catalog, if any, to which this DBTable belongs.
080: *
081: * @return catalog name, or null if it doesn't belong to a catalog
082: */
083: public String getCatalog();
084:
085: /**
086: * Get the column map for this table.
087: *
088: * @return Column metadata for this table.
089: */
090: public Map getColumns();
091:
092: /**
093: * Gets the DBColumn associated with the given name
094: *
095: * @param columnName column name
096: * @return The column value
097: */
098: public DBColumn getColumn(String columnName);
099:
100: /**
101: * Gets a read-only List of DBColumn instances contained in this table.
102: *
103: * @return read-only List of DBColumns
104: */
105: public List getColumnList();
106:
107: /**
108: * Get the DatabaseModel that contains this table.
109: *
110: * @return the instance of data source
111: */
112: public DatabaseModel getParent();
113:
114: /**
115: * Gets PrimaryKey, if any, defined on this table.
116: *
117: * @return PrimaryKey instance containing metadata for this table's PK, or null if no PK is
118: * defined
119: */
120: public PrimaryKey getPrimaryKey();
121:
122: /**
123: * Gets a List of ForeignKeys defined on columns in this DBTable.
124: *
125: * @return List of ForeignKeys defined on columns of this table; returns empty List if no
126: * ForeignKeys exist
127: */
128: public List getForeignKeys();
129:
130: /**
131: * Gets the ForeignKey instance, if any, associated with the given FK name.
132: *
133: * @param fkName name of FK to locate
134: * @return ForeignKey associated with fkName, or null if not found.
135: */
136: public ForeignKey getForeignKey(String fkName);
137:
138: /**
139: * Gets a read-only Set of DBTables, if any, whose primary keys are referenced by foreign key
140: * columns in this table.
141: *
142: * @return read-only List of names of tables referenced by columns in this table; returns empty
143: * List if this DBTable has no FK columns.
144: */
145: public Set getReferencedTables();
146:
147: /**
148: * Indicates whether the given table is referenced by one or more foreign key in this table.
149: *
150: * @param pkTarget table whose relationship with this table are to be checked
151: * @return true if this table has one or more FKs that reference pkTarget, false otherwise
152: */
153: public boolean references(DBTable pkTarget);
154:
155: /**
156: * Gets ForeignKey, if any, that references a corresponding PrimaryKey in the given DBTable.
157: *
158: * @param target DBTable whose relationship to this table is to be tested
159: * @return ForeignKey instance representing reference to target, or null if no such reference
160: * exists.
161: */
162: public ForeignKey getReferenceFor(DBTable target);
163:
164: /**
165: * Gets List of Index objects representing indices defined on columns of this table.
166: *
167: * @return List of Indexes defined on this table; returns empty List if no indexes are defined.
168: */
169: public List getIndexes();
170:
171: /**
172: * Gets Index, if any, associated with the given name.
173: *
174: * @param indexName name of index, if any, to be retrieved
175: * @return Index instance associated with indexName, or null if none was found.
176: */
177: public Index getIndex(String indexName);
178:
179: /**
180: * Indicates whether table is editable.
181: *
182: * @return true if table is editable, false otherwise
183: */
184: public boolean isEditable();
185:
186: public boolean isSelected();
187:
188: /**
189: * . set table editable
190: */
191: public void setEditable(boolean isEditable);
192:
193: public void setSelected(boolean select);
194:
195: /**
196: * @return
197: */
198: public boolean isSelectedforAnOperation();
199:
200: public void setSelectedforAllOperations(boolean setAll);
201:
202: }
|