wt.pds
Class DatabaseInfoUtilities

java.lang.Object
  extended bywt.pds.DatabaseInfoUtilities

public class DatabaseInfoUtilities
extends Object

This class contains static database introspection utility methods required for Query, POM and PDS functionality.

Supported API: false

Extendable: false


Field Summary
private static String ARRAY_ITEM
           
private static String ATTRIBUTE_NAME_DELIMITERS
           
static boolean BASE_TABLE
           
private static Datastore DATASTORE
           
static String NOT_AVAILABLE
           
private static Hashtable primitiveMap
           
private static String RESOURCE
           
static boolean VIEW
           
 
Constructor Summary
DatabaseInfoUtilities()
           
 
Method Summary
static LobLocator buildLobLocator(String tname, String pkName, String attr, String colname)
           
static ColumnDescriptor[] getBaseColumnDescriptors(ClassInfo a_classInfo)
          Returns the valid ColumnDescriptors for the class.
static TableInfo getBaseTableInfo(ClassInfo a_classInfo)
          Returns the base TableInfo for the class.
static String getBaseTableName(Class a_class)
          Returns the base table name for the class.
static String getBaseTableName(ClassInfo a_classInfo)
          Returns the base table name for the class.
private static ClassInfo getClassInfo(Class a_class)
           
static ClassInfo getClassInfoFor(ClassInfo parentClassInfo, String attrName)
           
static ClassInfo getClassInfoFor(ObjectMappable anObj)
           
static Class getColumnClass(ColumnExpression a_columnExpression)
          Return the Java type for the specified ColumnExpression.
static Class getJavaClass(String a_className)
          Return the Java class for the specified class string name.
static LobLocator getLobLocator(ClassInfo aClassInfo, String attribute_name)
           
static int getMaxAttributeNameSize(Class a_class)
          Returns the maximum number of attributes names for the specified class.
static ColumnDescriptor getPersistableColumnDescriptor(Class a_class, String a_attribute)
          Returns the valid ColumnDescriptor for the class and attribute name.
static String getPersistableColumnName(Class a_class, String a_attribute)
          Returns the valid column name for the class and attribute.
static String getStringCase(Class a_targetClass, String a_attributeName)
          Returns the StringCase attribute for the ColumnExpression, if it exists and is specified.
private static String getStringCase(ColumnDescriptor a_columnDescriptor)
           
static String getStringCase(ColumnExpression a_column)
          Returns the StringCase attribute for the ColumnExpression, if it exists and is specified.
static ClassInfo getValidClassInfo(FromClause a_fromClause, int a_fromIndex)
          Return the ClassInfo for the TableExpression at the specified position in the FromClause.
static ColumnDescriptor getValidColumnDescriptor(ClassInfo a_classInfo, String a_attribute)
          Returns the valid ColumnDescriptor for the class and attribute name.
static ColumnDescriptor getValidColumnDescriptor(Class a_class, String a_attribute)
          Returns the valid ColumnDescriptor for the class and attribute name.
static ColumnDescriptor[] getValidColumnDescriptors(ClassInfo a_classInfo)
          Returns the valid ColumnDescriptors for the class.
static String getValidColumnName(ClassInfo a_classInfo, String a_attribute)
          Returns the valid column name for the class and attribute.
static String getValidColumnName(ColumnDescriptor a_columnDescriptor, boolean a_isBaseTable)
          Returns the valid column name for the column descriptor.
private static String getValidColumnName(TableInfo a_tableInfo, String a_attribute, boolean a_baseTable, ClassInfo a_classInfo)
          Returns the column name for the table and attribute.
static LinkInfo getValidLinkInfo(FromClause a_fromClause, int a_fromIndex)
          Return the LinkInfo for the TableExpression at the specified position in the FromClause.
static Vector getValidSubClassInfos(Class a_class)
          This method returns a Vector of all of the subclasses that are Persistable and concrete (inlcuding the specified class).
static Vector getValidSubClassInfos(ClassInfo a_classInfo)
          This method returns a Vector of all of the subclasses that are Persistable and concrete (inlcuding the specified class).
static TableInfo getValidTableInfo(Class a_class)
           
static TableInfo getValidTableInfo(ClassInfo a_classInfo)
          Returns the valid TableInfo for the class.
static String getValidTableName(Class a_class)
          Returns the valid table name for the class.
