org.apache.turbine.torque.engine.database.model
Class Table

java.lang.Object
  |
  +--org.apache.turbine.torque.engine.database.model.Table

public class Table
extends java.lang.Object

A Class for holding data about a table used in an Application.

Version:
$Id: Table.java,v 1.17 2001/05/31 00:59:46 jmcnally Exp $
Author:
Leon Messerschmidt, Jason van Zyl,
Constructor Summary
Table()
          Default Constructor
Table(java.lang.String name)
          Constructs a table object with a name
 
Method Summary
 Column addColumn(org.xml.sax.Attributes attrib)
          A utility function to create a new column from attrib and add it to this table.
 void addColumn(Column col)
          Adds a new column to the column vector and set the parent table of the column to the current table
 ForeignKey addForeignKey(org.xml.sax.Attributes attrib)
          A utility function to create a new foreign key from attrib and add it to this table.
 void addForeignKey(ForeignKey fk)
          Adds a new FK to the FK vector and set the parent table of the column to the current table
 IdMethodParameter addIdMethodParameter(org.xml.sax.Attributes attrib)
          /** A utility function to create a new id method parameter from attrib and add it to this table.
 void addIdMethodParameter(IdMethodParameter imp)
          Adds a new id method parameter to the vector and set the parent table of the column to the current table
 Index addIndex(org.xml.sax.Attributes attrib)
          A utility function to create a new index from attrib and add it to this table.
 void addIndex(Index index)
          Adds a new index to the index vector and set the parent table of the column to the current table
 void addReferrer(ForeignKey fk)
          Adds the foreign key from another table that refers to this table.
 Unique addUnique(org.xml.sax.Attributes attrib)
          A utility function to create a new Unique from attrib and add it to this table.
 void addUnique(Unique unique)
          Adds a new Unique to the Unique vector and set the parent table of the column to the current table
 boolean containsColumn(Column col)
          Returns true if the table contains a spesified column
 boolean containsColumn(java.lang.String name)
          Returns true if the table contains a spesified column
 java.util.List getAdditionalIndicesForPrimaryKey()
          Returns a list of CSV strings for a primary key composed of multiple parts to create extra indices for.
 java.lang.String getAlias()
          JavaName of om object this entry references.
 java.lang.String getBaseClass()
          Get the value of baseClass.
 java.lang.String getBasePeer()
          Get the value of basePeer.
 Column getChildrenColumn()
           
 java.util.List getChildrenNames()
          Get the objects that can be created from this table.
 Column getColumn(java.lang.String name)
          Returns a specified column.
 Column getColumnByJavaName(java.lang.String javaName)
          Returns a specified column.
 Column[] getColumns()
          Returns an Array containing all the columns in the table
 boolean getContainsForeignPK()
          Determine if this table contains a foreign PK
 Database getDatabase()
          Get the parent of the table
 ForeignKey getForeignKey(java.lang.String col)
          Return the first foreign key that includes col in it's list of local columns.
 ForeignKey[] getForeignKeys()
          Returns an Array containing all the FKs in the table
 java.util.List getForeignTableNames()
          A list of tables referenced by foreign keys in this table
 java.lang.String getIdMethod()
          Get the method for generating pk's
 java.util.List getIdMethodParameters()
          Returns a Collection of parameters relevant for the chosen id generation method.
 Index[] getIndices()
          Returns an Array containing all the FKs in the table
 java.lang.String getJavaName()
          Get name to use in Java sources
 java.lang.String getName()
          Get the name of the Table
 int getNumColumns()
          Utility method to get the number of columns in this table
 java.util.List getPrimaryKey()
          Returns the collection of Columns which make up the single primary key for this table.
 java.util.ArrayList getPrimaryKeys()
          Deprecated. Use getPrimaryKey() instead.
 java.util.List getReferrers()
          Get list of references to this table.
 java.lang.String getSequenceName()
          A name to use for creating a sequence if one is not specified.
 Unique[] getUnices()
          Returns an Array containing all the UKs in the table
 boolean isAbstract()
          When a table is abstract, it marks the business object class that is generated as being abstract.
 boolean isAlias()
          Is this table specified in the schema or is there just a foreign key reference to it.
 boolean isSkipSql()
          Skip generating sql for this table (in the event it should not be created from scratch).
 void loadFromXML(org.xml.sax.Attributes attrib, java.lang.String defaultIdMethod)
          Load the table object from an xml tag.
 java.lang.String printPrimaryKey()
          Returns all parts of the primary key, separated by commas.
 java.lang.String printPrimaryKeys()
          Deprecated. Use printPrimaryKey() instead.
 void setAbstract(boolean v)
          When a table is abstract, it marks the business object class that is generated as being abstract.
 void setAlias(java.lang.String v)
          Set whether this table specified in the schema or is there just a foreign key reference to it.
 void setBaseClass(java.lang.String v)
          Set the value of baseClass.
 void setBasePeer(java.lang.String v)
          Set the value of basePeer.
 void setContainsForeignPK(boolean b)
          Set whether this table contains a foreign PK
 void setDatabase(Database parent)
          Set the parent of the table
 void setIdMethod(java.lang.String idMethod)
          Set the method for generating pk's
 void setJavaName(java.lang.String javaName)
          Set name to use in Java sources
 void setName(java.lang.String newName)
          Set the name of the Table
 void setSkipSql(boolean v)
          Set whether this table should have its creation sql generated.
 java.lang.String toString()
          Creates a string representation of this table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Table

public Table()
Default Constructor


Table

public Table(java.lang.String name)
Constructs a table object with a name

Method Detail

loadFromXML

public void loadFromXML(org.xml.sax.Attributes attrib,
                        java.lang.String defaultIdMethod)
Load the table object from an xml tag.


getBaseClass

public java.lang.String getBaseClass()
Get the value of baseClass.

Returns:
value of baseClass.

setBaseClass

public void setBaseClass(java.lang.String v)
Set the value of baseClass.

Parameters:
v - Value to assign to baseClass.

getBasePeer

public java.lang.String getBasePeer()
Get the value of basePeer.

Returns:
value of basePeer.

setBasePeer

public void setBasePeer(java.lang.String v)
Set the value of basePeer.

Parameters:
v - Value to assign to basePeer.

addColumn

public Column addColumn(org.xml.sax.Attributes attrib)
A utility function to create a new column from attrib and add it to this table.


addColumn

public void addColumn(Column col)
Adds a new column to the column vector and set the parent table of the column to the current table


addForeignKey

public ForeignKey addForeignKey(org.xml.sax.Attributes attrib)
A utility function to create a new foreign key from attrib and add it to this table.


getChildrenColumn

public Column getChildrenColumn()

getChildrenNames

public java.util.List getChildrenNames()
Get the objects that can be created from this table.


addReferrer

public void addReferrer(ForeignKey fk)
Adds the foreign key from another table that refers to this table.


getReferrers

public java.util.List getReferrers()
Get list of references to this table.


setContainsForeignPK

public void setContainsForeignPK(boolean b)
Set whether this table contains a foreign PK


getContainsForeignPK

public boolean getContainsForeignPK()
Determine if this table contains a foreign PK


getForeignTableNames

public java.util.List getForeignTableNames()
A list of tables referenced by foreign keys in this table


addForeignKey

public void addForeignKey(ForeignKey fk)
Adds a new FK to the FK vector and set the parent table of the column to the current table


addIdMethodParameter

public IdMethodParameter addIdMethodParameter(org.xml.sax.Attributes attrib)
/** A utility function to create a new id method parameter from attrib and add it to this table.


addIdMethodParameter

public void addIdMethodParameter(IdMethodParameter imp)
Adds a new id method parameter to the vector and set the parent table of the column to the current table


addIndex

public void addIndex(Index index)
Adds a new index to the index vector and set the parent table of the column to the current table


addIndex

public Index addIndex(org.xml.sax.Attributes attrib)
A utility function to create a new index from attrib and add it to this table.


addUnique

public void addUnique(Unique unique)
Adds a new Unique to the Unique vector and set the parent table of the column to the current table


addUnique

public Unique addUnique(org.xml.sax.Attributes attrib)
A utility function to create a new Unique from attrib and add it to this table.


getName

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


setName

public void setName(java.lang.String newName)
Set the name of the Table


getJavaName

public java.lang.String getJavaName()
Get name to use in Java sources


setJavaName

public void setJavaName(java.lang.String javaName)
Set name to use in Java sources


getIdMethod

public java.lang.String getIdMethod()
Get the method for generating pk's


setIdMethod

public void setIdMethod(java.lang.String idMethod)
Set the method for generating pk's


isSkipSql

public boolean isSkipSql()
Skip generating sql for this table (in the event it should not be created from scratch).

Returns:
value of skipSql.

setSkipSql

public void setSkipSql(boolean v)
Set whether this table should have its creation sql generated.

Parameters:
v - Value to assign to skipSql.

getAlias

public java.lang.String getAlias()
JavaName of om object this entry references.

Returns:
value of external.

isAlias

public boolean isAlias()
Is this table specified in the schema or is there just a foreign key reference to it.

Returns:
value of external.

setAlias

public void setAlias(java.lang.String v)
Set whether this table specified in the schema or is there just a foreign key reference to it.

Parameters:
v - Value to assign to alias.

isAbstract

public boolean isAbstract()
When a table is abstract, it marks the business object class that is generated as being abstract. if you have a table called "FOO", then the Foo BO will be public abstract class Foo This helps support class hierarchies

Returns:
value of abstractValue.

setAbstract

public void setAbstract(boolean v)
When a table is abstract, it marks the business object class that is generated as being abstract. if you have a table called "FOO", then the Foo BO will be public abstract class Foo This helps support class hierarchies

Parameters:
v - Value to assign to abstractValue.

getColumns

public Column[] getColumns()
Returns an Array containing all the columns in the table


getNumColumns

public int getNumColumns()
Utility method to get the number of columns in this table


getForeignKeys

public ForeignKey[] getForeignKeys()
Returns an Array containing all the FKs in the table


getIdMethodParameters

public java.util.List getIdMethodParameters()
Returns a Collection of parameters relevant for the chosen id generation method.


getSequenceName

public java.lang.String getSequenceName()
A name to use for creating a sequence if one is not specified.


getIndices

public Index[] getIndices()
Returns an Array containing all the FKs in the table


getUnices

public Unique[] getUnices()
Returns an Array containing all the UKs in the table


getColumn

public Column getColumn(java.lang.String name)
Returns a specified column.

Returns:
Return a Column object or null if it does not exist.

getColumnByJavaName

public Column getColumnByJavaName(java.lang.String javaName)
Returns a specified column.

Returns:
Return a Column object or null if it does not exist.

getForeignKey

public ForeignKey getForeignKey(java.lang.String col)
Return the first foreign key that includes col in it's list of local columns. Eg. Foreign key (a,b,c) refrences tbl(x,y,z) will be returned of col is either a,b or c.

Returns:
Return a Column object or null if it does not exist.

containsColumn

public boolean containsColumn(Column col)
Returns true if the table contains a spesified column


containsColumn

public boolean containsColumn(java.lang.String name)
Returns true if the table contains a spesified column


setDatabase

public void setDatabase(Database parent)
Set the parent of the table


getDatabase

public Database getDatabase()
Get the parent of the table


toString

public java.lang.String toString()
Creates a string representation of this table. This is an xml representation.

Overrides:
toString in class java.lang.Object

getPrimaryKey

public java.util.List getPrimaryKey()
Returns the collection of Columns which make up the single primary key for this table.

Returns:
A list of the primary key parts.

getPrimaryKeys

public final java.util.ArrayList getPrimaryKeys()
Deprecated. Use getPrimaryKey() instead.


printPrimaryKey

public java.lang.String printPrimaryKey()
Returns all parts of the primary key, separated by commas.

Returns:
A CSV list of primary key parts.

printPrimaryKeys

public final java.lang.String printPrimaryKeys()
Deprecated. Use printPrimaryKey() instead.


getAdditionalIndicesForPrimaryKey

public java.util.List getAdditionalIndicesForPrimaryKey()
Returns a list of CSV strings for a primary key composed of multiple parts to create extra indices for. In MySQL, values much match key part order from the left to right. So, in the key definition PRIMARY KEY (FOO_ID, BAR_ID), FOO_ID must be the first element used in the where clause of the SQL query used against this table for the primary key index to be used. This feature could cause problems under MySQL with heavily indexed tables, as MySQL currently only supports 16 indices per table (i.e. it might cause too many indices to be created).

See the manual for a better description of this issue.

Returns:
A list of CSV list of primary key parts.


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