EclipseLink 1.1.4, build 'v20100812-r7860' API Reference

org.eclipse.persistence.sessions.factories
Class ProjectClassGenerator

java.lang.Object
  extended by org.eclipse.persistence.sessions.factories.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.

Author:
James Sutherland
Since:
TopLink 3.0

Field Summary
protected  java.lang.String className
           
protected  java.util.Hashtable descriptorMethodNames
           
protected  java.lang.String outputFileName
           
protected  java.lang.String outputPath
           
protected  java.io.Writer outputWriter
           
protected  java.lang.String packageName
           
protected  Project project
           
 
Constructor Summary
ProjectClassGenerator()
          PUBLIC: Create a new generator.
ProjectClassGenerator(Project project)
          PUBLIC: Create a new generator to output the project.
ProjectClassGenerator(Project project, java.lang.String projectClassName, java.lang.String fileName)
          PUBLIC: Create a new generator to output to the file.
ProjectClassGenerator(Project project, java.lang.String projectClassName, java.io.Writer outputWriter)
          PUBLIC: Create a new generator to output to the writer.
 
Method Summary
protected  void addAggregateCollectionMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, java.lang.String mappingName, AggregateCollectionMapping mapping)
           
protected  void addAggregateObjectMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, java.lang.String mappingName, AggregateObjectMapping mapping)
           
protected  void addCacheInvalidationPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
           
protected  void addCMPPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, CMPPolicy sourceCMPPolicy)
           
protected  void addConverterLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, java.lang.String converterName, Converter converter)
           
protected  void addDescriptorPropertyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
           
protected  void addDirectCollectionMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, java.lang.String mappingName, DirectCollectionMapping mapping)
           
protected  void addDirectMapMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, java.lang.String mappingName, DirectMapMapping mapping)
           
protected  void addEventManagerPropertyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
           
protected  void addFetchGroupLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, FetchGroup fetchGroup, java.lang.String fetchGroupIdentifier)
           
protected  void addFetchGroupManagerLine(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
           
protected  void addForeignReferenceMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, java.lang.String mappingName, ForeignReferenceMapping mapping)
           
protected  void addHistoryPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
           
protected  void addHistoryPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, DirectCollectionMapping mapping, java.lang.String mappingName)
           
protected  void addHistoryPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, HistoryPolicy policy, java.lang.String policyName)
           
protected  void addHistoryPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ManyToManyMapping mapping, java.lang.String mappingName)
           
protected  void addInheritanceLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, InheritancePolicy policy)
           
protected  void addInterfaceLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, InterfacePolicy policy)
           
protected  void addManyToManyMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, java.lang.String mappingName, ManyToManyMapping mapping)
           
protected  void addMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, DatabaseMapping mapping)
           
protected  void addNamedQueryLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, DatabaseQuery query, DescriptorQueryManager queryManager, int iteration)
           
protected  void addObjectTypeConverterLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, java.lang.String converterName, ObjectTypeConverter converter)
           
protected  void addOneToManyMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, java.lang.String mappingName, OneToManyMapping mapping)
           
protected  void addOneToOneMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, java.lang.String mappingName, OneToOneMapping mapping)
           
protected  void addOptimisticLockingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy policy)
           
protected  void addQueryKeyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, QueryKey queryKey)
           
protected  void addQueryManagerPropertyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
           
protected  void addReturningPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ReturningPolicy policy)
           
protected  void addReturningPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, ReturningPolicy policy, java.lang.String policyName)
           
protected  void addTransformationMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, java.lang.String mappingName, TransformationMapping mapping)
           
protected  void addTypeConversionConverterLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, java.lang.String converterName, TypeConversionConverter converter)
           
protected  void addVariableOneToOneMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, java.lang.String mappingName, VariableOneToOneMapping mapping)
           
protected  void addXMLInteractionLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, XMLInteraction interaction, java.lang.String variableName)
           
protected  java.lang.String buildBuilderString(java.lang.String builderString, org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, int iteration, java.lang.String queryIdentifier)
           
