com.tivoli.twg.engine
Class TWGDbColumn

java.lang.Object
  extended bycom.tivoli.twg.engine.TWGDbColumn
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
TWGDbCharColumn, TWGDbDateColumn, TWGDbDatetimeColumn, TWGDbDoubleColumn, TWGDbIntegerColumn, TWGDbRealColumn, TWGDbSmallintColumn, TWGDbVarcharColumn

public abstract class TWGDbColumn
extends java.lang.Object
implements java.io.Serializable

TWGDbColumn is an abstract class that encapsulates a database7 table column. It describe column-related parameters for a single table column. The subclasses of this column are collected in a TWGDbColumnData object that is passed as a parameter when the database table is initialized.

See Also:
TWGDbColumnData, Serialized Form

Constructor Summary
protected TWGDbColumn(java.lang.String realName, java.lang.String tokenName, int colType, int colLength, java.lang.Object defaultValue)
          Constructor for Character or Varchar columns
protected TWGDbColumn(java.lang.String realName, java.lang.String tokenName, int colType, java.lang.Object defaultValue)
          Constructor for TWGDbColumn - non-character columns
protected TWGDbColumn(TWGDbColumn copyCol)
          Create a TWGDbColumn by copying another one
 
Method Summary
 boolean allowsGTLT()
          Get whether the column is allowed to have greater than or less than operation for queries and filters.
 boolean compareTo(DataValue dv, TWGDbColumnFilter colFilter)
          Classes that implement filter processing must override the compareTo method to allow comparing a data value to the information stored in the TWGDbColumnFilter.
protected abstract  TWGDbColumn createFilterColumn(java.util.Locale loc, TWGDatabaseTable table)
          Abstract method to create a filter column version of this column.
 java.lang.Object getColumnDefaultValue()
          Get the default value for the column.
 int getColumnId()
          Get the column number.
 java.lang.Integer getColumnlength()
          Get the number of characters in column.
 int getColumnType()
          Get the column type.
 java.lang.String getDisplayName()
          Get the column display name.
protected abstract  java.io.Serializable getDistinctValues(java.util.Locale loc, TWGDatabaseTable table)
          New in Director v2.1.
 DataValue getInitialDistinctValues()
          Returns the data value that is used to prime the distinct values for this column
 java.lang.Integer getKeyNum()
          Get the key number of the column.
 IntValueSet getMatchingMoids(TWGFilterConstraint filterConstraint, TWGDbConnection conn, IntValueSet moids)
          If the standard filter query won't work then override this method in the derived class and implement the filter.
 java.lang.String getMetaType()
          Get the meta type for the column
 java.lang.String getRealColumnName()
          Get the real column name.
protected  TWGDatabaseTable getTable()
          Get database table for this column (engine use only)
 java.lang.String getTokenColumnName()
          Get the token column name.
 boolean implementsFilterProcessing()
          This method will return true if this column has special filter processing needs.
protected abstract  void insertDistinctValue(java.lang.Object value)
          Abstract class to be insert a distinct value into the list of distinct values.
 boolean isFilterColumn()
          Get whether the column should be displayed on the edit dynamic group (filter) panel.
 boolean isMappedColumn()
          Return true if the column value in a query result set will be translated.
 boolean queryDistinctValues()
          Is this column one for which we query the table for distinct values?
protected  void refreshDistinctIfNeeded()
          Refresh distinct column values (if cache expired) (Console use only)
protected  void refreshDistinctValues(java.lang.String tableName, TWGDbConnection conn)
          This method is protected as an implementation side effect.
protected  void replaceDistinctValues(java.sql.ResultSet rs)
          This method is protected as an implementation side effect.
 void setAllowsGTLT(boolean gtlt)
          Set whether the column is allowed to have greater than and less than operations for queries and filters.
protected  void setColumnId(int column_id)
          This method is protected as an implementation side effect.
 void setColumnLength(java.lang.Integer columnLength)
           
static void setColumnNameLength(int columnLength)
          The column length is specified during the ctr of the TWGDbColumn object.
 void setDefaultValue(java.lang.Object defaultValue)
          Set the default value for the column.
protected  void setDisplayName(java.util.Locale loc, TWGDatabaseTable table)
          Set the column display name used in printouts and displays.
protected abstract  void setDistinctValues(java.lang.Object vals)
          Set distinct values for this column (console use only)
 void setFilterColumn(boolean filter)
          Set whether the column should be displayed on the edit dynamic group (filter) panel.
 void setFilterProcessing(boolean processing)
          Allows setting this TWGDbColumn to have special filter processing needs.
protected  void setInitialDistinctValues(DataValue dv)
          Set the initial distinct values for this column.
protected  void setKeyNum(int keyNum)
          This method is protected as an implementation side effect.
protected  void setMappedColumn(boolean mapped)
          Set whether column values are translated via resource bundles.
 void setMetaType(java.lang.String metaType)
          Set the meta type for this column.
