Top Description Fields Constructors Methods
org.eclipse.persistence.sessions.factories

public Class ProjectClassGenerator

extends Object
Class Inheritance
Imports
java.io.FileOutputStream, .IOException, .OutputStreamWriter, .StringWriter, .Writer, java.util.ArrayList, .Calendar, .Enumeration, .Hashtable, .Iterator, .List, .Map, .Vector, org.eclipse.persistence.descriptors.CMPPolicy, .CachePolicy, .ClassDescriptor, .DescriptorQueryManager, .InheritancePolicy, .InterfacePolicy, .RelationalDescriptor, .ReturningPolicy, .SelectedFieldsLockingPolicy, .TimestampLockingPolicy, .VersionLockingPolicy, org.eclipse.persistence.descriptors.copying.CloneCopyPolicy, org.eclipse.persistence.descriptors.invalidation.CacheInvalidationPolicy, .DailyCacheInvalidationPolicy, .NoExpiryCacheInvalidationPolicy, .TimeToLiveCacheInvalidationPolicy, org.eclipse.persistence.eis.EISLogin, org.eclipse.persistence.eis.interactions.XMLInteraction, org.eclipse.persistence.exceptions.ValidationException, org.eclipse.persistence.expressions.Expression, .ExpressionOperator, org.eclipse.persistence.history.HistoryPolicy, org.eclipse.persistence.indirection.IndirectMap, org.eclipse.persistence.internal.codegen.ClassDefinition, .CodeGenerator, .NonreflectiveMethodDefinition, org.eclipse.persistence.internal.descriptors.FieldTransformation, .MethodBasedFieldTransformation, .OptimisticLockingPolicy, .TransformerBasedFieldTransformation, org.eclipse.persistence.internal.expressions.ExpressionJavaPrinter, .FunctionExpression, org.eclipse.persistence.internal.helper.DatabaseField, .DatabaseTable, .DescriptorCompare, .Helper, org.eclipse.persistence.internal.indirection.BasicIndirectionPolicy, .ContainerIndirectionPolicy, .IndirectionPolicy, .NoIndirectionPolicy, .ProxyIndirectionPolicy, .TransparentIndirectionPolicy, org.eclipse.persistence.internal.queries.ReportItem, org.eclipse.persistence.internal.sessions.factories.DirectToXMLTypeMappingHelper, org.eclipse.persistence.mappings.AggregateCollectionMapping, .AggregateObjectMapping, .CollectionMapping, .DatabaseMapping, .DirectCollectionMapping, .DirectMapMapping, .DirectToFieldMapping, .ForeignReferenceMapping, .ManyToManyMapping, .OneToManyMapping, .OneToOneMapping, .TransformationMapping, .VariableOneToOneMapping, org.eclipse.persistence.mappings.converters.Converter, .ObjectTypeConverter, .SerializedObjectConverter, .TypeConversionConverter, org.eclipse.persistence.mappings.foundation.AbstractDirectMapping, org.eclipse.persistence.mappings.querykeys.DirectQueryKey, .QueryKey, org.eclipse.persistence.queries.DatabaseQuery, .FetchGroup, .InMemoryQueryIndirectionPolicy, .MethodBaseQueryRedirector, .ObjectLevelReadQuery, .ReadAllQuery, .ReadQuery, .ReportQuery, org.eclipse.persistence.sequencing.Sequence, .TableSequence, .UnaryTableSequence, org.eclipse.persistence.sessions.DatabaseLogin, .DatasourceLogin, .Login, .Project

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

Modifier and TypeField and Description
protected String
protected Hashtable<ClassDescriptor, String>
protected String
protected String
protected Writer
protected String
protected Project

Constructor Summary

AccessConstructor and Description
public
ProjectClassGenerator()

PUBLIC: Create a new generator.

public
ProjectClassGenerator(Project project)

PUBLIC: Create a new generator to output the project.

public
ProjectClassGenerator(Project project, String projectClassName, Writer outputWriter)

PUBLIC: Create a new generator to output to the writer.

