Class TableCreatorClassGenerator
- java.lang.Object
-
- org.eclipse.persistence.sessions.factories.TableCreatorClassGenerator
-
public class TableCreatorClassGenerator extends java.lang.ObjectPurpose: Allow for a class storing a TopLink table creator's tables (meta-data) to be generated. This class can then be used at runtime to (re)create a project's database schema.
- Author:
- James Sutherland
- Since:
- TopLink 3.0
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringclassNameprotected java.lang.StringoutputFileNameprotected java.lang.StringoutputPathprotected java.io.WriteroutputWriterprotected java.lang.StringpackageNameprotected TableCreatortableCreator
-
Constructor Summary
Constructors Constructor Description TableCreatorClassGenerator()PUBLIC: Create a new generator.TableCreatorClassGenerator(TableCreator tableCreator)PUBLIC: Create a new generator to output the table creator.TableCreatorClassGenerator(TableCreator tableCreator, java.lang.String projectClassName, java.io.Writer outputWriter)PUBLIC: Create a new generator to output the table creator.TableCreatorClassGenerator(TableCreator tableCreator, java.lang.String projectClassName, java.lang.String fileName)PUBLIC: Create a new generator to output the table creator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddFieldLines(FieldDefinition field, org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method)protected voidaddForeignKeyLines(ForeignKeyConstraint foreignKey, org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method)protected org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinitionbuildConstructor()protected org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinitionbuildLoginMethod(DatabaseLogin login)protected org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinitionbuildTableMethod(TableDefinition table)voidgenerate()PUBLIC: Generate the project class, output the java source code to the stream or file.voidgenerate(boolean useUnicode)PUBLIC: Generate the creator class, output the java source code to the stream or file.protected org.eclipse.persistence.internal.codegen.ClassDefinitiongenerateCreatorClass()Return a class definition object representing the code to be generated for the table creator.java.lang.StringgetClassName()PUBLIC: Return the name of class to be generated.java.lang.StringgetOutputFileName()PUBLIC: Return the file name that the generate .java file will be output to.java.lang.StringgetOutputPath()PUBLIC: Return the path that the generate .java file will be output to.java.io.WritergetOutputWriter()PUBLIC: Return the writer the output to.java.lang.StringgetPackageName()PUBLIC: Return the package name of class to be generated.TableCreatorgetTableCreator()PUBLIC: Return the table creator to generate from.protected java.lang.StringprintString(java.lang.Object value)Return the printed version of the primitive value object.protected java.lang.StringremoveDots(java.lang.String packageName)voidsetClassName(java.lang.String newClassName)PUBLIC: Set the name of class to be generated.voidsetOutputFileName(java.lang.String newOutputFileName)PUBLIC: Set the file name that the generate .java file will be output to.voidsetOutputPath(java.lang.String newOutputPath)PUBLIC: Set the path that the generate .java file will be output to.voidsetOutputWriter(java.io.Writer outputWriter)PUBLIC: Set the writer the output to.voidsetPackageName(java.lang.String newPackageName)PUBLIC: Set the package name of class to be generated.voidsetTableCreator(TableCreator tableCreator)PUBLIC: Set the table creator to generate from.static voidwrite(TableCreator tableCreator, java.lang.String creatorClassName, java.io.Writer writer)PUBLIC: Generate the source code to a table creator class to the table creator's tables into the writer.static voidwrite(TableCreator tableCreator, java.lang.String creatorClassName, java.lang.String fileName)PUBLIC: Generate the source code to a table creator class to the table creator's tables into the file.
-
-
-
Field Detail
-
className
protected java.lang.String className
-
packageName
protected java.lang.String packageName
-
outputPath
protected java.lang.String outputPath
-
outputFileName
protected java.lang.String outputFileName
-
outputWriter
protected java.io.Writer outputWriter
-
tableCreator
protected TableCreator tableCreator
-
-
Constructor Detail
-
TableCreatorClassGenerator
public TableCreatorClassGenerator()
PUBLIC: Create a new generator.
-
TableCreatorClassGenerator
public TableCreatorClassGenerator(TableCreator tableCreator)
PUBLIC: Create a new generator to output the table creator.
-
TableCreatorClassGenerator
public TableCreatorClassGenerator(TableCreator tableCreator, java.lang.String projectClassName, java.io.Writer outputWriter)
PUBLIC: Create a new generator to output the table creator.
-
TableCreatorClassGenerator
public TableCreatorClassGenerator(TableCreator tableCreator, java.lang.String projectClassName, java.lang.String fileName)
PUBLIC: Create a new generator to output the table creator.
-
-
Method Detail
-
addFieldLines
protected void addFieldLines(FieldDefinition field, org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method)
-
addForeignKeyLines
protected void addForeignKeyLines(ForeignKeyConstraint foreignKey, org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method)
-
buildConstructor
protected org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition buildConstructor()
-
buildLoginMethod
protected org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition buildLoginMethod(DatabaseLogin login)
-
buildTableMethod
protected org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition buildTableMethod(TableDefinition table)
-
generate
public void generate(boolean useUnicode) throws ValidationExceptionPUBLIC: Generate the creator class, output the java source code to the stream or file. useUnicode determines if unicode escaped characters for non_ASCII charaters will be used.- Throws:
ValidationException
-
generate
public void generate() throws ValidationExceptionPUBLIC: Generate the project class, output the java source code to the stream or file. Unicode escaped characters for non_ASCII charaters will be used.- Throws:
ValidationException
-
generateCreatorClass
protected org.eclipse.persistence.internal.codegen.ClassDefinition generateCreatorClass()
Return a class definition object representing the code to be generated for the table creator. This class will have one method per descriptor and its toString can be used to convert it to code.
-
getClassName
public java.lang.String getClassName()
PUBLIC: Return the name of class to be generated. This is the unqualified name.
-
getOutputFileName
public java.lang.String getOutputFileName()
PUBLIC: Return the file name that the generate .java file will be output to.
-
getOutputPath
public java.lang.String getOutputPath()
PUBLIC: Return the path that the generate .java file will be output to.
-
getOutputWriter
public java.io.Writer getOutputWriter()
PUBLIC: Return the writer the output to.
-
getPackageName
public java.lang.String getPackageName()
PUBLIC: Return the package name of class to be generated.
-
getTableCreator
public TableCreator getTableCreator()
PUBLIC: Return the table creator to generate from.
-
printString
protected java.lang.String printString(java.lang.Object value)
Return the printed version of the primitive value object. This must determine the class and use the correct constrcutor arguments.
-
removeDots
protected java.lang.String removeDots(java.lang.String packageName)
-
setClassName
public void setClassName(java.lang.String newClassName)
PUBLIC: Set the name of class to be generated. This can be qualified or unqualified name and will set the file name to match.
-
setOutputFileName
public void setOutputFileName(java.lang.String newOutputFileName)
PUBLIC: Set the file name that the generate .java file will be output to. If the file does not include .java it will be appended.
-
setOutputPath
public void setOutputPath(java.lang.String newOutputPath)
PUBLIC: Set the path that the generate .java file will be output to.
-
setOutputWriter
public void setOutputWriter(java.io.Writer outputWriter)
PUBLIC: Set the writer the output to.
-
setPackageName
public void setPackageName(java.lang.String newPackageName)
PUBLIC: Set the package name of class to be generated.
-
setTableCreator
public void setTableCreator(TableCreator tableCreator)
PUBLIC: Set the table creator to generate from. All of the creator's tables will be stored into the file.
-
write
public static void write(TableCreator tableCreator, java.lang.String creatorClassName, java.io.Writer writer)
PUBLIC: Generate the source code to a table creator class to the table creator's tables into the writer.
-
write
public static void write(TableCreator tableCreator, java.lang.String creatorClassName, java.lang.String fileName)
PUBLIC: Generate the source code to a table creator class to the table creator's tables into the file.
-
-