protected  void setQueryDistinctValues(boolean queryDistinct)
          Set whether distinct values should be retrieved by querying the database
 void setShortColumnName(java.lang.String shortColumnName)
          Get the token column name.
 void setTableName(java.lang.String name)
          Set database table for this column (console use only)
 java.lang.String toString()
          Convert column to String for debug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TWGDbColumn

protected TWGDbColumn(java.lang.String realName,
                      java.lang.String tokenName,
                      int colType,
                      java.lang.Object defaultValue)
Constructor for TWGDbColumn - non-character columns

Parameters:
realName - - real column name
tokenName - - token column name
colType - - type of the column
defaultValue - - the column default value

TWGDbColumn

protected TWGDbColumn(java.lang.String realName,
                      java.lang.String tokenName,
                      int colType,
                      int colLength,
                      java.lang.Object defaultValue)
Constructor for Character or Varchar columns

Parameters:
realName - - real column name
tokenName - - token column name
colType - - type of the column
colLength - - the number of characters in the column.
defaultValue - - the column default value

TWGDbColumn

protected TWGDbColumn(TWGDbColumn copyCol)
Create a TWGDbColumn by copying another one

Parameters:
copyCol - -- the column to be copied
Method Detail

getTable

protected TWGDatabaseTable getTable()
                             throws TWGDbException
Get database table for this column (engine use only)

Returns:
database table instance for this column
Throws:
TWGDbException

setTableName

public void setTableName(java.lang.String name)
Set database table for this column (console use only)

Parameters:
name - database table name

createFilterColumn

protected abstract TWGDbColumn createFilterColumn(java.util.Locale loc,
                                                  TWGDatabaseTable table)
Abstract method to create a filter column version of this column. Must be overriden by subclasses. This method should be called only in the Director server engine.

Parameters:
loc - - the locale to use for translations
table - - the TWGDatabaseTable that this column belongs to

setMappedColumn

protected void setMappedColumn(boolean mapped)
Set whether column values are translated via resource bundles. The default is false. The only column types that should set this value are String types (CHAR, VARCHAR). All other column subclasses should not have a method that allows setting of this value.

This method should be called only in the create method of a TWGDatabaseTable subclass when defining the table