public
ProjectClassGenerator(Project project, String projectClassName, String fileName)

PUBLIC: Create a new generator to output to the file.

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
addFetchGroupLines(NonreflectiveMethodDefinition method, FetchGroup fetchGroup, String fetchGroupIdentifier)

protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected String
buildBuilderString(String builderString, NonreflectiveMethodDefinition method, int iteration, String queryIdentifier)

protected NonreflectiveMethodDefinition
protected NonreflectiveMethodDefinition
protected void
buildExpressionString(String builderString, NonreflectiveMethodDefinition method, String queryIdentifier, Expression exp, String attrString)

protected NonreflectiveMethodDefinition
buildLoginMethod(Login datasourceLogin)

private List<ClassDescriptor>
buildSortedListOfDescriptors(List<ClassDescriptor> descriptors)

Take an unsorted list of descriptors and sort it so that the order is maintained.

protected void
computeDescriptorMethodNames()

This figures out the best name for each descriptor, first using the local class name then the qualified one for duplicates.

private String
public void
generate(boolean useUnicode)

PUBLIC: Generate the project class, output the java source code to the stream or file.

public void
generate()

PUBLIC: Generate the project class, output the java source code to the stream or file.

protected ClassDefinition
generateProjectClass()

Return a class definition object representing the code to be generated for the project and its descriptors.

public String
getClassName()

PUBLIC: Return the name of class to be generated.

protected Hashtable<ClassDescriptor, String>
public String
getOutputFileName()

PUBLIC: Return the file name that the generate .java file will be output to.

public String
getOutputPath()

PUBLIC: Return the path that the generate .java file will be output to.

public Writer
getOutputWriter()

PUBLIC: Return the writer the output to.

public String
getPackageName()

PUBLIC: Return the package name of class to be generated.

public Project
getProject()

PUBLIC: Return the project to generate from.

protected String
printString(Object value)

Return the printed version of the primitive value object.

protected String
removeDots(String packageName)

public void
setClassName(String newClassName)

PUBLIC: Set the name of class to be generated.

protected String
setDefaultOrAddSequenceString(Sequence sequence, boolean isSetDefault)

protected void
public void
setOutputFileName(String newOutputFileName)

PUBLIC: Set the file name that the generate .java file will be output to.

public void
setOutputPath(String newOutputPath)

PUBLIC: Set the path that the generate .java file will be output to.

public void
setOutputWriter(Writer outputWriter)

PUBLIC: Set the writer the output to.

public void
setPackageName(String newPackageName)

PUBLIC: Set the package name of class to be generated.

public void
setProject(Project newProject)

PUBLIC: Set the project to generate from.

protected Vector<DatabaseMapping>
sortMappings(Vector<DatabaseMapping> mappings)

Short the mappings by type.

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.

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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classNameback to summary
protected String className
descriptorMethodNamesback to summary
protected Hashtable<ClassDescriptor, String> descriptorMethodNames
outputFileNameback to summary
protected String outputFileName
outputPathback to summary
protected String outputPath
outputWriterback to summary
protected Writer outputWriter
packageNameback to summary
protected String packageName
projectback to summary
protected Project project

Constructor Detail

ProjectClassGeneratorback to summary
public ProjectClassGenerator()

PUBLIC: Create a new generator.

ProjectClassGeneratorback to summary
public ProjectClassGenerator(Project project)

PUBLIC: Create a new generator to output the project.

ProjectClassGeneratorback to summary
public ProjectClassGenerator(Project project, String projectClassName, Writer outputWriter)

PUBLIC: Create a new generator to output to the writer.

ProjectClassGeneratorback to summary
public ProjectClassGenerator(Project project, String projectClassName, String fileName)

PUBLIC: Create a new generator to output to the file.

Method Detail

