org.apache.torque.engine.database.model
Class Database

java.lang.Object
  extended by org.apache.torque.engine.database.model.Database
Direct Known Subclasses:
KualiDatabase

public class Database
extends Object

A class for holding application data structures.

Version:
$Id: Database.java,v 1.1.6.1 2008-04-01 04:07:48 jkeller Exp $
Author:
John McNally, Daniel Rall, Greg Monroe

Field Summary
private  String baseClass
           
private  String basePeer
           
private  String databaseType
           
private  String defaultIdMethod
           
private  String defaultJavaNamingMethod
           
private  String defaultJavaType
           
private  Map domainMap
           
private  String fileName
          the name of the definition file
private  boolean heavyIndexing
           
private  String javaName
           
private static org.apache.commons.logging.Log log
          Logging class from commons.logging
private  String name
           
private  Map options
           
private  String pkg
           
private  List tableList
           
private  Hashtable tablesByJavaName
           
private  Hashtable tablesByName
           
 
Constructor Summary
Database(String databaseType)
          Creates a new instance for the specified database type.
 
Method Summary
 void addDomain(Domain domain)
           
 void addOption(String key, String value)
          Add an XML Specified option key/value pair to this element's option set.
 Table addTable(Attributes attrib)
          An utility method to add a new table from an xml attribute.
 void addTable(Table tbl)
          Add a table to the list and sets the Database property to this Database
 void doFinalInitialization()
          Initializes the model.
 String getBaseClass()
          Get the value of baseClass.
 String getBasePeer()
          Get the value of basePeer.
protected  String getDatabaseType()
           
 String getDefaultIdMethod()
          Get the value of defaultIdMethod.
 String getDefaultJavaNamingMethod()
          Get the value of defaultJavaNamingMethod which specifies the method for converting schema names for table and column to Java names.
 String getDefaultJavaType()
          Get type to use in Java sources (primitive || object)
 Domain getDomain(String domainName)
           
 String getFileName()
           
 String getJavaName()
          Get the base name to use when creating related Java Classes.
 String getName()
          Get the name of the Database
 String getOption(String key)
          Get the value that was associated with this key in an XML option element.
 Map getOptions()
          Gets the full ordered hashtable array of items specified by XML option statements under this element.
 String getPackage()
          Get the value of package.
 Platform getPlatform()
          Returns the Platform implementation for this database.
 String getStandardJavaName()
          Convert dbName to a Java compatible name by the JavaName method only (ignores the defaultJavaNamingMethod).
 Table getTable(String name)
          Return the table with the specified name.
 Table getTableByJavaName(String javaName)
          Return the table with the specified javaName.
 List getTables()
          Return an List of all tables
 boolean isHeavyIndexing()
          Get the value of heavyIndexing.
 void loadFromXML(Attributes attrib)
          Load the database object from an xml tag.
 boolean requiresIdTable()
          Determines if this database will be using the IDMethod.ID_BROKER to create ids for torque OM objects.
 void setBaseClass(String v)
          Set the value of baseClass.
 void setBasePeer(String v)
          Set the value of basePeer.
 void setDatabaseType(String databaseType)
           
 void setDefaultIdMethod(String v)
          Set the value of defaultIdMethod.
 void setDefaultJavaNamingMethod(String v)
          Set the value of defaultJavaNamingMethod.
 void setFileName(String name)
           
 void setHeavyIndexing(boolean v)
          Set the value of heavyIndexing.
 void setName(String name)
          Set the name of the Database
 void setPackage(String v)
          Set the value of package.
 String toString()
          Creats a string representation of this Database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log
Logging class from commons.logging


databaseType

private String databaseType

tableList

private List tableList

domainMap

private Map domainMap

name

private String name

javaName

private String javaName

pkg

private String pkg

baseClass

private String baseClass

basePeer

private String basePeer

defaultIdMethod

private String defaultIdMethod

defaultJavaType

private String defaultJavaType

defaultJavaNamingMethod

private String defaultJavaNamingMethod

tablesByName

private Hashtable tablesByName

tablesByJavaName

private Hashtable tablesByJavaName

heavyIndexing

private boolean heavyIndexing

fileName

private String fileName
the name of the definition file


options

private Map options
Constructor Detail

Database

public Database(String databaseType)
Creates a new instance for the specified database type.

Parameters:
databaseType - The default type for this database.
Method Detail

loadFromXML

public void loadFromXML(Attributes attrib)
Load the database object from an xml tag.

Parameters:
attrib - the xml attributes

getName

public String getName()
Get the name of the Database

