org.apache.torque.map
Class DatabaseMap

java.lang.Object
  extended byorg.apache.torque.map.DatabaseMap
All Implemented Interfaces:
java.io.Serializable

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

DatabaseMap is used to model a database.

Version:
$Id: DatabaseMap.java,v 1.7 2002/09/13 06:00:49 mpoeschl Exp $
Author:
John D. McNally, Daniel Rall
See Also:
Serialized Form

Field Summary
private  IDBroker idBroker
          The IDBroker that goes with the idTable.
private  java.util.HashMap idGenerators
          The IdGenerators, keyed by type of idMethod.
private  TableMap idTable
          A special table used to generate primary keys for the other tables.
private  java.lang.String name
          Name of the database.
private  java.util.Hashtable tables
          Name of the tables in the database.
 
Constructor Summary
DatabaseMap()
          Required by proxy.
DatabaseMap(java.lang.String name)
          Constructor.
DatabaseMap(java.lang.String name, int numberOfTables)
          Constructor.
 
Method Summary
 void addIdGenerator(java.lang.String type, IdGenerator idGen)
          Add a type of id generator for access by a TableMap.
 void addTable(java.lang.String tableName)
          Add a new table to the database by name.
 void addTable(java.lang.String tableName, int numberOfColumns)
          Add a new table to the database by name.
 void addTable(TableMap map)
          Add a new TableMap to the database.
 boolean containsTable(java.lang.String name)
          Does this database contain this specific table?
 boolean containsTable(TableMap table)
          Does this database contain this specific table?
 IDBroker getIDBroker()
          Get the IDBroker for this database.
(package private)  IdGenerator getIdGenerator(java.lang.String type)
          Get a type of id generator.
 TableMap getIdTable()
          Get the ID table for this database.
 java.lang.String getName()
          Get the name of this database.
 TableMap getTable(java.lang.String name)
          Get a TableMap for the table by name.
 TableMap[] getTables()
          Get a TableMap[] of all of the tables in the database.
 void setIdTable(java.lang.String tableName)
          Set the ID table for this database.
 void setIdTable(TableMap idTable)
          Set the ID table for this database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private java.lang.String name
Name of the database.


tables

private java.util.Hashtable tables
Name of the tables in the database.


idTable

private TableMap idTable
A special table used to generate primary keys for the other tables.


idBroker

private IDBroker idBroker
The IDBroker that goes with the idTable.


idGenerators

private java.util.HashMap idGenerators
The IdGenerators, keyed by type of idMethod.

Constructor Detail

DatabaseMap

public DatabaseMap()
Required by proxy. Not used.


DatabaseMap

public DatabaseMap(java.lang.String name,
                   int numberOfTables)
Constructor.

Parameters:
name - Name of the database.
numberOfTables - Number of tables in the database.

DatabaseMap

public DatabaseMap(java.lang.String name)
Constructor.

Parameters:
name - Name of the database.
Method Detail

containsTable

public boolean containsTable(TableMap table)
Does this database contain this specific table?

Parameters:
table - The TableMap representation of the table.
Returns:
True if the database contains the table.

containsTable

public boolean containsTable(java.lang.String name)
Does this database contain this specific table?

Parameters:
name - The String representation of the table.
Returns:
True if the database contains the table.

getIdTable

public TableMap getIdTable()
Get the ID table for this database.

Returns:
A TableMap.

getIDBroker

public IDBroker getIDBroker()
Get the IDBroker for this database.

Returns:
An IDBroker.

getName

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

Returns:
A String.

getTable

public TableMap getTable(java.lang.String name)
Get a TableMap for the table by name.

Parameters:
name - Name of the table.
Returns:
A TableMap, null if the table was not found.

getTables

public TableMap[] getTables()
Get a TableMap[] of all of the tables in the database.

Returns:
A TableMap[].

addTable

public void addTable(java.lang.String tableName)
Add a new table to the database by name. It creates an empty TableMap that you need to populate.

Parameters:
tableName - The name of the table.

addTable

public void addTable(java.lang.String tableName,
                     int numberOfColumns)
Add a new table to the database by name. It creates an empty TableMap that you need to populate.

Parameters:
tableName - The name of the table.
numberOfColumns - The number of columns in the table.

addTable

public void addTable(TableMap map)
Add a new TableMap to the database.

Parameters:
map - The TableMap representation.

setIdTable

public void setIdTable(TableMap idTable)
Set the ID table for this database.

Parameters:
idTable - The TableMap representation for the ID table.

setIdTable

public void setIdTable(java.lang.String tableName)
Set the ID table for this database.

Parameters:
tableName - The name for the ID table.

addIdGenerator

public void addIdGenerator(java.lang.String type,
                           IdGenerator idGen)
Add a type of id generator for access by a TableMap.

Parameters:
type - a String value
idGen - an IdGenerator value

getIdGenerator

IdGenerator getIdGenerator(java.lang.String type)
Get a type of id generator. Valid values are listed in the IDMethod interface.

Parameters:
type - a String value
Returns:
an IdGenerator value


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