org.apache.torque.map
Class TableMap

java.lang.Object
  extended by org.apache.torque.map.TableMap
All Implemented Interfaces:
java.io.Serializable, IDMethod

public class TableMap
extends java.lang.Object
implements IDMethod, java.io.Serializable

TableMap is used to model a table in a database.

Version:
$Id: TableMap.java 473821 2006-11-11 22:37:25Z tv $
Author:
John D. McNally, Daniel Rall, Greg Monroe
See Also:
Serialized Form

Field Summary
protected static java.lang.String[] VALID_ID_METHODS
          The list of valid ID generation methods.
 
Fields inherited from interface org.apache.torque.adapter.IDMethod
AUTO_INCREMENT, ID_BROKER, NATIVE, NO_ID_METHOD, SEQUENCE
 
Constructor Summary
TableMap()
          Required by proxy.
TableMap(java.lang.String tableName, DatabaseMap containingDB)
          Constructor.
TableMap(java.lang.String tableName, int numberOfColumns, DatabaseMap containingDB)
          Constructor.
TableMap(java.lang.String tableName, java.lang.String prefix, DatabaseMap containingDB)
          Constructor.
 
Method Summary
 void addColumn(ColumnMap cmap)
          Add a pre-created column to this table.
 void addColumn(java.lang.String columnName, java.lang.Object type)
          Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.
 void addColumn(java.lang.String columnName, java.lang.Object type, int size)
          Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.
 void addColumn(java.lang.String columnName, java.lang.Object type, int size, int scale)
          Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.
 void addForeignKey(java.lang.String columnName, java.lang.Object type, java.lang.String fkTable, java.lang.String fkColumn)
          Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.
 void addForeignKey(java.lang.String columnName, java.lang.Object type, java.lang.String fkTable, java.lang.String fkColumn, int size)
          Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.
 void addForeignPrimaryKey(java.lang.String columnName, java.lang.Object type, java.lang.String fkTable, java.lang.String fkColumn)
          Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.
 void addForeignPrimaryKey(java.lang.String columnName, java.lang.Object type, java.lang.String fkTable, java.lang.String fkColumn, int size)
          Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.
 void addPrimaryKey(java.lang.String columnName, java.lang.Object type)
          Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.
 void addPrimaryKey(java.lang.String columnName, java.lang.Object type, int size)
          Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.
 boolean containsColumn(ColumnMap column)
          Does this table contain the specified column?
 boolean containsColumn(java.lang.String name)
          Does this table contain the specified column?
 boolean containsObjectColumn()
          Returns true if this tableMap contains a column with object data.
 ColumnMap getColumn(java.lang.String name)
          Get a ColumnMap for the named table.
 ColumnMap[] getColumns()
          Get a ColumnMap[] of the columns in this table.
 DatabaseMap getDatabaseMap()
          Get the DatabaseMap containing this TableMap.
 DatabaseMap getDbMap()
          Returns the database map for this table.
 java.lang.String getDescription()
          Returns the table description info.
 IdGenerator getIdGenerator()
          Deprecated. use DatabaseInfo.getIdGenerator(getPrimaryKeyMethod()) instead. Will be removed in a future version of Torque.
 java.lang.String getJavaName()
          Get the Java name of the table as defined in XML.
 java.lang.Class getManagerClass()
          Returns the manager class for this table.
 java.lang.String getName()
          Get the name of the Table.
 java.lang.Class getOMClass()
          Returns the OM class for this table.
 java.lang.Class getPeerClass()
          Returns the Peer Class for this table.
 java.lang.String getPrefix()
          Get table prefix name.
 java.lang.String getPrimaryKeyMethod()
          Get the method used to generate primary keys for this table.
 java.lang.Object getPrimaryKeyMethodInfo()
          Get the information used to generate a primary key
 boolean isUseInheritance()
          Returns whether this table uses inheritance.
 boolean isUseManager()
          Returns whether managers are used for this table.
 java.lang.String removeUnderScores(java.lang.String data)
          Removes the PREFIX, removes the underscores and makes first letter caps.
 void setDescription(java.lang.String description)
          Sets the table description.
 void setJavaName(java.lang.String value)
          Set the Java name of the table as defined by generator/XML.
 void setManagerClass(java.lang.Class managerClass)
          Sets the manager class for this table.
 void setOMClass(java.lang.Class omClass)
          Sets the OM root class for this table.
 void setPeerClass(java.lang.Class peerClass)
          Sets the Peer class for this table.
 void setPrefix(java.lang.String prefix)
          Set table prefix name.
 void setPrimaryKeyMethod(java.lang.String method)
          Sets the method used to generate a key for this table.
 void setPrimaryKeyMethodInfo(java.lang.Object pkInfo)
          Sets the pk information needed to generate a key
 void setUseInheritance(boolean useInheritance)
          Sets whether this table uses inheritance.
 void setUseManager(boolean useManager)
          Sets whether managers are used for this table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALID_ID_METHODS

