org.apache.torque.engine.database.transform
Class SQLToAppData

java.lang.Object
  extended by org.apache.torque.engine.database.transform.SQLToAppData

public class SQLToAppData
extends Object

A Class that converts an sql input file to a Database structure. The class makes use of SQL Scanner to get sql tokens and the parses these to create the Database class. SQLToAppData is in effect a simplified sql parser.

Version:
$Id: SQLToAppData.java,v 1.1 2007-10-21 07:57:26 abyrne Exp $
Author:
Leon Messerschmidt, Jon S. Stevens

Field Summary
private  Database appDataDB
           
private  int count
           
private  String databaseType
           
private  String sqlFile
           
private  Token token
           
private  List tokens
           
 
Constructor Summary
SQLToAppData(String sqlFile)
          Create a new class with an input Reader
SQLToAppData(String sqlFile, String databaseType)
          Create a new class with an input Reader.
 
Method Summary
private  void create_Table_Column_Data(Table tbl)
          Parse the data definition of the column statement.
private  void create_Table_Column_Foreign(Table tbl)
          Parses FOREIGN KEY (BAR) REFERENCES TABLE (BAR) statement
private  void create_Table_Column_Primary(Table tbl)
          Parses PRIMARY KEY (FOO,BAR) statement
private  void create_Table_Column_Unique(Table tbl)
          Parses UNIQUE (NAME,FOO,BAR) statement
private  void create_Table_Column(Table tbl)
          Parses column information between the braces of a CREATE TABLE () sql statement.
private  void create_Table()
          Parses a CREATE TABLE sql command
private  void create()
          Parses a CREATE TABLE FOO command.
private  void err(String name)
          Creates an error condition and adds the line and column number of the current token to the error message.
 Database execute()
          Execute the parser.
 String getSqlFile()
          Get the current input sql file
private  boolean hasTokens()
          Check if there is more tokens available for parsing.
private  void next()
          Move to the next token.
 void setSqlFile(String sqlFile)
          Set the current input sql file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sqlFile

private String sqlFile

tokens

private List tokens

token

private Token token

appDataDB

private Database appDataDB

count

private int count

databaseType

private String databaseType
Constructor Detail

SQLToAppData

public SQLToAppData(String sqlFile)
Create a new class with an input Reader

Parameters:
sqlFile - the sql file

SQLToAppData

public SQLToAppData(String sqlFile,
                    String databaseType)
Create a new class with an input Reader. This ctor is not used but putting here in the event db.props properties are found to be useful converting sql to xml, the infrastructure will exist

Parameters:
sqlFile - the sql file
databaseType -
Method Detail

getSqlFile

public String getSqlFile()
Get the current input sql file

Returns:
the sql file

setSqlFile

public void setSqlFile(String sqlFile)
Set the current input sql file

Parameters:
sqlFile - the sql file

next

private void next()
           throws ParseException
Move to the next token.

Throws:
ParseException - if there is no more tokens available.

err

private void err(String name)
          throws ParseException
Creates an error condition and adds the line and column number of the current token to the error message.

Parameters:
name - name of the error
Throws:
ParseException

hasTokens

private boolean hasTokens()
Check if there is more tokens available for parsing.

Returns:
true if there are more tokens available

create

private void create()
             throws ParseException
Parses a CREATE TABLE FOO command.

Throws:
ParseException

create_Table

private void create_Table()
                   throws ParseException
Parses a CREATE TABLE sql command

Throws:
ParseException - error parsing the input file

create_Table_Column

private void create_Table_Column(Table tbl)
                          throws ParseException
Parses column information between the braces of a CREATE TABLE () sql statement.

Throws:
ParseException - error parsing the input file

create_Table_Column_Primary

private void create_Table_Column_Primary(Table tbl)
                                  throws ParseException
Parses PRIMARY KEY (FOO,BAR) statement

Throws:
ParseException - error parsing the input file

create_Table_Column_Unique

private void create_Table_Column_Unique(Table tbl)
                                 throws ParseException
Parses UNIQUE (NAME,FOO,BAR) statement

Throws:
ParseException - error parsing the input file

create_Table_Column_Foreign

private void create_Table_Column_Foreign(Table tbl)
                                  throws ParseException
Parses FOREIGN KEY (BAR) REFERENCES TABLE (BAR) statement

Throws:
ParseException - error parsing the input file

create_Table_Column_Data

private void create_Table_Column_Data(Table tbl)
                               throws ParseException
Parse the data definition of the column statement.

Throws:
ParseException - error parsing the input file

execute

public Database execute()
                 throws IOException,
                        ParseException
Execute the parser.

Throws:
IOException - If an I/O error occurs
ParseException - error parsing the input file


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