Dresden OCL Toolkit

tudresden.ocl.sql
Class DDLGenerator

java.lang.Object
  extended bytudresden.ocl.sql.DDLGenerator

class DDLGenerator
extends Object

A DDL (Data Definition Language) generator. The generator takes a ORMapping implementation as input and generates a script that contains a number of table definitions including primary and foreign key references. Which tables are going to be created is determined by the implementation of ORMapping, which does the actual object relational mapping. The DDLGenerator just queries the information produced by the implementation of ORMapping and generates the appropriate DDL script. The generated DDL script is executable on Oracle 8i. To adapt the Generator for other database systems, just subclass DDLGenerator and replace the String variables that contain the DDL tokens.

Author:
Sten Loecher
See Also:
ORMapping

Field Summary
private static String CONSTRAINT_NAME
           
private  int constraintCount
           
private  boolean scriptGenerated
           
private  String theScript
           
private  SQLBuilder theSQLBuilder
           
 
Constructor Summary
(package private) DDLGenerator()
           
 
Method Summary
 void createDDL(ORMapping orm, SQLBuilder sqlb)
          Creates the DDL script.
private  void createTable(Table t)
          Generates the table definition including the primary key constraints for a table.
 String getDDLScript()
           
static void main(String[] arg)
          For command line and debugging operations only.
private  void setForeignKeys(Table t)
          Generates alter table statements to create foreign key references.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theScript

private String theScript

constraintCount

private int constraintCount

scriptGenerated

private boolean scriptGenerated

theSQLBuilder

private SQLBuilder theSQLBuilder

CONSTRAINT_NAME

private static String CONSTRAINT_NAME
Constructor Detail

DDLGenerator

DDLGenerator()
Method Detail

main

public static void main(String[] arg)
For command line and debugging operations only. Generates a SQL DDL script from a xmi source and stores it to the specified destination.


getDDLScript

public String getDDLScript()
                    throws IllegalStateException
Returns:
the DDL script
Throws:
IllegalStateException - if no script was generated before calling this methode

createDDL

public void createDDL(ORMapping orm,
                      SQLBuilder sqlb)
Creates the DDL script.


createTable

private void createTable(Table t)
Generates the table definition including the primary key constraints for a table.

Parameters:
t - the table for which the definitions should be created

setForeignKeys

private void setForeignKeys(Table t)
Generates alter table statements to create foreign key references.

Parameters:
t - the table for which the alter table statements should be created

Dresden OCL Toolkit

Submit a bug
Developed at the Dresden University of Technology.
This software is published under the GNU Lesser General Public License.