protected static final java.lang.String[] VALID_ID_METHODS
The list of valid ID generation methods.

Constructor Detail

TableMap

public TableMap()
Required by proxy. Not used.


TableMap

public TableMap(java.lang.String tableName,
                int numberOfColumns,
                DatabaseMap containingDB)
Constructor.

Parameters:
tableName - The name of the table.
numberOfColumns - The number of columns in the table.
containingDB - A DatabaseMap that this table belongs to.

TableMap

public TableMap(java.lang.String tableName,
                DatabaseMap containingDB)
Constructor.

Parameters:
tableName - The name of the table.
containingDB - A DatabaseMap that this table belongs to.

TableMap

public TableMap(java.lang.String tableName,
                java.lang.String prefix,
                DatabaseMap containingDB)
Constructor.

Parameters:
tableName - The name of the table.
prefix - The prefix for the table name (ie: SCARAB for SCARAB_PROJECT).
containingDB - A DatabaseMap that this table belongs to.
Method Detail

containsColumn

public boolean containsColumn(ColumnMap column)
Does this table contain the specified column?

Parameters:
column - A ColumnMap.
Returns:
True if the table contains the column.

containsColumn

public boolean containsColumn(java.lang.String name)
Does this table contain the specified column?

Parameters:
name - A String with the name of the column.
Returns:
True if the table contains the column.

getDatabaseMap

public DatabaseMap getDatabaseMap()
Get the DatabaseMap containing this TableMap.

Returns:
A DatabaseMap.

containsObjectColumn

public boolean containsObjectColumn()
Returns true if this tableMap contains a column with object data. If the type of the column is not a string, a number or a date, it is assumed that it is object data.

Returns:
True if map contains a column with object data.

getName

public java.lang.String getName()
Get the name of the Table.

Returns:
A String with the name of the table.

getJavaName

public java.lang.String getJavaName()
Get the Java name of the table as defined in XML.

Returns:
A String with the Java name of the table.

setJavaName

public void setJavaName(java.lang.String value)
Set the Java name of the table as defined by generator/XML.

Parameters:
value - A String with the Java name of the table.

getPrefix

public java.lang.String getPrefix()
Get table prefix name.

Returns:
A String with the prefix.

setPrefix

public void setPrefix(java.lang.String prefix)
Set table prefix name.

Parameters:
prefix - The prefix for the table name (ie: SCARAB for SCARAB_PROJECT).

getPrimaryKeyMethod

public java.lang.String getPrimaryKeyMethod()
Get the method used to generate primary keys for this table.

Returns:
A String with the method.

getIdGenerator

public IdGenerator getIdGenerator()
Deprecated. use DatabaseInfo.getIdGenerator(getPrimaryKeyMethod()) instead. Will be removed in a future version of Torque.

Get the value of idGenerator.

Returns:
value of idGenerator.

getPrimaryKeyMethodInfo

public java.lang.Object getPrimaryKeyMethodInfo()
Get the information used to generate a primary key

Returns:
An Object.

getColumns

public ColumnMap[] getColumns()
Get a ColumnMap[] of the columns in this table.

Returns:
A ColumnMap[].

getColumn

public ColumnMap getColumn(java.lang.String name)
Get a ColumnMap for the named table.

Parameters:
name - A String with the name of the table.
Returns:
A ColumnMap.

addColumn

public void addColumn(ColumnMap cmap)
Add a pre-created column to this table. It will replace any existing column.

Parameters:
cmap - A ColumnMap.

addColumn

public void addColumn(java.lang.String columnName,
                      java.lang.Object type)
Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.

Add a column to this table of a certain type.

Parameters:
columnName - A String with the column name.
type - An Object specifying the type.

addColumn

public void addColumn(java.lang.String columnName,
                      java.lang.Object type,
                      int size,
                      int scale)
Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.

Add a column to this table of a certain type, size, and scale.

Parameters:
columnName - A String with the column name.
type - An Object specifying the type.
size - An int specifying the size.
scale - An int specifying the scale.

addColumn

public void addColumn(java.lang.String columnName,
                      java.lang.Object type,
                      int size)
Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.

Add a column to this table of a certain type and size.

Parameters:
columnName - A String with the column name.
type - An Object specifying the type.
size - An int specifying the size.

addPrimaryKey