static String getValidTableName(ClassInfo a_classInfo)
          Returns the valid table name for the class.
static boolean isAutoNavigate(Class a_class)
           
static boolean isAutoNavigate(ClassInfo a_classInfo)
           
static boolean isBaseTable(ClassInfo a_classInfo)
          Returns true if the TableInfo for this class is for a base table .
static boolean isForeignKeyLink(Class a_class)
          Indicates if the specified class is a ForeignKey link.
static boolean isForeignKeyLink(ClassInfo a_classInfo)
          Indicates if the specified class is a ForeignKey link.
static boolean isForeignKeyLink(LinkInfo a_linkInfo)
          Indicates if the specified class is a ForeignKey link.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE_TABLE

public static final boolean BASE_TABLE
See Also:
Constant Field Values

VIEW

public static final boolean VIEW
See Also:
Constant Field Values

NOT_AVAILABLE

public static final String NOT_AVAILABLE
See Also:
Constant Field Values

RESOURCE

private static final String RESOURCE

ATTRIBUTE_NAME_DELIMITERS

private static final String ATTRIBUTE_NAME_DELIMITERS
See Also:
Constant Field Values

primitiveMap

private static Hashtable primitiveMap

ARRAY_ITEM

private static final String ARRAY_ITEM
See Also:
Constant Field Values

DATASTORE

private static final Datastore DATASTORE
Constructor Detail

DatabaseInfoUtilities

public DatabaseInfoUtilities()
Method Detail

getStringCase

public static String getStringCase(Class a_targetClass,
                                   String a_attributeName)
                            throws WTException
Returns the StringCase attribute for the ColumnExpression, if it exists and is specified.

Parameters:
a_targetClass - Target class to use
a_attributeName - Name of attribute to use
Returns:
StringCase value, null if not found or the value is "AS IS"
Throws:
WTException

getStringCase

public static String getStringCase(ColumnExpression a_column)
                            throws WTException
Returns the StringCase attribute for the ColumnExpression, if it exists and is specified.

Parameters:
a_column - ColumnExpression to use
Returns:
StringCase value, null if not found or the value is "AS IS"
Throws:
WTException

getValidTableInfo

public static TableInfo getValidTableInfo(ClassInfo a_classInfo)
                                   throws PersistenceException
Returns the valid TableInfo for the class. Returns View info if it is valid, otherise returns Base Table info.

Parameters:
a_classInfo -
Returns:
Valid TableInfo
Throws:
wt.pds.PersistenceException
PersistenceException

getBaseTableInfo

public static TableInfo getBaseTableInfo(ClassInfo a_classInfo)
                                  throws PersistenceException
Returns the base TableInfo for the class.

Parameters:
a_classInfo -
Returns:
Base TableInfo
Throws:
wt.pds.PersistenceException
PersistenceException

isBaseTable

public static boolean isBaseTable(ClassInfo a_classInfo)
                           throws PersistenceException
Returns true if the TableInfo for this class is for a base table .

Parameters:
a_classInfo -
Returns:
true if the TableInfo for this class is for a base table
Throws:
wt.pds.PersistenceException
PersistenceException

getValidColumnDescriptors

public static ColumnDescriptor[] getValidColumnDescriptors(ClassInfo a_classInfo)
                                                    throws PersistenceException
Returns the valid ColumnDescriptors for the class. Returns View ColumnDescriptors if valid, otherise returns Base Table ColumnDescriptors.

Parameters:
a_classInfo -
Returns:
Valid ColumnDescriptors
Throws:
wt.pds.PersistenceException
PersistenceException

getBaseColumnDescriptors

public static ColumnDescriptor[] getBaseColumnDescriptors(ClassInfo a_classInfo)
                                                   throws PersistenceException
Returns the valid ColumnDescriptors for the class. Always returns Base Table ColumnDescriptors.

Parameters:
a_classInfo -
Returns:
Base ColumnDescriptors
Throws:
wt.pds.PersistenceException
PersistenceException

getValidColumnDescriptor

public static ColumnDescriptor getValidColumnDescriptor(ClassInfo a_classInfo,
                                                        String a_attribute)
                                                 throws PersistenceException
Returns the valid ColumnDescriptor for the class and attribute name. The attribute may be for a View (if valid) or Base Table.

Parameters:
a_classInfo -
a_attribute -
Returns:
Valid ColumnDescriptors
Throws:
wt.pds.PersistenceException
PersistenceException

