|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.afcs.warts.db.TableDescription
A TableDescription class contains information about a particular database table, including the source account, the descriptions of each column, and the number of primary key columns.
LICENSE: This code is released to the public domain and may be used for any purpose whatsoever without permission or acknowledgment.
Constructor Summary | |
TableDescription(AccountConfiguration accountConfiguration,
java.lang.String owner,
java.lang.String name,
java.util.List columnDescriptions,
int numPrimaryColumns,
boolean fakePrimaryKeys)
Initialises a new table description with the specified information. |
Method Summary | |
int |
bindPrimaryKeyValues(java.sql.PreparedStatement statement,
java.util.List primaryKeyValues,
int offset)
This method loops through the specified list of primary key values, using the column descriptions maintained internally to bind them to variables in the specified prepared statement, starting at the specified offset. |
boolean |
dataHandlersOK()
Returns true if valid data handlers exist for the primary key columns in this table. |
java.lang.String |
describeFirstEquivalenceIssue(TableDescription anotherTableDescription)
Returns a text description of the first reason that can be found for this table not being equivalent to the specified table. |
boolean |
equals(java.lang.Object otherObj)
Returns true if the current table description describes the same table reached via the same account configuration as the specified object. |
TableDescription |
findEquivalentDescription(java.util.List accountConfigurations,
AccountConfiguration preferredAccount)
This method looks through all of the tables reachable through the account configurations in the specified list, returning the first table that is equivalent to the current table (but isn't in the current account), or null if no equivalent table can be found. |
AccountConfiguration |
getAccountConfiguration()
Returns the account configuration used to load this table. |
ColumnDescription |
getColumnDescription(int columnIndex)
Returns the column description for the specified column. |
java.util.List |
getColumnDescriptions()
Returns an unmodifiable list containing all of the columns in this table, with primary key columns first. |
java.lang.String |
getName()
Returns the name of the table. |
java.util.List |
getNonPrimaryColumns()
Returns an unmodifiable list containing the primary key columns in this table. |
int |
getNumNonPrimaryKeyColumns()
Returns the number of non-primary key columns. |
int |
getNumPrimaryKeyColumns()
Returns the number of primary key columns. |
java.lang.String |
getOwner()
Returns the owner of the table. |
java.util.List |
getPrimaryKeyColumns()
Returns an unmodifiable list containing the non-primary key columns in this table. |
java.lang.String |
getQualifiedName()
Returns the qualified name of the table, which is in the form 'owner.name'. |
java.lang.String |
getQualifiedNameSql()
Returns the qualified name of the table for use in SQL statements, which is in the form '"owner"."name"'. |
java.lang.String |
getQualifiedNameWithAccount()
Returns the qualified name of the table with information about the account from which the table was referenced (which includes the machine name). |
java.lang.String |
getWhereClause()
Returns the where clause appropriate for use in a prepared statement that will be selecting or updating a value given primary key values that identify the row. |
boolean |
hasFakePrimaryColumns()
Returns true if the primary key columns in this table are not actually primary key columns. |
int |
hashCode()
Returns a hashcode for this instance that obeys the general contract. |
boolean |
isEquivalentTo(TableDescription anotherTableDescription)
Returns true if the specified table is equivalent to this one. |
java.lang.String |
toString()
Returns a text description of the current instance that can be used for debugging purposes. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public TableDescription(AccountConfiguration accountConfiguration, java.lang.String owner, java.lang.String name, java.util.List columnDescriptions, int numPrimaryColumns, boolean fakePrimaryKeys)
accountConfiguration
- The account configuration from which the
table was loaded.owner
- The owner of the table (which is not necessarily the
owner of the account used to load the table). This is
case sensitive.name
- The name of the table, which is case sensitive.columnDescriptions
- The list of columns in the table.numPrimaryColumns
- The number of primary key columns.fakePrimaryKeys
- Whether or not the primary key columns are fake.
This can be used when a table has no primary key columns,
in which case all columns are taken to be primary key
columns.Method Detail |
public int bindPrimaryKeyValues(java.sql.PreparedStatement statement, java.util.List primaryKeyValues, int offset) throws java.sql.SQLException
statement
- The prepared statement to bind values to.primaryKeyValues
- The list of primary key values.offset
- The variable index to start binding variables at.
java.sql.SQLException
- If a SQL error occurs while binding any errors.
java.lang.NullPointerException
- If statement or primaryKeyValues is null.
java.lang.IllegalArgumentException
- If the length of primaryKeyValues is
less than the number of primary key columns.public boolean dataHandlersOK()
public boolean hasFakePrimaryColumns()
public java.lang.String getName()
public int getNumNonPrimaryKeyColumns()
public int getNumPrimaryKeyColumns()
public java.lang.String getOwner()
public java.lang.String getQualifiedName()
public java.lang.String getQualifiedNameSql()
public java.lang.String getQualifiedNameWithAccount()
public ColumnDescription getColumnDescription(int columnIndex)
columnIndex
- The index of the column to look up.
java.lang.IllegalArgumentException
- If columnIndex is out of bounds.public java.util.List getColumnDescriptions()
public java.util.List getNonPrimaryColumns()
public java.util.List getPrimaryKeyColumns()
public AccountConfiguration getAccountConfiguration()
public java.lang.String getWhereClause()
bindPrimaryKeyValues(java.sql.PreparedStatement, java.util.List, int)
can then be used to bind
primary key values to the SQL statement generated.
public boolean isEquivalentTo(TableDescription anotherTableDescription)
anotherTableDescription
- The other table description to compare to
this one.
java.lang.NullPointerException
- If anotherTableDescription is null.public java.lang.String describeFirstEquivalenceIssue(TableDescription anotherTableDescription)
isEquivalentTo(org.afcs.warts.db.TableDescription)
returns false for the same table, this is useful
for finding out why. It will return null if the tables are equivalent.
anotherTableDescription
- The other table to compare the current
instance to.
java.lang.NullPointerException
- If anotherTableDescription is null.public TableDescription findEquivalentDescription(java.util.List accountConfigurations, AccountConfiguration preferredAccount)
isEquivalentTo(TableDescription)
.
accountConfigurations
- The list of account configurations to search.preferredAccount
- If this is non-null, then we look for equivalent
tables in this account first and return any matches if
found.
java.lang.NullPointerException
- If accountConfigurations is null.public boolean equals(java.lang.Object otherObj)
otherObj
- The other object to compare this instance to.
public int hashCode()
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |