net.sourceforge.sql2java
Class CodeWriter

java.lang.Object
  extended by net.sourceforge.sql2java.CodeWriter

public class CodeWriter
extends java.lang.Object


Field Summary
protected static java.lang.String basePackage
           
static java.lang.String classPrefix
           
protected  VelocityContext current_vc
           
protected static java.lang.String dateClassName
           
protected static Database db
           
protected static java.lang.String destDir
           
protected static java.util.Hashtable excludeHash
           
protected static java.util.Hashtable includeHash
           
static java.lang.String MGR_CLASS
           
protected static java.lang.String optimisticLockColumn
           
protected static java.lang.String optimisticLockType
           
protected static java.util.Properties props
           
 Table table
           
protected static java.lang.String timeClassName
           
protected static java.lang.String timestampClassName
           
protected  VelocityContext vc
           
 
Constructor Summary
CodeWriter(Database db, java.util.Properties props)
          The Default Constructor
 
Method Summary
static boolean authorizeFile(java.lang.String folder, java.lang.String schemaOrTable)
          is this file to be processed or not ?
static boolean authorizeProcess(java.lang.String autorizePattern, java.lang.String includeProperty, java.lang.String excludeProperty)
          check the value for include & exclude lists defined in the config file
 void checkDatabase()
           
 boolean checkTable(Table newTable)
           
static boolean folderContainsPattern(java.lang.String folder, java.lang.String[] patterns)
           
 java.lang.String getClassPrefix()
           
 Database getDb()
          Public accessor for db
static java.lang.String[] getExplodedString(java.lang.String value)
           
 java.lang.String getLoadingPath()
          get loading path
static java.lang.String getProperty(java.lang.String key)
          Convenience property chop method
static java.lang.String getProperty(java.lang.String key, java.lang.String default_val)
          Convenience property chop method
static java.lang.String[] getPropertyExploded(java.lang.String key)
          Return as a String array the key's value.
static java.lang.String[] getPropertyExploded(java.lang.String mkey, java.lang.String defaultValue)
           
 java.util.List getRelationTables()
          Returns from db.getTables() those having isRelationTable() evaluating to true.
 java.lang.String[] getSchemaTemplates(java.lang.String property)
           
 Table getTable()
          public accessor for table
 Table getTable(java.lang.String tableName)
          Public db.getTable()
 java.util.List getTables()
          Public db.getTables()
 java.lang.String[] getTableTemplates(java.lang.String property)
           
 java.lang.String[] getTemplates(java.lang.String property, boolean perShema)
           
 boolean listContainsString(java.util.List list, java.lang.String string)
          Check if a list contains an item that is equal() to a string
 void log(java.lang.String logStr)
          System.out.println() wrapper
 void process()
          The entry point for generating code.
 java.util.Vector recurseTemplate(java.util.Vector files, java.lang.String folder, boolean perSchema)
          recurse in the template folders
 void setCurrentFilename(java.lang.String relpath_or_package, java.lang.String fn)
           
 void setCurrentJavaFilename(java.lang.String relpath_or_package, java.lang.String fn)
           
 void setDestinationFolder(java.lang.String destDir)
           
 java.lang.String tableName()
          Return table.getName()
 void writeComponent(java.lang.String templateName)
          This method creates a file and generates the class; it is based on the original SQL2Java methods The filename for the class is based on the value of the Velocity variable passed in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

props

protected static java.util.Properties props

MGR_CLASS

public static java.lang.String MGR_CLASS

dateClassName

protected static java.lang.String dateClassName

timeClassName

protected static java.lang.String timeClassName

timestampClassName

protected static java.lang.String timestampClassName

db

protected static Database db

includeHash

protected static java.util.Hashtable includeHash

excludeHash

protected static java.util.Hashtable excludeHash

basePackage

protected static java.lang.String basePackage

destDir

protected static java.lang.String destDir

optimisticLockType

protected static java.lang.String optimisticLockType

optimisticLockColumn

protected static java.lang.String optimisticLockColumn

classPrefix

public static java.lang.String classPrefix