public void addPrimaryKey(java.lang.String columnName,
                          java.lang.Object type)
Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.

Add a primary key column to this Table.

Parameters:
columnName - A String with the column name.
type - An Object specifying the type.

addPrimaryKey

public void addPrimaryKey(java.lang.String columnName,
                          java.lang.Object type,
                          int size)
Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.

Add a primary key column to this Table.

Parameters:
columnName - A String with the column name.
type - An Object specifying the type.
size - An int specifying the size.

addForeignKey

public void addForeignKey(java.lang.String columnName,
                          java.lang.Object type,
                          java.lang.String fkTable,
                          java.lang.String fkColumn)
Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.

Add a foreign key column to the table.

Parameters:
columnName - A String with the column name.
type - An Object specifying the type.
fkTable - A String with the foreign key table name.
fkColumn - A String with the foreign key column name.

addForeignKey

public void addForeignKey(java.lang.String columnName,
                          java.lang.Object type,
                          java.lang.String fkTable,
                          java.lang.String fkColumn,
                          int size)
Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.

Add a foreign key column to the table.

Parameters:
columnName - A String with the column name.
type - An Object specifying the type.
fkTable - A String with the foreign key table name.
fkColumn - A String with the foreign key column name.
size - An int specifying the size.

addForeignPrimaryKey

public void addForeignPrimaryKey(java.lang.String columnName,
                                 java.lang.Object type,
                                 java.lang.String fkTable,
                                 java.lang.String fkColumn)
Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.

Add a foreign primary key column to the table.

Parameters:
columnName - A String with the column name.
type - An Object specifying the type.
fkTable - A String with the foreign key table name.
fkColumn - A String with the foreign key column name.

addForeignPrimaryKey

public void addForeignPrimaryKey(java.lang.String columnName,
                                 java.lang.Object type,
                                 java.lang.String fkTable,
                                 java.lang.String fkColumn,
                                 int size)
Deprecated. Associated Column maps should be populated using it's set methods, then added to table via addColumn(ColumnMap). This method will be removed in a future version of Torque.

Add a foreign primary key column to the table.

Parameters:
columnName - A String with the column name.
type - An Object specifying the type.
fkTable - A String with the foreign key table name.
fkColumn - A String with the foreign key column name.
size - An int specifying the size.

setPrimaryKeyMethod

public void setPrimaryKeyMethod(java.lang.String method)
Sets the method used to generate a key for this table. Valid values are as specified in the IDMethod interface.

Parameters:
method - The ID generation method type name.

setPrimaryKeyMethodInfo

public void setPrimaryKeyMethodInfo(java.lang.Object pkInfo)
Sets the pk information needed to generate a key

Parameters:
pkInfo - information needed to generate a key

removeUnderScores

public final java.lang.String removeUnderScores(java.lang.String data)
Removes the PREFIX, removes the underscores and makes first letter caps. SCARAB_FOO_BAR becomes FooBar.

Parameters:
data - A String.
Returns:
A String with data processed.

getDescription

public java.lang.String getDescription()
Returns the table description info.

Returns:
Returns the description.

setDescription

public void setDescription(java.lang.String description)
Sets the table description.

Parameters:
description - The description to set.

getOMClass

public java.lang.Class getOMClass()
Returns the OM class for this table.

Returns:
the OM class.

setOMClass

public void setOMClass(java.lang.Class omClass)
Sets the OM root class for this table.

Parameters:
omClass - The OM root class for this table.

getPeerClass

public java.lang.Class getPeerClass()
Returns the Peer Class for this table.

Returns:
The peerClass for this table.

setPeerClass

public void setPeerClass(java.lang.Class peerClass)
Sets the Peer class for this table.

Parameters:
peerClass - The peerClass to set.

getDbMap

public DatabaseMap getDbMap()
Returns the database map for this table.

Returns:
the database map for this table.

isUseInheritance

public boolean isUseInheritance()
Returns whether this table uses inheritance.

Returns:
whether inheritance is used.

setUseInheritance

public void setUseInheritance(boolean useInheritance)
Sets whether this table uses inheritance.

Parameters:
useInheritance - whether this table uses inheritance.

isUseManager

public boolean isUseManager()
Returns whether managers are used for this table.

Returns:
whether managers are used for this table.

setUseManager

public void setUseManager(boolean useManager)
Sets whether managers are used for this table.

Parameters:
useManager - whether managers are used for this table.

getManagerClass

public java.lang.Class getManagerClass()
Returns the manager class for this table.

Returns:
the managerClass.

setManagerClass

public void setManagerClass(java.lang.Class managerClass)
Sets the manager class for this table.

Parameters:
managerClass - the manager class for this table.


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.