public class Database extends Object implements Serializable
| Constructor and Description |
|---|
Database()
Creates an empty model without a name.
|
Database(String name)
Creates an empty model with the given name.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTable(int idx,
Table table)
Adds a table at the specified position.
|
void |
addTable(Table table)
Adds a table.
|
void |
addTables(Collection tables)
Adds the given tables.
|
org.apache.commons.beanutils.DynaBean |
createDynaBeanFor(String tableName,
boolean caseSensitive)
Convenience method that combines
createDynaBeanFor(Table) and
findTable(String, boolean). |
org.apache.commons.beanutils.DynaBean |
createDynaBeanFor(Table table)
Creates a new dyna bean for the given table.
|
boolean |
equals(Object obj) |
Table |
findTable(String name)
Finds the table with the specified name, using case insensitive matching.
|
Table |
findTable(String name,
boolean caseSensitive)
Finds the table with the specified name, using case insensitive matching.
|
Table[] |
findTables(String[] tableNames,
boolean caseSensitive)
Returns the indicated tables.
|
Table[] |
findTables(String tableNameRegExp,
boolean caseSensitive)
Finds the tables whose names match the given regular expression.
|
SqlDynaClass |
getDynaClassFor(org.apache.commons.beanutils.DynaBean bean)
Returns the
SqlDynaClass for the given dyna bean. |
SqlDynaClass |
getDynaClassFor(String tableName)
Returns the
SqlDynaClass for the given table name. |
String |
getIdMethod()
Returns the method for generating primary key values.
|
String |
getName()
Returns the name of this database model.
|
Table |
getTable(int idx)
Returns the table at the specified position.
|
int |
getTableCount()
Returns the number of tables in this model.
|
Table[] |
getTables()
Returns the tables in this model.
|
String |
getVersion()
Returns the version of this database model.
|
int |
hashCode() |
void |
initialize()
Initializes the model by establishing the relationships between elements in this model encoded
eg.
|
void |
mergeWith(Database otherDb)
Adds all tables from the other database to this database.
|
void |
removeAllTablesExcept(Table[] tables)
Removes all but the given tables.
|
void |
removeTable(int idx)
Removes the indicated table.
|
void |
removeTable(Table table)
Removes the given table.
|
void |
removeTables(Table[] tables)
Removes the given tables.
|
void |
resetDynaClassCache()
Resets the dyna class cache.
|
void |
setIdMethod(String idMethod)
Sets the method for generating primary key values.
|
void |
setName(String name)
Sets the name of this database model.
|
void |
setVersion(String version)
Sets the version of this database model.
|
String |
toString() |
String |
toVerboseString()
Returns a verbose string representation of this database.
|
public Database()
public Database(String name)
name - The namepublic void mergeWith(Database otherDb) throws ModelException
otherDb - The other database modelModelExceptionpublic String getName()
public void setName(String name)
name - The namepublic String getVersion()
public void setVersion(String version)
version - The versionpublic String getIdMethod()
public void setIdMethod(String idMethod)
idMethod - The methodpublic int getTableCount()
public Table[] getTables()
public Table getTable(int idx)
idx - The index of the tablepublic void addTable(Table table)
table - The table to addpublic void addTable(int idx,
Table table)
idx - The index where to insert the tabletable - The table to addpublic void addTables(Collection tables)
tables - The tables to addpublic void removeTable(Table table)
table - The table to removepublic void removeTable(int idx)
idx - The index of the table to removepublic void removeTables(Table[] tables)
tables - The tables to removepublic void removeAllTablesExcept(Table[] tables)
tables - The tables to keeppublic void initialize()
throws ModelException
ModelExceptionpublic Table findTable(String name)
name - The name of the table to findnull if there is no such tablepublic Table findTable(String name, boolean caseSensitive)
name - The name of the table to findcaseSensitive - Whether case matters for the namesnull if there is no such tablepublic Table[] findTables(String[] tableNames, boolean caseSensitive)
tableNames - The names of the tablescaseSensitive - Whether the case of the table names matterspublic Table[] findTables(String tableNameRegExp, boolean caseSensitive) throws PatternSyntaxException
tableNameRegExp - The table name regular expressioncaseSensitive - Whether the case of the table names matters; if not, then the regular expression should
assume that the table names are all-uppercasePatternSyntaxException - If the regular expression is invalidpublic void resetDynaClassCache()
public SqlDynaClass getDynaClassFor(String tableName)
SqlDynaClass for the given table name. If the it does not
exist yet, a new one will be created based on the Table definition.tableName - The name of the table to create the bean forSqlDynaClass for the indicated table or null
if the model contains no such tablepublic SqlDynaClass getDynaClassFor(org.apache.commons.beanutils.DynaBean bean)
SqlDynaClass for the given dyna bean.bean - The dyna beanSqlDynaClass for the given beanpublic org.apache.commons.beanutils.DynaBean createDynaBeanFor(Table table) throws SqlDynaException
table - The table to create the bean forSqlDynaExceptionpublic org.apache.commons.beanutils.DynaBean createDynaBeanFor(String tableName, boolean caseSensitive) throws SqlDynaException
createDynaBeanFor(Table) and
findTable(String, boolean).tableName - The name of the table to create the bean forcaseSensitive - Whether case matters for the namesSqlDynaExceptionpublic String toVerboseString()
Copyright © 2010-2015 Pivotal Software, Inc. All rights reserved.