getValidColumnDescriptor

public static ColumnDescriptor getValidColumnDescriptor(Class a_class,
                                                        String a_attribute)
                                                 throws PersistenceException
Returns the valid ColumnDescriptor for the class and attribute name. The attribute may be for a View (if valid) or Base Table.

Parameters:
a_class -
a_attribute -
Returns:
Valid ColumnDescriptors
Throws:
wt.pds.PersistenceException
PersistenceException

getValidTableName

public static String getValidTableName(ClassInfo a_classInfo)
                                throws PersistenceException
Returns the valid table name for the class. The view name will be returned if valid, otherwise a Base Table.

Parameters:
a_classInfo -
Returns:
Table name
Throws:
wt.pds.PersistenceException
PersistenceException

getValidTableName

public static String getValidTableName(Class a_class)
                                throws PersistenceException
Returns the valid table name for the class. The view name will be returned if valid, otherwise a Base Table.

Parameters:
a_class -
Returns:
Table name
Throws:
wt.pds.PersistenceException
PersistenceException

getBaseTableName

public static String getBaseTableName(ClassInfo a_classInfo)
                               throws PersistenceException
Returns the base table name for the class.

Parameters:
a_classInfo -
Returns:
Table name
Throws:
wt.pds.PersistenceException
PersistenceException

getBaseTableName

public static String getBaseTableName(Class a_class)
                               throws PersistenceException
Returns the base table name for the class.

Parameters:
a_class -
Returns:
Table name
Throws:
wt.pds.PersistenceException
PersistenceException

getValidColumnName

public static String getValidColumnName(ClassInfo a_classInfo,
                                        String a_attribute)
                                 throws PersistenceException
Returns the valid column name for the class and attribute. The View column name will be returned if valid, otherwise the Base Table column name is returned.

Parameters:
a_classInfo -
a_attribute -
Returns:
Column name
Throws:
wt.pds.PersistenceException
PersistenceException

getValidColumnName

public static String getValidColumnName(ColumnDescriptor a_columnDescriptor,
                                        boolean a_isBaseTable)
                                 throws PersistenceException
Returns the valid column name for the column descriptor.

Parameters:
a_columnDescriptor -
a_isBaseTable -
Returns:
Column name
Throws:
wt.pds.PersistenceException
PersistenceException

getValidSubClassInfos

public static Vector getValidSubClassInfos(ClassInfo a_classInfo)
                                    throws PersistenceException
This method returns a Vector of all of the subclasses that are Persistable and concrete (inlcuding the specified class). If the Vector is empty, an exception is thrown.

Parameters:
a_classInfo -
Returns:
Vector
Throws:
PersistenceException

getValidSubClassInfos

public static Vector getValidSubClassInfos(Class a_class)
                                    throws PersistenceException
This method returns a Vector of all of the subclasses that are Persistable and concrete (inlcuding the specified class). If the Vector is empty, an exception is thrown.

Parameters:
a_class -
Returns:
Vector
Throws:
PersistenceException

getValidColumnName

private static String getValidColumnName(TableInfo a_tableInfo,
                                         String a_attribute,
                                         boolean a_baseTable,
                                         ClassInfo a_classInfo)
                                  throws PersistenceException
Returns the column name for the table and attribute. The View column name will be returned if a_baseTable is false, otherwise the Base Table column name is returned.

Parameters:
a_tableInfo -
a_attribute -
a_baseTable - if true return base table name, otherwise return column name
a_classInfo -
Returns:
Column name
Throws:
wt.pds.PersistenceException
PersistenceException

getMaxAttributeNameSize

public static int getMaxAttributeNameSize(Class a_class)
                                   throws PersistenceException
Returns the maximum number of attributes names for the specified class. Currently, this is an upper bound. In practice, much fewer names are required.

Parameters:
a_class -
Returns:
Number of attribute names
Throws:
wt.pds.PersistenceException
PersistenceException

getPersistableColumnDescriptor

public static ColumnDescriptor getPersistableColumnDescriptor(Class a_class,
                                                              String a_attribute)
                                                       throws PersistenceException
Returns the valid ColumnDescriptor for the class and attribute name. The attribute may be for a View (if valid) or Base Table. A ColumnDescriptor is also returned if the attribute is valid for a Persistable and the class has a Persistable sub-class.

Parameters:
a_class -
a_attribute -
Returns:
Valid ColumnDescriptor
Throws:
wt.pds.PersistenceException
PersistenceException