addAggregateCollectionMappingLinesback to summary
protected void addAggregateCollectionMappingLines(NonreflectiveMethodDefinition method, String mappingName, AggregateCollectionMapping mapping)
addAggregateObjectMappingLinesback to summary
protected void addAggregateObjectMappingLines(NonreflectiveMethodDefinition method, String mappingName, AggregateObjectMapping mapping)
addCacheInvalidationPolicyLinesback to summary
protected void addCacheInvalidationPolicyLines(NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
addCMPPolicyLinesback to summary
protected void addCMPPolicyLines(NonreflectiveMethodDefinition method, CMPPolicy sourceCMPPolicy)
addConverterLinesback to summary
protected void addConverterLines(NonreflectiveMethodDefinition method, String converterName, Converter converter)
addDescriptorPropertyLinesback to summary
protected void addDescriptorPropertyLines(NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
addDirectCollectionMappingLinesback to summary
protected void addDirectCollectionMappingLines(NonreflectiveMethodDefinition method, String mappingName, DirectCollectionMapping mapping)
addDirectMapMappingLinesback to summary
protected void addDirectMapMappingLines(NonreflectiveMethodDefinition method, String mappingName, DirectMapMapping mapping)
addEventManagerPropertyLinesback to summary
protected void addEventManagerPropertyLines(NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
addFetchGroupLinesback to summary
protected void addFetchGroupLines(NonreflectiveMethodDefinition method, FetchGroup fetchGroup, String fetchGroupIdentifier)
addFetchGroupManagerLineback to summary
protected void addFetchGroupManagerLine(NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
addForeignReferenceMappingLinesback to summary
protected void addForeignReferenceMappingLines(NonreflectiveMethodDefinition method, String mappingName, ForeignReferenceMapping mapping)
addHistoryPolicyLinesback to summary
protected void addHistoryPolicyLines(NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
addHistoryPolicyLinesback to summary
protected void addHistoryPolicyLines(NonreflectiveMethodDefinition method, DirectCollectionMapping mapping, String mappingName)
addHistoryPolicyLinesback to summary
protected void addHistoryPolicyLines(NonreflectiveMethodDefinition method, ManyToManyMapping mapping, String mappingName)
addHistoryPolicyLinesback to summary
protected void addHistoryPolicyLines(NonreflectiveMethodDefinition method, HistoryPolicy policy, String policyName)
addInheritanceLinesback to summary
protected void addInheritanceLines(NonreflectiveMethodDefinition method, InheritancePolicy policy)
addInterfaceLinesback to summary
protected void addInterfaceLines(NonreflectiveMethodDefinition method, InterfacePolicy policy)
addManyToManyMappingLinesback to summary
protected void addManyToManyMappingLines(NonreflectiveMethodDefinition method, String mappingName, ManyToManyMapping mapping)
addMappingLinesback to summary
protected void addMappingLines(NonreflectiveMethodDefinition method, DatabaseMapping mapping)
addNamedQueryLinesback to summary
protected void addNamedQueryLines(NonreflectiveMethodDefinition method, DatabaseQuery query, DescriptorQueryManager queryManager, int iteration)
addObjectTypeConverterLinesback to summary
protected void addObjectTypeConverterLines(NonreflectiveMethodDefinition method, String converterName, ObjectTypeConverter converter)
addOneToManyMappingLinesback to summary
protected void addOneToManyMappingLines(NonreflectiveMethodDefinition method, String mappingName, OneToManyMapping mapping)
addOneToOneMappingLinesback to summary
protected void addOneToOneMappingLines(NonreflectiveMethodDefinition method, String mappingName, OneToOneMapping mapping)
addOptimisticLockingLinesback to summary
protected void addOptimisticLockingLines(NonreflectiveMethodDefinition method, OptimisticLockingPolicy policy)
addQueryKeyLinesback to summary
protected void addQueryKeyLines(NonreflectiveMethodDefinition method, QueryKey queryKey)
addQueryManagerPropertyLinesback to summary
protected void addQueryManagerPropertyLines(NonreflectiveMethodDefinition method, ClassDescriptor descriptor)
addReturningPolicyLinesback to summary
protected void addReturningPolicyLines(NonreflectiveMethodDefinition method, ReturningPolicy policy)
addReturningPolicyLinesback to summary
protected void addReturningPolicyLines(NonreflectiveMethodDefinition method, ReturningPolicy policy, String policyName)
addTransformationMappingLinesback to summary
protected void addTransformationMappingLines(NonreflectiveMethodDefinition method, String mappingName, TransformationMapping mapping)
addTypeConversionConverterLinesback to summary
protected void addTypeConversionConverterLines(NonreflectiveMethodDefinition method, String converterName, TypeConversionConverter converter)
addVariableOneToOneMappingLinesback to summary
protected void addVariableOneToOneMappingLines(NonreflectiveMethodDefinition method, String mappingName, VariableOneToOneMapping mapping)
addXMLInteractionLinesback to summary
protected void addXMLInteractionLines(NonreflectiveMethodDefinition method, XMLInteraction interaction, String variableName)
buildBuilderStringback to summary
protected String buildBuilderString(String builderString, NonreflectiveMethodDefinition method, int iteration, String queryIdentifier)
buildConstructorback to summary
protected NonreflectiveMethodDefinition buildConstructor()
buildDescriptorMethodback to summary
protected NonreflectiveMethodDefinition buildDescriptorMethod(ClassDescriptor descriptor)
buildExpressionStringback to summary
protected void buildExpressionString(String builderString, NonreflectiveMethodDefinition method, String queryIdentifier, Expression exp, String attrString)
buildLoginMethodback to summary
protected NonreflectiveMethodDefinition buildLoginMethod(Login datasourceLogin)
buildSortedListOfDescriptorsback to summary
private List<ClassDescriptor> buildSortedListOfDescriptors(List<ClassDescriptor> descriptors)

Take an unsorted list of descriptors and sort it so that the order is maintained.

computeDescriptorMethodNamesback to summary
protected void computeDescriptorMethodNames()

This figures out the best name for each descriptor, first using the local class name then the qualified one for duplicates.

constructValidSQLorEJBQLLinesForJavaSourceback to summary
private String constructValidSQLorEJBQLLinesForJavaSource(String qlString)
generateback to summary
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.

generateback to summary
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.

generateProjectClassback to summary
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.

getClassNameback to summary
public String getClassName()

PUBLIC: Return the name of class to be generated. This is the unqualified name.

getDescriptorMethodNamesback to summary
protected Hashtable<ClassDescriptor, String> getDescriptorMethodNames()
getOutputFileNameback to summary
public String getOutputFileName()

PUBLIC: Return the file name that the generate .java file will be output to.

getOutputPathback to summary
public String getOutputPath()

PUBLIC: Return the path that the generate .java file will be output to.

getOutputWriterback to summary
public Writer getOutputWriter()

PUBLIC: Return the writer the output to.

getPackageNameback to summary
public String getPackageName()

PUBLIC: Return the package name of class to be generated.

getProjectback to summary
public Project getProject()

PUBLIC: Return the project to generate from.

printStringback to summary
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.

removeDotsback to summary
protected String removeDots(String packageName)
setClassNameback to summary
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.

setDefaultOrAddSequenceStringback to summary
protected String setDefaultOrAddSequenceString(Sequence sequence, boolean isSetDefault)
setDescriptorMethodNamesback to summary
protected void setDescriptorMethodNames(Hashtable<ClassDescriptor, String> descriptorMethodNames)
setOutputFileNameback to summary
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.

setOutputPathback to summary
public void setOutputPath(String newOutputPath)

PUBLIC: Set the path that the generate .java file will be output to.

setOutputWriterback to summary
public void setOutputWriter(Writer outputWriter)

PUBLIC: Set the writer the output to.

setPackageNameback to summary
public void setPackageName(String newPackageName)

PUBLIC: Set the package name of class to be generated.

setProjectback to summary
public void setProject(Project newProject)

PUBLIC: Set the project to generate from. All of the projects descriptors will be stored into the file.

sortMappingsback to summary
protected Vector<DatabaseMapping> sortMappings(Vector<DatabaseMapping> mappings)

Short the mappings by type.

writeback to summary
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.

writeback to summary
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.