|
||||||||
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
org.brains2b.sql.toclass.Sql2File
public class Sql2File
This class writes an SQL Table which is supplied through an SqlTableModel
to a data class, with the necessary accessors
This class is called from Sql2ClassConsole
and some other implementations
which supply the necessary information. If you use this class just to generate files look at
Sql2ClassConsole
first.
The naming of the new class file will be equal to the table name, but with initial caps. example: EMPLOYEES will become Employees. Underscores will be treated as an instance to initialize caps again. example: EMP_SALARIES will become EmpSalaries
The class is written to the given location and packageName. The location should not include the
package directory itself. If the package directory does not exist it will be created. If the location
does not exist you will get a FileNotFoundException
The option dennis@brains2b.nl
Sql2ClassConsole
,
TableModel
,
Sql2DataC
Field Summary |
---|
Fields inherited from class org.brains2b.sql.toclass.SqlClassWriter |
---|
m_location, m_packageName, m_tableModel, m_typeInfo |
Fields inherited from interface org.brains2b.task.Task |
---|
RESULT_ERROR, RESULT_OK, RESULT_WARNING |
Constructor Summary | |
---|---|
Sql2File(java.io.File location,
java.lang.String packageName)
Constructor |
|
Sql2File(java.io.File location,
java.lang.String packageName,
org.brains2b.sql.meta.TableModel tm)
Constructor |
Method Summary | |
---|---|
protected java.lang.String |
getClassName(java.lang.String name)
get the class name for the data class |
java.io.File |
getResultfile()
get the file which has been created. |
boolean |
isDefault()
check if defaults should be generated for the class |
protected boolean |
isOptimisticLock()
does this class use optimistic locking |
boolean |
isTrimValue()
|
void |
run()
run does the actual work in this class. |
void |
setDefault(boolean default1)
set indicator to generate default values from table as default in the class |
void |
setOptimisticLock(boolean b)
set this to true if optimistic locking should be used. |
void |
setTableModel(org.brains2b.sql.meta.TableModel tableModel)
overwritten to retrieve the columns for local use |
void |
setTrimValue(boolean trimValue)
|
Methods inherited from class org.brains2b.sql.toclass.SqlClassWriter |
---|
fileExists, getFile, getUnreserverdWord, isPrimaryKey, setTypeInfo, varName |
Methods inherited from class org.brains2b.task.DefaultTask |
---|
addException, addMessage, addTaskListener, fireTaskEvent, getMax, getMessages, getMin, getPosition, getResult, isFinished, progress, progress, removeTaskListener, setFinished, setMax, setMin, setResult |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Sql2File(java.io.File location, java.lang.String packageName, org.brains2b.sql.meta.TableModel tm)
location
- File, set the location to write the file to, this location should exist before run is called
on this class.packageName
- 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.tm
- org.brains2b.sql.meta.SqlTableModel, the table model to base this dataclass onpublic Sql2File(java.io.File location, java.lang.String packageName)
This constructor does not set the TableModel, this is however required
for this class to be able to generate the file. You should set the tablemodel
by calling setTableModel(org.brains2b.sql.meta.SqlTableModel)
location
- File, set the location to write the file to, this location should exist before run is called
on this class.packageName
- 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.#setTableModel(SqlTableModel)
Method Detail |
---|
public void setTableModel(org.brains2b.sql.meta.TableModel tableModel)
setTableModel
in class SqlClassWriter
tableModel
- SqlTableModel, the table model usedorg.brains2b.sql.toclass.SqlClassWriter#setTableModel(SqlTableModel)
public void run()
Output is written to the org.brains2b.log.Logger
. Dependant
on the setting there the code will show up on System.out
. This is
the case if you do nothing
Runnable.run()
,
DefaultTask.setFinished(boolean)
,
Logger
public java.io.File getResultfile()
The result of this file is only valid after run()
has finished
getResultfile
in class SqlClassWriter
SqlClassWriter.getResultfile()
,
run()
protected java.lang.String getClassName(java.lang.String name)
getClassName
in class SqlClassWriter
name
- String, the table name
SqlClassWriter.getClassName(String)
protected boolean isOptimisticLock()
public void setOptimisticLock(boolean b)
by default optimistic locking is not used.
b
- booleanpublic boolean isTrimValue()
public void setTrimValue(boolean trimValue)
trimValue
- The trimValue to set.public boolean isDefault()
public void setDefault(boolean default1)
default1
- boolean, true if default should be
generated, false otherwise
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |