org.objectweb.cjdbc.common.sql.schema
Class DatabaseTable

java.lang.Object
  extended byorg.objectweb.cjdbc.common.sql.schema.DatabaseTable
All Implemented Interfaces:
java.io.Serializable

public class DatabaseTable
extends java.lang.Object
implements java.io.Serializable

A DatabaseTable represents a database table ! It is just an array of TableColumns objects.

Keep it mind that ArrayList is not synchronized...

Version:
1.0
Author:
Emmanuel Cecchet, Mathieu Peltier, Sara Bouchenak
See Also:
Serialized Form

Field Summary
private  java.util.ArrayList columns
          ArrayList of DatabaseColumn.
private  java.lang.String name
          Database table name.
private static long serialVersionUID
           
 
Constructor Summary
  DatabaseTable(java.lang.String name)
          Creates a new DatabaseTable instance.
private DatabaseTable(java.lang.String name, java.util.ArrayList columns)
          Creates a new DatabaseTable instance.
  DatabaseTable(java.lang.String name, int nbOfColumns)
          Creates a new DatabaseTable instance.
 
Method Summary
 void addColumn(DatabaseColumn column)
          Adds a DatabaseColumn object to this table.
 boolean equals(java.lang.Object other)
          Two DatabaseColumn are considered equal if they have the same name and the same columns.
 boolean equalsIgnoreType(java.lang.Object other)
          This function is the same as equals but ignores the column type.
 DatabaseColumn getColumn(java.lang.String columnName)
          Returns the DatabaseColumn object matching the given column name or null if not found (the case is ignored).
 DatabaseColumn getColumn(java.lang.String columnName, boolean isCaseSensitive)
          Returns the DatabaseColumn object matching the given column name or null if not found (the case can be enforced).
 java.util.ArrayList getColumns()
          Returns a list of DatabaseColumn objects describing the columns of this table.
 java.lang.String getName()
          Gets the name of the table.
 java.util.ArrayList getUniqueColumns()
          Returns a list of DatabaseColumn objects representing the unique columns of this table.
 java.lang.String getXml()
          Get xml information about this table.
 void mergeColumns(DatabaseTable table)
          Merges this table with the given table's columns.
 void remove(DatabaseColumn column)
          Drops a DatabaseColumn object from this table.
 void remove(java.lang.String columnName)
          Drops a DatabaseColumn object from this table.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

name

private java.lang.String name
Database table name.


columns

private java.util.ArrayList columns
ArrayList of DatabaseColumn.

Constructor Detail

DatabaseTable

public DatabaseTable(java.lang.String name)
Creates a new DatabaseTable instance.

Parameters:
name - table name

DatabaseTable

public DatabaseTable(java.lang.String name,
                     int nbOfColumns)
Creates a new DatabaseTable instance.

Parameters:
name - table name
nbOfColumns - number of columns

DatabaseTable

private DatabaseTable(java.lang.String name,
                      java.util.ArrayList columns)
Creates a new DatabaseTable instance.

Parameters:
name - table name
columns - columns list
Method Detail

getName

public java.lang.String getName()
Gets the name of the table.

Returns:
the table name

addColumn

public void addColumn(DatabaseColumn column)
Adds a DatabaseColumn object to this table.

Warning! The underlying ArrayList is not synchronized.

Parameters:
column - a DatabaseColumn value

remove

public void remove(java.lang.String columnName)
Drops a DatabaseColumn object from this table.

Warning! The underlying ArrayList is not synchronized.

Parameters:
columnName - a String that maps to a DatabaseColumn value

remove

public void remove(DatabaseColumn column)
Drops a DatabaseColumn object from this table.

Warning! The underlying ArrayList is not synchronized.

Parameters:
column - a DatabaseColumn value

mergeColumns

public void mergeColumns(DatabaseTable table)
                  throws java.sql.SQLException
Merges this table with the given table's columns. All missing columns are added if no conflict is detected. An exception is thrown if the given table columns conflicts with this one.

Parameters:
table - the table to merge
Throws:
java.sql.SQLException - if the schemas conflict

getColumns

public java.util.ArrayList getColumns()
Returns a list of DatabaseColumn objects describing the columns of this table.

Warning! The underlying ArrayList is not synchronized.

Returns:
an ArrayList of DatabaseColumn

getUniqueColumns

public java.util.ArrayList getUniqueColumns()
Returns a list of DatabaseColumn objects representing the unique columns of this table.

Warning! The underlying ArrayList is not synchronized.

Returns:
an ArrayList of DatabaseColumn objects

getColumn

public DatabaseColumn getColumn(java.lang.String columnName)
Returns the DatabaseColumn object matching the given column name or null if not found (the case is ignored).

Parameters:
columnName - column name to look for
Returns:
a DatabaseColumn value or null

getColumn

public DatabaseColumn getColumn(java.lang.String columnName,
                                boolean isCaseSensitive)
Returns the DatabaseColumn object matching the given column name or null if not found (the case can be enforced).

Parameters:
columnName - column name to look for
isCaseSensitive - true if name matching must be case sensitive
Returns:
a DatabaseColumn value or null

equals

public boolean equals(java.lang.Object other)
Two DatabaseColumn are considered equal if they have the same name and the same columns.

Parameters:
other - the object to compare with
Returns:
true if the tables are equal

equalsIgnoreType

public boolean equalsIgnoreType(java.lang.Object other)
This function is the same as equals but ignores the column type.

Parameters:
other - the object to compare with
Returns:
true if the table are equal ignoring the columns type
See Also:
equals(Object)

getXml

public java.lang.String getXml()
Get xml information about this table.

Returns:
xml formatted information on this database table.


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.