vc

protected VelocityContext vc

table

public Table table

current_vc

protected VelocityContext current_vc
Constructor Detail

CodeWriter

public CodeWriter(Database db,
                  java.util.Properties props)
The Default Constructor

Parameters:
props - Properties for configuring this instance
Method Detail

setDestinationFolder

public void setDestinationFolder(java.lang.String destDir)
                          throws java.lang.Exception
Throws:
java.lang.Exception

checkTable

public boolean checkTable(Table newTable)
                   throws java.lang.Exception
Throws:
java.lang.Exception

checkDatabase

public void checkDatabase()
                   throws java.lang.Exception
Throws:
java.lang.Exception

process

public void process()
             throws java.lang.Exception
The entry point for generating code.

Throws:
java.lang.Exception

writeComponent

public void writeComponent(java.lang.String templateName)
                    throws java.lang.Exception
This method creates a file and generates the class; it is based on the original SQL2Java methods The filename for the class is based on the value of the Velocity variable passed in.

Parameters:
templateName - The template to parse and generate from
variableFileName - A velocity variable on which to base the filename
Throws:
java.lang.Exception - (IOExceptions?)

setCurrentFilename

public void setCurrentFilename(java.lang.String relpath_or_package,
                               java.lang.String fn)
                        throws java.lang.Exception
Throws:
java.lang.Exception

setCurrentJavaFilename

public void setCurrentJavaFilename(java.lang.String relpath_or_package,
                                   java.lang.String fn)
                            throws java.lang.Exception
Throws:
java.lang.Exception

log

public void log(java.lang.String logStr)
System.out.println() wrapper


getClassPrefix

public java.lang.String getClassPrefix()

getDb

public Database getDb()
Public accessor for db


getTables

public java.util.List getTables()
Public db.getTables()


getTable

public Table getTable(java.lang.String tableName)
Public db.getTable()


getRelationTables

public java.util.List getRelationTables()
Returns from db.getTables() those having isRelationTable() evaluating to true.


tableName

public java.lang.String tableName()
Return table.getName()


getTable

public Table getTable()
public accessor for table


listContainsString

public boolean listContainsString(java.util.List list,
                                  java.lang.String string)
Check if a list contains an item that is equal() to a string


getProperty

public static java.lang.String getProperty(java.lang.String key)
Convenience property chop method

Parameters:
key - the property to get from this.props
Returns:
the associated value

getProperty

public static java.lang.String getProperty(java.lang.String key,
                                           java.lang.String default_val)
Convenience property chop method

Parameters:
key - the property to get from this.props
default_val - the default value to return in case not found
Returns:
the associated value

getPropertyExploded

public static java.lang.String[] getPropertyExploded(java.lang.String key)
Return as a String array the key's value.


getPropertyExploded

public static java.lang.String[] getPropertyExploded(java.lang.String mkey,
                                                     java.lang.String defaultValue)

getExplodedString

public static java.lang.String[] getExplodedString(java.lang.String value)

getLoadingPath

public java.lang.String getLoadingPath()
get loading path


getSchemaTemplates

public java.lang.String[] getSchemaTemplates(java.lang.String property)

getTableTemplates

public java.lang.String[] getTableTemplates(java.lang.String property)

getTemplates

public java.lang.String[] getTemplates(java.lang.String property,
                                       boolean perShema)

recurseTemplate

public java.util.Vector recurseTemplate(java.util.Vector files,
                                        java.lang.String folder,
                                        boolean perSchema)
recurse in the template folders


authorizeProcess

public static boolean authorizeProcess(java.lang.String autorizePattern,
                                       java.lang.String includeProperty,
                                       java.lang.String excludeProperty)
check the value for include & exclude lists defined in the config file


folderContainsPattern

public static boolean folderContainsPattern(java.lang.String folder,
                                            java.lang.String[] patterns)

authorizeFile

public static boolean authorizeFile(java.lang.String folder,
                                    java.lang.String schemaOrTable)
is this file to be processed or not ?



Copyright © 2002-2007 . All Rights Reserved.