de.fesenmeyer.dbnormalizer.core.util
Class MiscUtil

java.lang.Object
  extended by de.fesenmeyer.dbnormalizer.core.util.MiscUtil

public final class MiscUtil
extends Object

"Miscellaneous" Utility class: Contains helper methods for various purposes.

Author:
DF

Field Summary
private static DBNormalizerLogger logger
          The logger for this class.
 
Constructor Summary
private MiscUtil()
          Makes the constructor inaccessible.
 
Method Summary
static boolean checkTableEquality(String table1Name, String table1Catalog, String table1Schema, String table2Name, String table2Catalog, String table2Schema)
          Checks if two tables are equal by comparing their name, catalog and schema.
static TableContainer createTableContainer(String catalog, String schema)
          Creates a TableContainer.
static String getCollectionAsString(Collection<? extends Object> collection)
          Gets a Collection of objects as a string.
static StringBuffer getCollectionAsStringBuffer(Collection<? extends Object> collection)
          Gets a Collection of objects as a StringBuffer object.
static String getDeleteOrUpdateRuleAsString(int rule)
          Returns a string representation of the delete or update rule specified by argument rule.
static String getQualifiedTableName(String tableName, String catalog, String schema)
          Generates a qualified table name based on the arguments tableName, catalog and schema.
static AttributeStringSet parseAttributeStringSet(String attributeSetString, Table table)
          Parses a set of attribute names from a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static DBNormalizerLogger logger
The logger for this class.

Constructor Detail

MiscUtil

private MiscUtil()
Makes the constructor inaccessible.

Method Detail

parseAttributeStringSet

public static AttributeStringSet parseAttributeStringSet(String attributeSetString,
                                                         Table table)
                                                  throws DBNormalizerException
Parses a set of attribute names from a string. The attribute names in the string must be comma-separated. The method checks if the attributes exist in the specified table and throws an exception if they don't.

Parameters:
attributeSetString - the string
table - the table
Returns:
a set of attribute names
Throws:
DBNormalizerException - if some of the attribute names in the string do not exist in the specified table

checkTableEquality

public static boolean checkTableEquality(String table1Name,
                                         String table1Catalog,
                                         String table1Schema,
                                         String table2Name,
                                         String table2Catalog,
                                         String table2Schema)
Checks if two tables are equal by comparing their name, catalog and schema.

Parameters:
table1Name - the first table's (simple) name
table1Catalog - the first table's catalog, may be null
table1Schema - the first table's schema, may be null
table2Name - the second table's (simple) name
table2Catalog - the second table's catalog, may be null
table2Schema - the second table's schema, may be null
Returns:
true, if the tables are equal; false, otherwise

getQualifiedTableName

public static String getQualifiedTableName(String tableName,
                                           String catalog,
                                           String schema)
Generates a qualified table name based on the arguments tableName, catalog and schema.

Parameters:
tableName - a (simple) table name
catalog - a catalog name, may be null
schema - a schema name, may be null
Returns:
the qualified name

createTableContainer

public static TableContainer createTableContainer(String catalog,
                                                  String schema)
Creates a TableContainer. At least one of the arguments must be null.

Parameters:
catalog - the catalog, may be null
schema - the schema, may be null
Returns:
Returns a TableContainer of type
See Also:
TableContainer, TableContainerType

getCollectionAsStringBuffer

public static StringBuffer getCollectionAsStringBuffer(Collection<? extends Object> collection)
Gets a Collection of objects as a StringBuffer object. Builds a comma-separated string using the objects' toString-method.

Parameters:
collection - a collection of objects
Returns:
a StringBuffer object representing the collection

getCollectionAsString

public static String getCollectionAsString(Collection<? extends Object> collection)
Gets a Collection of objects as a string. Builds a comma-separated string using the objects' toString-method.

Parameters:
collection - a collection of objects
Returns:
a string representing the collection

getDeleteOrUpdateRuleAsString

public static String getDeleteOrUpdateRuleAsString(int rule)
Returns a string representation of the delete or update rule specified by argument rule. Examples are "CASCADE" or "RESTRICT".

Parameters:
rule - the DatabaseMetaData-Constant of the rule
Returns:
a string representation of the rule