|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.brains2b.task.DefaultTask
org.brains2b.sql.toclass.SqlClassWriter
Abstract class which supplies some general functions to classes generating Class files from a database source.
Field Summary | |
protected java.io.File |
m_location
|
protected java.lang.String |
m_packageName
|
protected org.brains2b.sql.meta.SqlTableModel |
m_tableModel
|
Fields inherited from interface org.brains2b.task.Task |
RESULT_ERROR, RESULT_OK, RESULT_WARNING |
Constructor Summary | |
protected |
SqlClassWriter(java.io.File location,
java.lang.String packageName)
Constructor |
Method Summary | |
boolean |
fileExists(java.lang.String tableName)
test if the file you want to create already exists based on the tablename supplied. |
protected abstract java.lang.String |
getClassName(java.lang.String name)
get the class name to be generated for the type of file. |
protected java.io.File |
getFile(java.io.File location,
java.lang.String packageName,
java.lang.String className)
get the File name on the basis of the supplied location, packageName and className |
abstract java.io.File |
getResultfile()
abstract method for returning the generated file |
void |
setTableModel(org.brains2b.sql.meta.SqlTableModel tableModel)
sets the model for the table used for generating the file |
protected java.lang.String |
varName(java.lang.String str)
check if a varName is not a java keyword and can be used as a variable name otherwise prepend x_ to it and use that as variable name
|
Methods inherited from class org.brains2b.task.DefaultTask |
addException, addMessage, addTaskListener, fireTaskEvent, getMax, getMessages, getMin, getPosition, getResult, isFinished, progress, removeTaskListener, setFinished, setMax, setMin, setResult |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.lang.Runnable |
run |
Field Detail |
protected java.io.File m_location
protected java.lang.String m_packageName
protected org.brains2b.sql.meta.SqlTableModel m_tableModel
Constructor Detail |
protected SqlClassWriter(java.io.File location, java.lang.String packageName)
location
- File, set the location to write the file to, this location should exist before run is called
on this class. If this is null the current directory is usedpackageName
- String, the packageName for the class, names should be separated by dots. The packagename
is both used to set the package name of the class as to create or use the directory relative to location to write the file to.
If this is null no package name is used when creating this file.Method Detail |
protected abstract java.lang.String getClassName(java.lang.String name)
Implementation is left to the class extending this class
name
- String, the table name
public boolean fileExists(java.lang.String tableName)
This method will return true on any IOException
except
FileNotFoundException
to make sure a valid file exists after the
generation has finished.
tableName
- String, the tableName
isFileSame
#isFileSame(File)
public void setTableModel(org.brains2b.sql.meta.SqlTableModel tableModel)
tableModel
- SqlTableModel, the table model usedprotected java.io.File getFile(java.io.File location, java.lang.String packageName, java.lang.String className) throws java.io.IOException
location
- File, the location.packageName
- String, the new or existing packageName. If new will be created at the
location. If location is null the packageName will be ignoredclassName
- String, the name of the class, a result of getClassName()
java.io.IOException
- thrown if createPackageDir
fails#createPackageDir(File, String)
protected java.lang.String varName(java.lang.String str)
x_
to it and use that as variable name
This method also makes sure at least the first letter is a lowercase letter
str
- String, the value which needs to be used a variable Name
KeyWords
public abstract java.io.File getResultfile()
implementation is left to the classes extending this class
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |