|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectca.sqlpower.architect.SQLObject
ca.sqlpower.architect.SQLTable
public class SQLTable
| Nested Class Summary | |
|---|---|
static class |
SQLTable.Folder<T extends SQLObject>
The Folder class is a SQLObject that holds a SQLTable's child folders (columns and relationships). |
| Field Summary | |
|---|---|
protected SQLTable.Folder<SQLColumn> |
columnsFolder
A List of SQLColumn objects which make up all the columns of this table. |
protected SQLTable.Folder<SQLRelationship> |
exportedKeysFolder
A List of SQLRelationship objects describing keys that this table exports. |
protected SQLTable.Folder<SQLRelationship> |
importedKeysFolder
A container for SQLRelationship objects describing keys that this table imports. |
protected SQLObject |
parent
|
protected java.lang.String |
physicalPrimaryKeyName
|
protected java.lang.String |
remarks
|
| Fields inherited from class ca.sqlpower.architect.SQLObject |
|---|
children, magicDisableCount, populated, undoEventListeners |
| Constructor Summary | |
|---|---|
SQLTable()
Creates a new SQLTable with no children, no parent, and all properties set to their defaults. |
|
SQLTable(SQLDatabase parent,
boolean startPopulated)
Creates a new SQLTable with parent as its parent and a null schema and catalog. |
|
SQLTable(SQLObject parent,
java.lang.String name,
java.lang.String remarks,
java.lang.String objectType,
boolean startPopulated)
|
|
| Method Summary | |
|---|---|
protected void |
addChildImpl(int index,
SQLObject child)
Connects up the columnsFolder, exportedKeysFolder, importedKeysFolder, and indicesFolder pointers to the children at indices 0, 1, 2, and 3 respectively. |
void |
addColumn(int pos,
SQLColumn col)
|
void |
addColumn(SQLColumn col)
|
void |
addIndex(SQLIndex idx)
Adds the given SQLIndex object to this table's index folder. |
boolean |
allowsChildren()
Returns true (tables have several folders as children). |
void |
changeColumnIndex(int oldIdx,
int newIdx,
boolean putInPK)
Moves the column at index oldIdx to index
newIdx. |
SQLCatalog |
getCatalog()
|
java.lang.String |
getCatalogName()
|
java.lang.Class<? extends SQLObject> |
getChildType()
|
SQLColumn |
getColumn(int idx)
|
SQLColumn |
getColumnByName(java.lang.String colName)
Populates this table then searches for the named column in a case-insensitive manner. |
SQLColumn |
getColumnByName(java.lang.String colName,
boolean populate,
boolean caseSensitive)
Searches for the named column. |
SQLColumn |
getColumnByName(java.lang.String colName,
boolean populate,
boolean caseSensitive,
java.sql.DatabaseMetaData dbmd)
|
SQLColumn |
getColumnByName(java.lang.String colName,
java.sql.DatabaseMetaData dbmd)
|
int |
getColumnIndex(SQLColumn col)
|
java.util.List<SQLColumn> |
getColumns()
Gets the value of columns |
SQLTable.Folder<SQLColumn> |
getColumnsFolder()
|
static SQLTable |
getDerivedInstance(SQLTable source,
SQLDatabase parent)
Creates a new SQLTable under the given parent database. |
SQLRelationship |
getExportedKeyByName(java.lang.String name)
Gets the value of exportedKeys by name |
SQLRelationship |
getExportedKeyByName(java.lang.String name,
boolean populate)
Gets the value of exportedKeys by name |
java.util.List<SQLRelationship> |
getExportedKeys()
Gets the value of exportedKeys |
java.util.List<SQLRelationship> |
getExportedKeys(java.sql.DatabaseMetaData dbmd)
|
SQLTable.Folder<SQLRelationship> |
getExportedKeysFolder()
|
java.util.List<SQLRelationship> |
getImportedKeys()
Gets the value of importedKeys |
SQLTable.Folder<SQLRelationship> |
getImportedKeysFolder()
|
SQLIndex |
getIndexByName(java.lang.String name)
Gets the value of index by name |
SQLIndex |
getIndexByName(java.lang.String name,
boolean populate)
Gets the value of index by name |
java.util.List<SQLIndex> |
getIndices()
Returns an unmodifiable list of all the indices of this table, in the same order they appear in the indices folder. |
SQLTable.Folder<SQLIndex> |
getIndicesFolder()
|
java.lang.String |
getObjectType()
Gets the type of table this object represents (TABLE or VIEW). |
SQLObject |
getParent()
Returns the parent of this SQLObject or null if it
is a root object such as SQLDatabase. |
SQLDatabase |
getParentDatabase()
Walks up the SQLObject containment hierarchy and returns the first SQLDatabase object encountered. |
java.lang.String |
getPhysicalPrimaryKeyName()
Gets the value of physicalPrimaryKeyName |
int |
getPkSize()
Counts the number of columns in the primary key of this table. |
SQLIndex |
getPrimaryKeyIndex()
Returns the primary key for this table, or null if none exists. |
java.lang.String |
getPrimaryKeyName()
Gets the name of this table's Primary Key index if it has one, otherwise returns null. |
java.lang.String |
getRemarks()
Gets the value of remarks |
SQLSchema |
getSchema()
|
java.lang.String |
getSchemaName()
|
java.lang.String |
getShortDisplayName()
The table's name. |
java.util.List<SQLIndex> |
getUniqueIndices()
Gets a list of unique indices |
void |
inherit(int pos,
SQLColumn sourceCol,
boolean addToPK)
|
void |
inherit(int pos,
SQLTable source)
Inserts all the columns of the given source table into this table at position pos. |
void |
inherit(SQLTable source)
Adds all the columns of the given source table to the end of this table's column list. |
void |
initFolders(boolean populated)
If you create a table from scratch using the no-args constructor, you should call this to create the standard set of Folder objects under this table. |
boolean |
isColumnsPopulated()
Returns true if this table's columns folder says it's populated. |
boolean |
isIndicesPopulated()
Returns true if this table's indices folder says it's populated. |
boolean |
isPopulated()
Tells if this object has already been filled with children, or if that operation is still pending. |
boolean |
isRelationshipsPopulated()
Returns true if this table's imported keys folder and exported keys folders both say they're populated. |
java.util.List<SQLRelationship> |
keysOfColumn(SQLColumn col)
|
void |
normalizePrimaryKey()
Renumbers the PrimaryKeySeq values of all columns in this table, then rebuilds this table's Primary Key Index so it correctly reflects the new PrimaryKeySeq column properties. |
void |
populate()
Since SQLTable is just a container for Folders, there is no special populate step. |
void |
removeColumn(int index)
Calls removeColumn(SQLColumn) with the appropriate argument. |
void |
removeColumn(SQLColumn col)
Removes the given column if it is in this table. |
void |
removeExportedKey(SQLRelationship r)
Convenience method for getExportedKeys.removeChild(r). |
void |
removeImportedKey(SQLRelationship r)
Convenience method for getImportedKeys.removeChild(r). |
void |
setName(java.lang.String argName)
Sets the table name, and also modifies the primary key name if it was previously null or set to the default of "oldTableName_pk". |
void |
setObjectType(java.lang.String argObjectType)
Sets the type of table this object represents (TABLE or VIEW). |
protected void |
setParent(SQLObject newParent)
Parents call this on their children to update parent pointers during addChild and removeChild requests. |
void |
setPhysicalPrimaryKeyName(java.lang.String argPhysicalPrimaryKeyName)
Sets the value of physicalPrimaryKeyName |
void |
setRemarks(java.lang.String argRemarks)
Sets the value of remarks |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected SQLObject parent
protected java.lang.String remarks
protected java.lang.String physicalPrimaryKeyName
protected SQLTable.Folder<SQLColumn> columnsFolder
protected SQLTable.Folder<SQLRelationship> exportedKeysFolder
protected SQLTable.Folder<SQLRelationship> importedKeysFolder
| Constructor Detail |
|---|
public SQLTable(SQLObject parent,
java.lang.String name,
java.lang.String remarks,
java.lang.String objectType,
boolean startPopulated)
throws ArchitectException
ArchitectException
public SQLTable(SQLDatabase parent,
boolean startPopulated)
throws ArchitectException
startPopulated - The initial setting of this table's folders' populated flags.
If this is set to false, the table will attempt to lazy-load the child folders. Otherwise,
this table will not try to load its children from a database connection.
ArchitectExceptionpublic SQLTable()
This is mainly for code that needs to reconstruct a SQLTable from outside configuration info, such as the SwingUIProject.load() method. If you want to make SQLTable objects from scratch, consider using one of the other constructors, which initialise the state more thoroughly.
| Method Detail |
|---|
public void initFolders(boolean populated)
throws ArchitectException
populated - The initial value to give the folders'
populated status. When loading from a file, this should be true;
if lazy loading from a database, it should be false.
ArchitectException
public static SQLTable getDerivedInstance(SQLTable source,
SQLDatabase parent)
throws ArchitectException
source - The table to copyparent - The database to insert the new table into
ArchitectException - if there are populate problems on source or parent
Or if the parent has children of type other than SQLTable.public void removeImportedKey(SQLRelationship r)
public void removeExportedKey(SQLRelationship r)
public int getPkSize()
public void inherit(SQLTable source)
throws ArchitectException
ArchitectException
public void inherit(int pos,
SQLTable source)
throws ArchitectException
pos.
If this table currently has no columns, then the source's primary key will remain intact (and this table will become an identical copy of source). If not, and if the insertion position <= this.pkSize(), then all source columns will be added to this table's primary key. Otherwise, no source columns will be added to this table's primary key.
ArchitectException
public void inherit(int pos,
SQLColumn sourceCol,
boolean addToPK)
throws ArchitectException
ArchitectException
public SQLColumn getColumn(int idx)
throws ArchitectException
ArchitectException
public SQLColumn getColumnByName(java.lang.String colName)
throws ArchitectException
ArchitectException
public SQLColumn getColumnByName(java.lang.String colName,
java.sql.DatabaseMetaData dbmd)
throws ArchitectException
ArchitectException
public SQLColumn getColumnByName(java.lang.String colName,
boolean populate,
boolean caseSensitive)
throws ArchitectException
populate - If true, this table will retrieve its column
list from the database; otherwise it just searches the current
list.
ArchitectException
public SQLColumn getColumnByName(java.lang.String colName,
boolean populate,
boolean caseSensitive,
java.sql.DatabaseMetaData dbmd)
throws ArchitectException
ArchitectException
public int getColumnIndex(SQLColumn col)
throws ArchitectException
ArchitectException
public void addColumn(SQLColumn col)
throws ArchitectException
ArchitectException
public void addColumn(int pos,
SQLColumn col)
throws ArchitectException
ArchitectException
public void addIndex(SQLIndex idx)
throws ArchitectException
ArchitectException
protected void addChildImpl(int index,
SQLObject child)
throws ArchitectException
addChildImpl in class SQLObjectindex - The index that the new child will havechild - The new child to add (must be same type as all other children)
ArchitectException - If you try to add a child of a different type than the existing children.
public void removeColumn(int index)
throws ArchitectException
removeColumn(SQLColumn) with the appropriate argument.
LockedColumnException - If the column is "owned" by a relationship, and cannot be
safely removed.
ArchitectException
public void removeColumn(SQLColumn col)
throws ArchitectException
#changeColumnIndex(int,int) method
because it does not throw LockedColumnException.
FIXME: This should be implemented by decreasing the column's reference count. (addColumn already does increase reference count when appropriate) Then, everything that manipulates reference counts directly can just use regular addColumn and removeColumn and magic will take care of the correct behaviour!
LockedColumnException - If the column is "owned" by a relationship, and cannot be
safely removed.
ArchitectException
public void changeColumnIndex(int oldIdx,
int newIdx,
boolean putInPK)
throws ArchitectException
oldIdx to index
newIdx. This may cause the moved column to become
part of the primary key (or to be removed from the primary
key).
oldIdx - the present index of the column.newIdx - the index that the column will have when this
method returns.
ArchitectException
public void normalizePrimaryKey()
throws ArchitectException
The process happens in three phases:
Assumptions:
ArchitectException
public java.util.List<SQLRelationship> keysOfColumn(SQLColumn col)
throws ArchitectException
ArchitectExceptionpublic java.lang.String toString()
toString in class java.lang.Objectpublic SQLObject getParent()
SQLObjectnull if it
is a root object such as SQLDatabase.
getParent in class SQLObjectprotected void setParent(SQLObject newParent)
SQLObject
setParent in class SQLObjectpublic java.lang.String getShortDisplayName()
getShortDisplayName in class SQLObject
public void populate()
throws ArchitectException
populate in class SQLObjectArchitectExceptionpublic boolean isPopulated()
SQLObject
isPopulated in class SQLObjectpublic boolean allowsChildren()
allowsChildren in class SQLObjectpublic java.lang.Class<? extends SQLObject> getChildType()
getChildType in class SQLObjectpublic SQLDatabase getParentDatabase()
public java.lang.String getCatalogName()
public SQLCatalog getCatalog()
public java.lang.String getSchemaName()
public SQLSchema getSchema()
public SQLTable.Folder<SQLColumn> getColumnsFolder()
public SQLTable.Folder<SQLRelationship> getImportedKeysFolder()
public SQLTable.Folder<SQLRelationship> getExportedKeysFolder()
public SQLTable.Folder<SQLIndex> getIndicesFolder()
public void setName(java.lang.String argName)
setName in class SQLObjectargName - The new table name. NULL is not allowed.public java.lang.String getRemarks()
public void setRemarks(java.lang.String argRemarks)
argRemarks - Value to assign to this.remarks
public java.util.List<SQLColumn> getColumns()
throws ArchitectException
ArchitectException
public java.util.List<SQLRelationship> getImportedKeys()
throws ArchitectException
ArchitectException
public java.util.List<SQLRelationship> getExportedKeys()
throws ArchitectException
ArchitectException
public java.util.List<SQLRelationship> getExportedKeys(java.sql.DatabaseMetaData dbmd)
throws ArchitectException
ArchitectException
public SQLRelationship getExportedKeyByName(java.lang.String name)
throws ArchitectException
ArchitectException
public SQLRelationship getExportedKeyByName(java.lang.String name,
boolean populate)
throws ArchitectException
ArchitectException
public java.util.List<SQLIndex> getUniqueIndices()
throws ArchitectException
ArchitectException
public SQLIndex getIndexByName(java.lang.String name)
throws ArchitectException
ArchitectException
public SQLIndex getIndexByName(java.lang.String name,
boolean populate)
throws ArchitectException
ArchitectExceptionpublic boolean isColumnsPopulated()
public boolean isRelationshipsPopulated()
public boolean isIndicesPopulated()
public java.lang.String getPrimaryKeyName()
throws ArchitectException
ArchitectException
public java.lang.String getPhysicalPrimaryKeyName()
throws ArchitectException
ArchitectExceptionpublic void setPhysicalPrimaryKeyName(java.lang.String argPhysicalPrimaryKeyName)
argPhysicalPrimaryKeyName - Value to assign to this.physicalPrimaryKeyNamepublic java.lang.String getObjectType()
public void setObjectType(java.lang.String argObjectType)
argObjectType - Value to assign to this.objectType
public SQLIndex getPrimaryKeyIndex()
throws ArchitectException
ArchitectException
public java.util.List<SQLIndex> getIndices()
throws ArchitectException
ArchitectException - If there is a problem populating the indices folder
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||