Class ProjectClassGenerator

java.lang.Object
org.eclipse.persistence.sessions.factories.ProjectClassGenerator

public class ProjectClassGenerator extends 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.

Author:
James Sutherland
  • Field Details

    • className

      protected String className
    • packageName

      protected String packageName
    • outputPath

      protected String outputPath
    • outputFileName

      protected String outputFileName
    • outputWriter

      protected Writer outputWriter
    • project

      protected Project project
    • descriptorMethodNames

      protected Hashtable descriptorMethodNames
  • Constructor Details

    • 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, String projectClassName, Writer outputWriter)
      PUBLIC: Create a new generator to output to the writer.
    • ProjectClassGenerator

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

    • addAggregateCollectionMappingLines

      protected void addAggregateCollectionMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, String mappingName, AggregateCollectionMapping mapping)
    • addAggregateObjectMappingLines

      protected void addAggregateObjectMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, String mappingName, AggregateObjectMapping mapping)
    • addCacheInvalidationPolicyLines

      protected void addCacheInvalidationPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
    • addCMPPolicyLines

      protected void addCMPPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, CMPPolicy sourceCMPPolicy)
    • addDescriptorPropertyLines

      protected void addDescriptorPropertyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
    • addDirectCollectionMappingLines

      protected void addDirectCollectionMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, String mappingName, DirectCollectionMapping mapping)
    • addDirectMapMappingLines

      protected void addDirectMapMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, String mappingName, DirectMapMapping mapping)
    • addFetchGroupManagerLine

      protected void addFetchGroupManagerLine(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
    • addFetchGroupLines

      protected void addFetchGroupLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, FetchGroup fetchGroup, String fetchGroupIdentifier)
    • addEventManagerPropertyLines

      protected void addEventManagerPropertyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
    • addForeignReferenceMappingLines

      protected void addForeignReferenceMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, String mappingName, ForeignReferenceMapping mapping)
    • addHistoryPolicyLines

      protected void addHistoryPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
    • addHistoryPolicyLines

      protected void addHistoryPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, DirectCollectionMapping mapping, String mappingName)
    • addHistoryPolicyLines

      protected void addHistoryPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ManyToManyMapping mapping, String mappingName)
    • addHistoryPolicyLines

      protected void addHistoryPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, HistoryPolicy policy, String policyName)
    • addInheritanceLines

      protected void addInheritanceLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, InheritancePolicy policy)
    • addInterfaceLines

      protected void addInterfaceLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, InterfacePolicy policy)
    • addManyToManyMappingLines

      protected void addManyToManyMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, String mappingName, ManyToManyMapping mapping)
    • addMappingLines

      protected void addMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, DatabaseMapping mapping)
    • addObjectTypeConverterLines

      protected void addObjectTypeConverterLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, String converterName, ObjectTypeConverter converter)
    • addOneToManyMappingLines

      protected void addOneToManyMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, String mappingName, OneToManyMapping mapping)
    • addOneToOneMappingLines

      protected void addOneToOneMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, String mappingName, OneToOneMapping mapping)
    • addOptimisticLockingLines

      protected void addOptimisticLockingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy policy)
    • addQueryKeyLines

      protected void addQueryKeyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, QueryKey queryKey)
    • addQueryManagerPropertyLines

      protected void addQueryManagerPropertyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
    • addXMLInteractionLines

      protected void addXMLInteractionLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, XMLInteraction interaction, String variableName)
    • addNamedQueryLines

      protected void addNamedQueryLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, DatabaseQuery query, DescriptorQueryManager queryManager, int iteration)
    • buildBuilderString

      protected String buildBuilderString(String builderString, org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, int iteration, String queryIdentifier)
    • buildExpressionString

      protected void buildExpressionString(String builderString, org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, String queryIdentifier, Expression exp, String attrString)
    • addReturningPolicyLines

      protected void addReturningPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ReturningPolicy policy)
    • addReturningPolicyLines

      protected void addReturningPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ReturningPolicy policy, String policyName)
    • addTransformationMappingLines

      protected void addTransformationMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, String mappingName, TransformationMapping mapping)
    • addConverterLines

      protected void addConverterLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, String converterName, Converter converter)
    • addTypeConversionConverterLines

      protected void addTypeConversionConverterLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, String converterName, TypeConversionConverter converter)
    • addVariableOneToOneMappingLines

      protected void addVariableOneToOneMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, String mappingName, VariableOneToOneMapping mapping)
    • buildConstructor

      protected org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition buildConstructor()
    • buildDescriptorMethod

      protected org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition buildDescriptorMethod(ClassDescriptor descriptor)
    • buildLoginMethod

      protected org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition buildLoginMethod(Login datasourceLogin)
    • setDefaultOrAddSequenceString

      protected 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 org.eclipse.persistence.internal.codegen.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 String getClassName()
      PUBLIC: Return the name of class to be generated. This is the unqualified name.
    • getDescriptorMethodNames

      protected Hashtable getDescriptorMethodNames()
    • getOutputFileName

      public String getOutputFileName()
      PUBLIC: Return the file name that the generate .java file will be output to.
    • getOutputPath

      public String getOutputPath()
      PUBLIC: Return the path that the generate .java file will be output to.
    • getOutputWriter

      public Writer getOutputWriter()
      PUBLIC: Return the writer the output to.
    • getPackageName

      public 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 String printString(Object value)
      Return the printed version of the primitive value object. This must determine the class and use the correct constructor arguments.
    • removeDots

      protected String removeDots(String packageName)
    • setClassName

      public void setClassName(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(Hashtable descriptorMethodNames)
    • setOutputFileName

      public void setOutputFileName(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(String newOutputPath)
      PUBLIC: Set the path that the generate .java file will be output to.
    • setOutputWriter

      public void setOutputWriter(Writer outputWriter)
      PUBLIC: Set the writer the output to.
    • setPackageName

      public void setPackageName(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 Vector sortMappings(Vector mappings)
      Short the mappings by type.
    • write

      public static void write(Project project, String projectClassName, 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, String projectClassName, String fileName)
      PUBLIC: Generate the source code to a project class to the project's descriptor into the file.