|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectca.sqlpower.architect.ArchitectUtils
public class ArchitectUtils
Collection of static utility methods for Architect.
| Method Summary | ||
|---|---|---|
static SQLTable |
addSimulatedTable(SQLDatabase db,
java.lang.String catalog,
java.lang.String schema,
java.lang.String name)
Creates a SQLTable in the given database, optionally under a catalog and/or schema. |
|
static void |
addUndoListenerToHierarchy(UndoCompoundEventListener listener,
SQLObject source)
Adds listener to source's listener list and all of source's children's listener lists recursively. |
|
static void |
addUndoListenerToHierarchy(UndoCompoundEventListener listener,
SQLObject[] sources)
Calls listenToHierarchy on each element in the sources array. |
|
static boolean |
areEqual(java.lang.Object o1,
java.lang.Object o2)
Does a generic object comparison where one or both of the objects could be null. |
|
static boolean |
columnsDiffer(SQLColumn targetColumn,
SQLColumn sourceColumn)
Checks if the definitions of two columns are materially different. |
|
static boolean |
columnTypesDiffer(int t1,
int t2)
Checks if the given column types materially differ. |
|
static void |
configureLog4j()
Sets up the log4j logging framework. |
|
static int |
countTables(SQLObject so)
Recursively count tables in the project, but only consider tables that have been expanded. |
|
static int |
countTablesSnapshot(SQLObject so)
Recursively count tables in the project, including ones that have not been expanded in the DBTree. |
|
static java.util.List<SQLColumn> |
findColumnsSourcedFromDatabase(SQLDatabase target,
SQLDatabase source)
Searches for all columns in the target database which are marked as having source columns in the given source database. |
|
static
|
findDescendentsByClass(SQLObject so,
java.lang.Class<T> clazz,
java.util.List<T> addTo)
Keep in mind that if you go after anything lower than SQLTable, you will invoke a potentially expensive populate() method multiple times. |
|
static
|
getAncestor(SQLObject so,
java.lang.Class<T> ancestorType)
Returns the parent database of so or null if so doesn't have an ancestor whose class is ancestorType. |
|
static SQLObject |
getTableContainer(SQLDatabase db,
java.lang.String catName,
java.lang.String schemaName)
Returns the object that contains tables in the given database. |
|
static boolean |
isCompatibleWithHierarchy(SQLDatabase db,
java.lang.String catalog,
java.lang.String schema,
java.lang.String name)
Returns true if and only if the given set of arguments would result in a successful call to addSimulatedTable(SQLDatabase, String, String, String). |
|
static void |
listenToHierarchy(SQLObjectListener listener,
SQLObject source)
Adds listener to source's listener list and all of source's children's listener lists recursively. |
|
static void |
listenToHierarchy(SQLObjectListener listener,
SQLObject[] sources)
Calls listenToHierarchy on each element in the sources array. |
|
static java.lang.String |
quoteCSV(java.lang.Object val)
Double quotes input string for CSV if needed: string contains ", \n, \r, ',' |
|
static java.lang.String |
quoteCSVStr(java.lang.String val)
|
|
static void |
startup()
Performs startup tasks for the architect system. |
|
static java.lang.String |
toQualifiedName(SQLObject obj)
Creates a dot-separated string of the name of the given SQLObject and the names of each of its ancestors. |
|
static java.lang.String |
toQualifiedName(SQLObject obj,
java.lang.Class<? extends SQLObject> stopAt)
Creates a dot-separated string of the name of the given SQLObject and the names of each of its ancestors, stopping at the first ancestor of the given type. |
|
static java.lang.String |
truncateString(java.lang.String s)
Chop long strings down to size for display purposes |
|
static void |
undoUnlistenToHierarchy(UndoCompoundEventListener listener,
SQLObject source)
Removes listener from source's listener list and all of source's children's listener lists recursively. |
|
static void |
undoUnlistenToHierarchy(UndoCompoundEventListener listener,
SQLObject[] sources)
Calls unlistenToHierarchy on each element in the sources array. |
|
static void |
unlistenToHierarchy(SQLObjectListener listener,
SQLObject source)
Removes listener from source's listener list and all of source's children's listener lists recursively. |
|
static void |
unlistenToHierarchy(SQLObjectListener listener,
SQLObject[] sources)
Calls unlistenToHierarchy on each element in the sources array. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void startup()
public static void configureLog4j()
public static void listenToHierarchy(SQLObjectListener listener,
SQLObject source)
throws ArchitectException
ArchitectException
public static void addUndoListenerToHierarchy(UndoCompoundEventListener listener,
SQLObject source)
throws ArchitectException
ArchitectException
public static void addUndoListenerToHierarchy(UndoCompoundEventListener listener,
SQLObject[] sources)
throws ArchitectException
ArchitectException
public static void listenToHierarchy(SQLObjectListener listener,
SQLObject[] sources)
throws ArchitectException
ArchitectException
public static void undoUnlistenToHierarchy(UndoCompoundEventListener listener,
SQLObject source)
throws ArchitectException
ArchitectException
public static void undoUnlistenToHierarchy(UndoCompoundEventListener listener,
SQLObject[] sources)
throws ArchitectException
ArchitectException
public static void unlistenToHierarchy(SQLObjectListener listener,
SQLObject source)
throws ArchitectException
ArchitectException
public static void unlistenToHierarchy(SQLObjectListener listener,
SQLObject[] sources)
throws ArchitectException
ArchitectException
public static boolean areEqual(java.lang.Object o1,
java.lang.Object o2)
o1.equals(o2).
public static java.util.List<SQLColumn> findColumnsSourcedFromDatabase(SQLDatabase target,
SQLDatabase source)
throws ArchitectException
target - The database to search. All columns of all tables in this database are searched.source - The database to look for in the target database's columns.
ArchitectException
public static int countTablesSnapshot(SQLObject so)
throws ArchitectException
source - the source object (usually the database)
ArchitectException
public static <T extends SQLObject> java.util.List<T> findDescendentsByClass(SQLObject so,
java.lang.Class<T> clazz,
java.util.List<T> addTo)
throws ArchitectException
source - the source object (usually the database)
ArchitectExceptionpublic static java.lang.String truncateString(java.lang.String s)
s - the input string
public static int countTables(SQLObject so)
throws ArchitectException
source - the source object (usually the database)
ArchitectExceptionpublic static java.lang.String quoteCSV(java.lang.Object val)
public static java.lang.String quoteCSVStr(java.lang.String val)
public static <T extends SQLObject> T getAncestor(SQLObject so,
java.lang.Class<T> ancestorType)
so - The object for whose ancestor to look. (Thanks, Winston).
public static SQLObject getTableContainer(SQLDatabase db,
java.lang.String catName,
java.lang.String schemaName)
throws ArchitectException
Note, all comparisons are done case-insensitively.
db - The database to retrieve the table container from.catName - The name of the catalog to retrieve. Must be null iff the
database does not have catalogs.schemaName - The name of the schema to retrieve. Must be null iff the
database does not have schemas.
ArchitectException
public static boolean isCompatibleWithHierarchy(SQLDatabase db,
java.lang.String catalog,
java.lang.String schema,
java.lang.String name)
throws ArchitectException
addSimulatedTable(SQLDatabase, String, String, String).
See that method's documentation for the meaning of the arguments.
ArchitectException - if populating any of the relevant SQLObjects fails.
public static SQLTable addSimulatedTable(SQLDatabase db,
java.lang.String catalog,
java.lang.String schema,
java.lang.String name)
throws ArchitectException
db - The database to create the table in.catalog - The catalog that the table (or the table's schema) should be in.
If null, it is assumed the given database doesn't have catalogs.schema - The schema that the table should be in. If null, it is assumed the
given database doesn't have schemas.name - The name of the table to create.
ArchitectException - If you specify catalog or schema for a database that doesn't
support catalogs or schemas; also if the database uses catalogs and schemas but you
fail to provide them.public static java.lang.String toQualifiedName(SQLObject obj)
public static java.lang.String toQualifiedName(SQLObject obj,
java.lang.Class<? extends SQLObject> stopAt)
obj - The object whose qualified name you wish to obtainstopAt - The class of ancestor to stop at. The name of this ancestor
will not be included in the returned string. If stopAt is
null, or a class which is not an ancestor of the given
SQLObject, the returned string will contain all ancestor
object names up to the root of the SQLObject tree.
public static boolean columnsDiffer(SQLColumn targetColumn,
SQLColumn sourceColumn)
targetColumn - One of the columns to compare. Must not be null.sourceColumn - One of the columns to compare. Must not be null.
public static boolean columnTypesDiffer(int t1,
int t2)
t1 - One of the column types to comparet2 - One of the column types to compare.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||