Class ProjectClassGenerator


  • public class ProjectClassGenerator
    extends java.lang.Object

    Purpose: Allow for a class storing a TopLink project's descriptors (meta-data) to be generated. This class can then be used at runtime to deploy the TopLink descriptor's instead of XML files.

    Since:
    TopLink 3.0
    Author:
    James Sutherland
    • 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
      • project

        protected Project project
      • descriptorMethodNames

        protected java.util.Hashtable descriptorMethodNames
    • Constructor Detail

      • ProjectClassGenerator

        public ProjectClassGenerator()
        PUBLIC: Create a new generator.
      • ProjectClassGenerator

        public ProjectClassGenerator​(Project project)
        PUBLIC: Create a new generator to output the project.
      • ProjectClassGenerator

        public ProjectClassGenerator​(Project project,
                                     java.lang.String projectClassName,
                                     java.io.Writer outputWriter)
        PUBLIC: Create a new generator to output to the writer.
      • ProjectClassGenerator

        public ProjectClassGenerator​(Project project,
                                     java.lang.String projectClassName,
                                     java.lang.String fileName)
        PUBLIC: Create a new generator to output to the file.
    • Method Detail

      • buildBuilderString

        protected java.lang.String buildBuilderString​(java.lang.String builderString,
                                                      NonreflectiveMethodDefinition method,
                                                      int iteration,
                                                      java.lang.String queryIdentifier)
      • buildExpressionString

        protected void buildExpressionString​(java.lang.String builderString,
                                             NonreflectiveMethodDefinition method,
                                             java.lang.String queryIdentifier,
                                             Expression exp,
                                             java.lang.String attrString)
      • setDefaultOrAddSequenceString

        protected java.lang.String setDefaultOrAddSequenceString​(Sequence sequence,
                                                                 boolean isSetDefault)
      • computeDescriptorMethodNames

        protected void computeDescriptorMethodNames()
        This figures out the best name for each descriptor, first using the local class name then the qualified one for duplicates.
      • generate

        public void generate​(boolean useUnicode)
                      throws ValidationException
        PUBLIC: Generate the project 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 ValidationException
        PUBLIC: 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
      • generateProjectClass

        protected ClassDefinition generateProjectClass()
        Return a class definition object representing the code to be generated for the project and its descriptors. 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.
      • getDescriptorMethodNames

        protected java.util.Hashtable getDescriptorMethodNames()
      • 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.
      • getProject

        public Project getProject()
        PUBLIC: Return the project 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 constructor 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.
      • setDescriptorMethodNames

        protected void setDescriptorMethodNames​(java.util.Hashtable descriptorMethodNames)
      • 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.
      • setProject

        public void setProject​(Project newProject)
        PUBLIC: Set the project to generate from. All of the projects descriptors will be stored into the file.
      • sortMappings

        protected java.util.Vector sortMappings​(java.util.Vector mappings)
        Short the mappings by type.
      • write

        public static void write​(Project project,
                                 java.lang.String projectClassName,
                                 java.io.Writer writer)
        PUBLIC: Generate the source code to a project class to the project's descriptor into the writer.
      • write

        public static void write​(Project project,
                                 java.lang.String projectClassName,
                                 java.lang.String fileName)
        PUBLIC: Generate the source code to a project class to the project's descriptor into the file.