getPersistableColumnName

public static String getPersistableColumnName(Class a_class,
                                              String a_attribute)
                                       throws PersistenceException
Returns the valid column name for the class and attribute. The View column name will be returned if valid, otherwise the Base Table column name is returned. A column name is also returned if the attribute is valid for a Persistable and the class has a Persistable sub-class.

Parameters:
a_class -
a_attribute -
Returns:
Column name
Throws:
wt.pds.PersistenceException
PersistenceException

isForeignKeyLink

public static boolean isForeignKeyLink(Class a_class)
                                throws PersistenceException
Indicates if the specified class is a ForeignKey link.

Parameters:
a_class -
Returns:
true if this class is a ForeignKey link
Throws:
wt.pds.PersistenceException
PersistenceException

isForeignKeyLink

public static boolean isForeignKeyLink(ClassInfo a_classInfo)
                                throws PersistenceException
Indicates if the specified class is a ForeignKey link.

Parameters:
a_classInfo -
Returns:
true if this class is a ForeignKey link
Throws:
wt.pds.PersistenceException
PersistenceException

isForeignKeyLink

public static boolean isForeignKeyLink(LinkInfo a_linkInfo)
Indicates if the specified class is a ForeignKey link.

Parameters:
a_linkInfo -
Returns:
true if this class is a ForeignKey link
Throws:
wt.pds.PersistenceException

getValidClassInfo

public static ClassInfo getValidClassInfo(FromClause a_fromClause,
                                          int a_fromIndex)
                                   throws PersistenceException
Return the ClassInfo for the TableExpression at the specified position in the FromClause.

Parameters:
a_fromClause - instance containing the table
a_fromIndex - index of table in the FromClause
Returns:
ClassInfo for the TableExpression
Throws:
wt.pds.PersistenceException
PersistenceException

getValidLinkInfo

public static LinkInfo getValidLinkInfo(FromClause a_fromClause,
                                        int a_fromIndex)
                                 throws PersistenceException
Return the LinkInfo for the TableExpression at the specified position in the FromClause.

Parameters:
a_fromClause - instance containing the table
a_fromIndex - index of table in the FromClause
Returns:
ClassInfo for the TableExpression
Throws:
wt.pds.PersistenceException
PersistenceException

getColumnClass

public static Class getColumnClass(ColumnExpression a_columnExpression)
                            throws WTException
Return the Java type for the specified ColumnExpression. If the Java type is a primitive, then the associated java.lang wrapper class is returned.

Parameters:
a_columnExpression - column to return the type for
Returns:
Class for the ColumnExpression. If the type cannot be determined, then java.lang.Object is returned. If the ColumnExpression is not a single column, then null is returned.
Throws:
WTException

getJavaClass

public static Class getJavaClass(String a_className)
                          throws WTException
Return the Java class for the specified class string name. If the Java type is a primitive, then the associated java.lang wrapper class is returned.

Parameters:
a_className - to return the type for
Returns:
Class for the java name
Throws:
WTException

isAutoNavigate

public static boolean isAutoNavigate(ClassInfo a_classInfo)
                              throws PersistenceException
Throws:
PersistenceException

isAutoNavigate

public static boolean isAutoNavigate(Class a_class)
                              throws PersistenceException
Throws:
PersistenceException

getValidTableInfo

public static TableInfo getValidTableInfo(Class a_class)
                                   throws PersistenceException
Throws:
PersistenceException

getLobLocator

public static LobLocator getLobLocator(ClassInfo aClassInfo,
                                       String attribute_name)
                                throws DatastoreException
Throws:
DatastoreException

buildLobLocator

public static LobLocator buildLobLocator(String tname,
                                         String pkName,
                                         String attr,
                                         String colname)

getStringCase

private static String getStringCase(ColumnDescriptor a_columnDescriptor)
                             throws WTException
Throws:
WTException

getClassInfoFor

public static ClassInfo getClassInfoFor(ClassInfo parentClassInfo,
                                        String attrName)
                                 throws PersistenceException
Throws:
PersistenceException

getClassInfoFor

public static ClassInfo getClassInfoFor(ObjectMappable anObj)
                                 throws PersistenceException
Throws:
PersistenceException

getClassInfo

private static ClassInfo getClassInfo(Class a_class)
                               throws PersistenceException
Throws:
PersistenceException