public class CodeWriter extends Object
| Modifier and Type | Field and Description |
|---|---|
protected String |
basePackage |
String |
classPrefix |
protected org.apache.velocity.VelocityContext |
current_vc |
protected static String |
dateClassName |
protected Database |
db |
protected String |
destDir |
protected Hashtable |
excludeHash |
protected Hashtable |
includeHash |
protected String |
libraryPackage |
protected String |
optimisticLockColumn |
protected String |
optimisticLockType |
protected static Properties |
props |
Table |
table |
protected static String |
timeClassName |
protected static String |
timestampClassName |
protected boolean |
useLibrary |
protected org.apache.velocity.VelocityContext |
vc |
| Constructor and Description |
|---|
CodeWriter(Database db,
Properties props)
The Default Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkDatabase() |
boolean |
checkTable(Table table) |
void |
cleanup() |
String |
getClassPrefix() |
List |
getColumns()
Return table.getColumns() as a List
|
Database |
getDb()
Public accessor for db
|
List |
getForeignKeys()
Return table.getForeignKeys() as a List
|
List |
getImportedKeys()
Return table.getImportedKeys() as a List
|
List |
getLinkedTables(Table rTable)
Returns a table's linked tables as a list
|
Column |
getLockColumn(Collection cols)
Find the column in the Collection that matches optimisticLockColumn
|
List |
getPrimaryKeys()
Return table.getPrimaryKeys() as a List
|
static String |
getProperty(String key)
Convenience property chop method
|
static String |
getProperty(String key,
String default_val)
Convenience property chop method
|
static String[] |
getPropertyExploded(String key)
Return as a String array the key's value.
|
List |
getRelationTable()
Returns a db.getRelationTable( table ) as a list
|
String |
getRemarks()
Returns the current table's remarks.
|
Table |
getTable()
public accessor for table
|
Table |
getTable(String tableName)
Public db.getTables()
|
List |
getTables()
Public db.getTables()
|
boolean |
hasRemarks()
Returns true if the current table.getRemarks().length() > 0
|
boolean |
isPresentLock(Collection cols)
Wrapper for the static Column method
|
boolean |
listContainsString(List list,
String string)
Check if a list contains an item that is equal() to a string
|
void |
log(String logStr)
System.out.println() wrapper
|
void |
process()
The entry point for generating code.
|
void |
setCurrentFilename(String relpath_or_package,
String fn) |
void |
setCurrentJavaFilename(String relpath_or_package,
String fn) |
void |
setDestinationFolder(String destDir) |
void |
setUseLibrary(String libraryPackage) |
String |
tableName()
Return table.getName()
|
void |
writeComponent(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.
|
protected static Properties props
protected static String dateClassName
protected static String timeClassName
protected static String timestampClassName
protected Database db
protected Hashtable includeHash
protected Hashtable excludeHash
protected String basePackage
protected String destDir
protected String optimisticLockType
protected String optimisticLockColumn
public String classPrefix
protected org.apache.velocity.VelocityContext vc
public Table table
protected org.apache.velocity.VelocityContext current_vc
protected boolean useLibrary
protected String libraryPackage
public CodeWriter(Database db, Properties props)
props - Properties for configuring this instancepublic void setUseLibrary(String libraryPackage)
public void setDestinationFolder(String destDir) throws Exception
Exceptionpublic void cleanup()
public void process()
throws Exception
Exceptionpublic void writeComponent(String templateName) throws Exception
templateName - The template to parse and generate fromvariableFileName - A velocity variable on which to base the filenameException - (IOExceptions?)public void setCurrentFilename(String relpath_or_package, String fn) throws Exception
Exceptionpublic void setCurrentJavaFilename(String relpath_or_package, String fn) throws Exception
Exceptionpublic void log(String logStr)
public String getClassPrefix()
public Database getDb()
public List getTables()
public String tableName()
public List getColumns()
public List getImportedKeys()
public List getForeignKeys()
public List getPrimaryKeys()
public boolean hasRemarks()
public String getRemarks()
public List getRelationTable()
public boolean isPresentLock(Collection cols)
public Column getLockColumn(Collection cols)
public Table getTable()
public boolean listContainsString(List list, String string)
public static String getProperty(String key)
key - the property to get from this.propspublic static String getProperty(String key, String default_val)
key - the property to get from this.propsdefault_val - the default value to return in case not foundCopyright © 2014. All Rights Reserved.