org.ephman.abra.tools
Class GenericFactoryGenerator

java.lang.Object
  |
  +--org.ephman.abra.tools.GenericFactoryGenerator
All Implemented Interfaces:
AbraTypes
Direct Known Subclasses:
FactoryGenerator

public abstract class GenericFactoryGenerator
extends java.lang.Object
implements AbraTypes

(this is the generic base a db specific descendant will be copied into this package given a base output directory generate a factory class for get/put when given a JClass descriptor

Version:
0.0.2
Author:
Paul M. Bethe

Nested Class Summary
(package private)  class GenericFactoryGenerator.InlineFieldWriter
           
(package private)  class GenericFactoryGenerator.NativeObjectMapping
           
 
Field Summary
(package private)  java.lang.String constructorString
           
(package private)  java.lang.String END_DATE
           
(package private) static java.util.HashSet nativeClassSet
           
(package private) static java.util.HashMap nativeSetTypes
           
protected  java.util.HashMap typeMap
           
static java.lang.String VERSION_NUMBER
           
 
Fields inherited from interface org.ephman.abra.tools.AbraTypes
BIG_DECIMAL, BIG_INTEGER, BLOB, BOOLEAN, BOOLEAN_OBJ, CHARACTER, CLOB, DOUBLE, DOUBLE_OBJ, FLOAT, INTEGER, INTEGER_OBJ, LONG, STRING, TIMESTAMP
 
Constructor Summary
GenericFactoryGenerator(java.lang.String outdir, char file_sep, java.lang.String imp, boolean useProcs)
          make a new generator with a base directory of outdir so for foo.bar.FooBar if outdir = /home/dknull and file_sep = '/' then a class /home/dknull/foo/bar/AbstractFooBarFactory.java is created
 
Method Summary
protected  java.lang.String createClobString()
           
protected  void createTypeMap()
           
 void generate(JClass currentClass)
           
abstract  java.lang.String getPrimaryKeyString(JClass currentClass)
          methods which should be implemented by descendant generator
 java.util.HashMap getTypeMap()
           
protected  boolean setPKInInsertStmt()
          override to false if auto increment is turned on..
protected  boolean usePackages()
           
protected  void writeDeepRetrieval(java.io.FileWriter outFile, JClass currentClass, java.util.Vector allFields)
           
protected  void writeFactoryHeader(java.io.FileWriter factoryOutFile, JClass currentClass)
           
protected  void writeFactoryMethods(java.io.FileWriter factoryOutFile, JClass currentClass, java.util.Vector allFields)
           
protected  int writeInsertMethod(java.io.FileWriter factoryOutFile, JClass currentClass, java.util.Vector allFields)
           
protected  void writeMakeFromRs(java.io.FileWriter outFile, JClass currentClass, java.util.Vector allFields)
           
protected  void writeManyToManyMethods(java.io.FileWriter outFile, JClass currentClass, java.util.Vector allFields)
           
protected  void writeOutAField(java.io.FileWriter outFile, JField jf)
           
protected  java.lang.String writeOutAField(JField jf)
           
protected  java.lang.String writeOutAField(JField jf, java.lang.String fieldType, java.lang.String colName)
           
protected  java.lang.String writeOutAField(JField jf, java.lang.String fieldType, java.lang.String colName, java.lang.String varName)
           
protected  java.lang.String writeOutAField(JField jf, java.lang.String fieldType, java.lang.String colName, java.lang.String varName, java.lang.String stype)
           
protected  void writeProcs(java.io.FileWriter outFile, JClass currentClass, java.util.Vector allFields)
          write procs
protected  void writeQueryBasedFactoryMethods(java.io.FileWriter outFile, JClass currentClass)
           
protected  void writeSetArgForPK(java.io.FileWriter factoryOutFile, java.lang.String varName, java.lang.String get_set_name)
           
protected  void writeStoreAndDeleteMethods(java.io.FileWriter outFile, JClass currentClass, java.util.Vector allFields)
          routine which writes store, getByOid and delete
protected  void writeViewCode(java.io.FileWriter outFile, JClass currentClass, java.util.Vector allFields)
           
protected  void writeViewString(JView view, JClass currentClass, java.io.FileWriter outFile)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

END_DATE

java.lang.String END_DATE

constructorString

java.lang.String constructorString

VERSION_NUMBER

public static final java.lang.String VERSION_NUMBER
See Also:
Constant Field Values

nativeClassSet

static java.util.HashSet nativeClassSet

nativeSetTypes

static java.util.HashMap nativeSetTypes

typeMap

protected java.util.HashMap typeMap
Constructor Detail

GenericFactoryGenerator

public GenericFactoryGenerator(java.lang.String outdir,
                               char file_sep,
                               java.lang.String imp,
                               boolean useProcs)
make a new generator with a base directory of outdir so for foo.bar.FooBar if outdir = /home/dknull and file_sep = '/' then a class /home/dknull/foo/bar/AbstractFooBarFactory.java is created

Parameters:
outdir - the base directory for writing files
file_sep - the file seperator ('/' for unix/linux , '\\' for Windows)
Method Detail

generate

public void generate(JClass currentClass)
              throws java.io.IOException,
                     SchemaException
java.io.IOException
SchemaException

getPrimaryKeyString

public abstract java.lang.String getPrimaryKeyString(JClass currentClass)
methods which should be implemented by descendant generator


writeSetArgForPK

protected void writeSetArgForPK(java.io.FileWriter factoryOutFile,
                                java.lang.String varName,
                                java.lang.String get_set_name)
                         throws java.io.IOException
java.io.IOException

writeFactoryMethods

protected void writeFactoryMethods(java.io.FileWriter factoryOutFile,
                                   JClass currentClass,
                                   java.util.Vector allFields)
                            throws java.io.IOException,
                                   SchemaException
java.io.IOException
SchemaException

writeQueryBasedFactoryMethods

protected void writeQueryBasedFactoryMethods(java.io.FileWriter outFile,
                                             JClass currentClass)
                                      throws java.io.IOException
java.io.IOException

writeDeepRetrieval

protected void writeDeepRetrieval(java.io.FileWriter outFile,
                                  JClass currentClass,
                                  java.util.Vector allFields)
                           throws java.io.IOException,
                                  SchemaException
java.io.IOException
SchemaException

writeStoreAndDeleteMethods

protected void writeStoreAndDeleteMethods(java.io.FileWriter outFile,
                                          JClass currentClass,
                                          java.util.Vector allFields)
                                   throws java.io.IOException,
                                          SchemaException
routine which writes store, getByOid and delete

java.io.IOException
SchemaException

usePackages

protected boolean usePackages()

writeProcs

protected void writeProcs(java.io.FileWriter outFile,
                          JClass currentClass,
                          java.util.Vector allFields)
                   throws java.io.IOException,
                          SchemaException
write procs

java.io.IOException
SchemaException

writeMakeFromRs

protected void writeMakeFromRs(java.io.FileWriter outFile,
                               JClass currentClass,
                               java.util.Vector allFields)
                        throws java.io.IOException,
                               SchemaException
java.io.IOException
SchemaException

writeOutAField

protected void writeOutAField(java.io.FileWriter outFile,
                              JField jf)
                       throws java.io.IOException,
                              SchemaException
java.io.IOException
SchemaException

writeOutAField

protected java.lang.String writeOutAField(JField jf)
                                   throws java.io.IOException,
                                          SchemaException
java.io.IOException
SchemaException

writeOutAField

protected java.lang.String writeOutAField(JField jf,
                                          java.lang.String fieldType,
                                          java.lang.String colName)
                                   throws java.io.IOException,
                                          SchemaException
java.io.IOException
SchemaException

writeOutAField

protected java.lang.String writeOutAField(JField jf,
                                          java.lang.String fieldType,
                                          java.lang.String colName,
                                          java.lang.String varName)
                                   throws java.io.IOException,
                                          SchemaException
java.io.IOException
SchemaException

writeOutAField

protected java.lang.String writeOutAField(JField jf,
                                          java.lang.String fieldType,
                                          java.lang.String colName,
                                          java.lang.String varName,
                                          java.lang.String stype)
                                   throws java.io.IOException,
                                          SchemaException
java.io.IOException
SchemaException

writeInsertMethod

protected int writeInsertMethod(java.io.FileWriter factoryOutFile,
                                JClass currentClass,
                                java.util.Vector allFields)
                         throws java.io.IOException,
                                SchemaException
java.io.IOException
SchemaException

createClobString

protected java.lang.String createClobString()

setPKInInsertStmt

protected boolean setPKInInsertStmt()
override to false if auto increment is turned on..


writeFactoryHeader

protected void writeFactoryHeader(java.io.FileWriter factoryOutFile,
                                  JClass currentClass)
                           throws java.io.IOException,
                                  SchemaException
java.io.IOException
SchemaException

writeViewCode

protected void writeViewCode(java.io.FileWriter outFile,
                             JClass currentClass,
                             java.util.Vector allFields)
                      throws java.io.IOException,
                             SchemaException
java.io.IOException
SchemaException

writeViewString

protected void writeViewString(JView view,
                               JClass currentClass,
                               java.io.FileWriter outFile)
                        throws java.io.IOException,
                               SchemaException
java.io.IOException
SchemaException

writeManyToManyMethods

protected void writeManyToManyMethods(java.io.FileWriter outFile,
                                      JClass currentClass,
                                      java.util.Vector allFields)
                               throws java.io.IOException,
                                      SchemaException
java.io.IOException
SchemaException

getTypeMap

public java.util.HashMap getTypeMap()

createTypeMap

protected void createTypeMap()