Returns:
name of the Database

setName

public void setName(String name)
Set the name of the Database

Parameters:
name - name of the Database

getFileName

public String getFileName()

setFileName

public void setFileName(String name)

getPackage

public String getPackage()
Get the value of package.

Returns:
value of package.

setPackage

public void setPackage(String v)
Set the value of package.

Parameters:
v - Value to assign to package.

getBaseClass

public String getBaseClass()
Get the value of baseClass.

Returns:
value of baseClass.

setBaseClass

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

Parameters:
v - Value to assign to baseClass.

getBasePeer

public String getBasePeer()
Get the value of basePeer.

Returns:
value of basePeer.

setBasePeer

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

Parameters:
v - Value to assign to basePeer.

getDefaultIdMethod

public String getDefaultIdMethod()
Get the value of defaultIdMethod.

Returns:
value of defaultIdMethod.

setDefaultIdMethod

public void setDefaultIdMethod(String v)
Set the value of defaultIdMethod.

Parameters:
v - Value to assign to defaultIdMethod.

getDefaultJavaType

public String getDefaultJavaType()
Get type to use in Java sources (primitive || object)

Returns:
the type to use

getDefaultJavaNamingMethod

public String getDefaultJavaNamingMethod()
Get the value of defaultJavaNamingMethod which specifies the method for converting schema names for table and column to Java names.

Returns:
The default naming conversion used by this database.

setDefaultJavaNamingMethod

public void setDefaultJavaNamingMethod(String v)
Set the value of defaultJavaNamingMethod.

Parameters:
v - The default naming conversion for this database to use.

isHeavyIndexing

public boolean isHeavyIndexing()
Get the value of heavyIndexing.

Returns:
value of heavyIndexing.

setHeavyIndexing

public void setHeavyIndexing(boolean v)
Set the value of heavyIndexing.

Parameters:
v - Value to assign to heavyIndexing.

getTables

public List getTables()
Return an List of all tables

Returns:
List of all tables

getTable

public Table getTable(String name)
Return the table with the specified name.

Parameters:
name - table name
Returns:
A Table object. If it does not exist it returns null

getTableByJavaName

public Table getTableByJavaName(String javaName)
Return the table with the specified javaName.

Parameters:
javaName - name of the java object representing the table
Returns:
A Table object. If it does not exist it returns null

addTable

public Table addTable(Attributes attrib)
An utility method to add a new table from an xml attribute.

Parameters:
attrib - the xml attributes
Returns:
the created Table

addTable

public void addTable(Table tbl)
Add a table to the list and sets the Database property to this Database

Parameters:
tbl - the table to add

addDomain

public void addDomain(Domain domain)

getDomain

public Domain getDomain(String domainName)

getDatabaseType

protected String getDatabaseType()

setDatabaseType

public void setDatabaseType(String databaseType)

getPlatform

public Platform getPlatform()
Returns the Platform implementation for this database.

Returns:
a Platform implementation

requiresIdTable

public boolean requiresIdTable()
Determines if this database will be using the IDMethod.ID_BROKER to create ids for torque OM objects.

Returns:
true if there is at least one table in this database that uses the IDMethod.ID_BROKER method of generating ids. returns false otherwise.

doFinalInitialization

public void doFinalInitialization()
                           throws EngineException
Initializes the model.

Throws:
EngineException

getJavaName

public String getJavaName()
Get the base name to use when creating related Java Classes.

Returns:
A Java syntax capatible version of the dbName using the method defined by the defaultJavaNamingMethod XML value.

getStandardJavaName

public String getStandardJavaName()
Convert dbName to a Java compatible name by the JavaName method only (ignores the defaultJavaNamingMethod).

Returns:
The current dbName converted to a standard format that can be used as part of a Java Object name.

toString

public String toString()
Creats a string representation of this Database. The representation is given in xml format.

Overrides:
toString in class Object
Returns:
string representation in xml

addOption

public void addOption(String key,
                      String value)
Add an XML Specified option key/value pair to this element's option set.

Parameters:
key - the key of the option.
value - the value of the option.

getOption

public String getOption(String key)
Get the value that was associated with this key in an XML option element.

Parameters:
key - the key of the option.
Returns:
The value for the key or a null.

getOptions

public Map getOptions()
Gets the full ordered hashtable array of items specified by XML option statements under this element.

Note, this is not thread save but since it's only used for generation which is single threaded, there should be minimum danger using this in Velocity.

Returns:
An Map of all options. Will not be null but may be empty.


Copyright © 2004-2011 The Kuali Foundation. All Rights Reserved.