Parameters:
mapped - - true if the column can is to be translated, otherwise false /*

isMappedColumn

public boolean isMappedColumn()
Return true if the column value in a query result set will be translated. Return false if not.

Returns:
true for a mapped column, otherwise false

setFilterColumn

public void setFilterColumn(boolean filter)
Set whether the column should be displayed on the edit dynamic group (filter) panel. The default is true.

This method should be called only in the create method of a TWGDatabaseTable subclass when defining the table

Parameters:
filter - - true to make the column a filter column

isFilterColumn

public boolean isFilterColumn()
Get whether the column should be displayed on the edit dynamic group (filter) panel.

Returns:
true if column is a filter column, otherwise false

setAllowsGTLT

public void setAllowsGTLT(boolean gtlt)
Set whether the column is allowed to have greater than and less than operations for queries and filters.

This method should be called only in the create method of a TWGDatabaseTable subclass when defining the table

Parameters:
gtlt - - true to allow greater than and less than, otherwise false

allowsGTLT

public boolean allowsGTLT()
Get whether the column is allowed to have greater than or less than operation for queries and filters.

Returns:
true if column can use greater than and less than, otherwise, false

insertDistinctValue

protected abstract void insertDistinctValue(java.lang.Object value)
                                     throws TWGDbException
Abstract class to be insert a distinct value into the list of distinct values. Must be overridden by subclass

Parameters:
value - - The value to be inserted.
Throws:
- - TWGDbException
TWGDbException

getRealColumnName

public java.lang.String getRealColumnName()
Get the real column name. if the column length has been set then use the short column length

Returns:
String

setColumnNameLength

public static void setColumnNameLength(int columnLength)
The column length is specified during the ctr of the TWGDbColumn object. There are some SQL implementations, like DB2 V5, that has a different limit than the initially suppported Databases. This includes limiting char to 254 characters instead of the initial release limit of 255. This member function allows TWGDatabaseTable to detect these differences and modify accordingly.

Parameters:
columnLength - - length of column

setShortColumnName

public void setShortColumnName(java.lang.String shortColumnName)
Get the token column name.

Returns:
String

getTokenColumnName

public java.lang.String getTokenColumnName()
Get the token column name.

Returns:
String

getDisplayName

public java.lang.String getDisplayName()
Get the column display name. The display name will be the same as the real column name except when the column information is serialized through the IPC in response to a request to get descriptive table information. Then it will contain the displayable name

Returns:
String that contains the column display name or real name

setDisplayName

protected void setDisplayName(java.util.Locale loc,
                              TWGDatabaseTable table)
Set the column display name used in printouts and displays.

Parameters:
loc - - Locale used for the column
table - - reference to the TWGDatabaseTable which the column is in.

getColumnType

public int getColumnType()
Get the column type. Valid types are in TWGDatabaseConstants

Returns:
the column type
See Also:
TWGDatabaseConstants

getColumnlength

public java.lang.Integer getColumnlength()
Get the number of characters in column. This only applies to String type columns (VARCHAR, CHAR);

Returns:
the column length

setColumnLength

public void setColumnLength(java.lang.Integer columnLength)

getKeyNum

public java.lang.Integer getKeyNum()
Get the key number of the column. Return 0 if the column is not part of the table key.

Returns:
the key number. For non-key columns return 0.

setKeyNum

protected void setKeyNum(int keyNum)
This method is protected as an implementation side effect. Do not call or change. Its interface may be changed in a later release.

Set the key number of the column.

Parameters:
keyNum - - key number

setColumnId

protected void setColumnId(int column_id)
This method is protected as an implementation side effect. Do not call or change. Its interface may be changed in a later release.

Set the column number.

Parameters:
column_id - - column number.

getColumnId

public int getColumnId()
Get the column number.

Returns:
the column id number

setDefaultValue

public void setDefaultValue(java.lang.Object defaultValue)
Set the default value for the column.

This method should be called only in the create method of a TWGDatabaseTable subclass when defining the table

Parameters:
defaultValue - - default value

getMetaType

public java.lang.String getMetaType()
Get the meta type for the column

Returns:
the meta type for the column

setMetaType

public void setMetaType(java.lang.String metaType)
Set the meta type for this column.

This method should be called to set the meta type of the column. An example would be a char column that is used to hold ip addresses. The meta type could be set to IPAddress.


getColumnDefaultValue

public java.lang.Object getColumnDefaultValue()
Get the default value for the column.

Returns:
the default value cast to an Object

setDistinctValues

protected abstract void setDistinctValues(java.lang.Object vals)
Set distinct values for this column (console use only)


refreshDistinctIfNeeded

protected void refreshDistinctIfNeeded()
Refresh distinct column values (if cache expired) (Console use only)


refreshDistinctValues

protected void refreshDistinctValues(java.lang.String tableName,
                                     TWGDbConnection conn)
                              throws TWGDbException
This method is protected as an implementation side effect. Do not call or change. Its interface may be changed in a later release.

Refresh the list of saved distinct column values with the values obtained from the physical database table.

Parameters:
tableName - - the real table name for the table
conn - - a TWGDbConnection for the database
Throws:
TWGDbException

getDistinctValues

protected abstract java.io.Serializable getDistinctValues(java.util.Locale loc,
                                                          TWGDatabaseTable table)
New in Director v2.1. Package-scope method only to be used by TWGDbCommandProcessor on the server (implemented only by subclasses). Get distinct values as an object which can be serialized and sent as an IPC output parm.

Returns:
Serializable object containing distinct values

replaceDistinctValues

protected void replaceDistinctValues(java.sql.ResultSet rs)
                              throws TWGDbException
This method is protected as an implementation side effect. Do not call or change. Its interface may be changed in a later release.

Replace the saved set of distinct column values with the results from a database query such that the values are returned on subsequent calls to getDistinctValues().

Parameters:
rs - - query result set
Throws:
TWGDbException

setQueryDistinctValues

protected void setQueryDistinctValues(boolean queryDistinct)
Set whether distinct values should be retrieved by querying the database

Parameters:
queryDistinct - - true means we retrieve distinct values from table

queryDistinctValues

public boolean queryDistinctValues()
Is this column one for which we query the table for distinct values?

Returns:
true if we query the table for distinct values

setInitialDistinctValues

protected void setInitialDistinctValues(DataValue dv)
Set the initial distinct values for this column. These values will always be displayed in the dynamic filter builder.

Parameters:
dv - - datavalue

getInitialDistinctValues

public DataValue getInitialDistinctValues()
Returns the data value that is used to prime the distinct values for this column

Returns:
- data value.

implementsFilterProcessing

public boolean implementsFilterProcessing()
This method will return true if this column has special filter processing needs. If true is returned then the column has an override for the getMatchingMoids method.


setFilterProcessing

public void setFilterProcessing(boolean processing)
Allows setting this TWGDbColumn to have special filter processing needs. One example is TWGDbTCPIPColumn


compareTo

public boolean compareTo(DataValue dv,
                         TWGDbColumnFilter colFilter)
Classes that implement filter processing must override the compareTo method to allow comparing a data value to the information stored in the TWGDbColumnFilter. This is needed to support the ALL_FOR_SAME_ADDRESS version of AND.

Parameters:
dv - - the data value to compare
colFilter - - the column filter to compare to
Returns:
- the boolean value of the comparision

getMatchingMoids

public IntValueSet getMatchingMoids(TWGFilterConstraint filterConstraint,
                                    TWGDbConnection conn,
                                    IntValueSet moids)
If the standard filter query won't work then override this method in the derived class and implement the filter. The moids that meed the filter constraints are returned.

Parameters:
conn - - database connection to use.
filterConstraint - - the filter constraint.
moids - - this is the list of moids to check. If the list is null then check against all moids.
Returns:
- return the list of moids that match the filter constraint.

toString

public java.lang.String toString()
Convert column to String for debug

Returns:
String with a textual description of the column.