protected  org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition buildConstructor()
           
protected  org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition buildDescriptorMethod(ClassDescriptor descriptor)
           
protected  void buildExpressionString(java.lang.String builderString, org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method, java.lang.String queryIdentifier, Expression exp, java.lang.String attrString)
           
protected  org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition buildLoginMethod(Login datasourceLogin)
           
protected  void computeDescriptorMethodNames()
          This figures out the best name for each descriptor, first using the local class name then the qualified one for duplicates.
 void generate()
          PUBLIC: Generate the project class, output the java source code to the stream or file.
 void generate(boolean useUnicode)
          PUBLIC: Generate the project class, output the java source code to the stream or file.
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.
 java.lang.String getClassName()
          PUBLIC: Return the name of class to be generated.
protected  java.util.Hashtable getDescriptorMethodNames()
           
 java.lang.String getOutputFileName()
          PUBLIC: Return the file name that the generate .java file will be output to.
 java.lang.String getOutputPath()
          PUBLIC: Return the path that the generate .java file will be output to.
 java.io.Writer getOutputWriter()
          PUBLIC: Return the writer the output to.
 java.lang.String getPackageName()
          PUBLIC: Return the package name of class to be generated.
 Project getProject()
          PUBLIC: Return the project to generate from.
protected  java.lang.String printString(java.lang.Object value)
          Return the printed version of the primitive value object.
protected  java.lang.String removeDots(java.lang.String packageName)
           
 void setClassName(java.lang.String newClassName)
          PUBLIC: Set the name of class to be generated.
protected  java.lang.String setDefaultOrAddSequenceString(Sequence sequence, boolean isSetDefault)
           
protected  void setDescriptorMethodNames(java.util.Hashtable descriptorMethodNames)
           
 void setOutputFileName(java.lang.String newOutputFileName)
          PUBLIC: Set the file name that the generate .java file will be output to.
 void setOutputPath(java.lang.String newOutputPath)
          PUBLIC: Set the path that the generate .java file will be output to.
 void setOutputWriter(java.io.Writer outputWriter)
          PUBLIC: Set the writer the output to.
 void setPackageName(java.lang.String newPackageName)
          PUBLIC: Set the package name of class to be generated.
 void setProject(Project newProject)
          PUBLIC: Set the project to generate from.
protected  java.util.Vector sortMappings(java.util.Vector mappings)
          Short the mappings by type.
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.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

addAggregateCollectionMappingLines

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

addAggregateObjectMappingLines

protected void addAggregateObjectMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method,
                                              java.lang.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,
                                               java.lang.String mappingName,
                                               DirectCollectionMapping mapping)

addDirectMapMappingLines

protected void addDirectMapMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method,
                                        java.lang.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,
                                  java.lang.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,
                                               java.lang.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,
                                     java.lang.String mappingName)

addHistoryPolicyLines

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

addHistoryPolicyLines

protected void addHistoryPolicyLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method,
                                     HistoryPolicy policy,
                                     java.lang.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,
                                         java.lang.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,
                                           java.lang.String converterName,
                                           ObjectTypeConverter converter)

addOneToManyMappingLines

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

addOneToOneMappingLines

protected void addOneToOneMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method,
                                       java.lang.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,
                                      java.lang.String variableName)

addNamedQueryLines

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

buildBuilderString

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

buildExpressionString

protected void buildExpressionString(java.lang.String builderString,
                                     org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method,
                                     java.lang.String queryIdentifier,
                                     Expression exp,
                                     java.lang.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,
                                       java.lang.String policyName)

addTransformationMappingLines

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

addConverterLines

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

addTypeConversionConverterLines

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

addVariableOneToOneMappingLines

protected void addVariableOneToOneMappingLines(org.eclipse.persistence.internal.codegen.NonreflectiveMethodDefinition method,
                                               java.lang.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 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 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 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 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.


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.


EclipseLink 1.1.4, build 'v20100812-r7860' API Reference