org.eclipse.ocl.examples.codegen.java
Class JavaCodeGenerator

java.lang.Object
  extended by org.eclipse.ocl.examples.codegen.generator.AbstractCodeGenerator
      extended by org.eclipse.ocl.examples.codegen.java.JavaCodeGenerator
All Implemented Interfaces:
CodeGenerator
Direct Known Subclasses:
AutoCodeGenerator, JUnitCodeGenerator, OCLinEcoreCodeGenerator

public abstract class JavaCodeGenerator
extends AbstractCodeGenerator

OCL2JavaClass supports generation of the content of a JavaClassFile to provide the polymorphic implementation of an ExpressionInOCL.


Field Summary
static java.util.Map<java.lang.Class<?>,java.lang.Class<?>> javaPrimitiveClasses
           
static java.util.Map<java.lang.String,java.lang.Class<?>> javaPrimitiveNames
           
static java.lang.Class<?>[] knownClasses
          The known classes that templates may use in unqualified form.
 
Fields inherited from class org.eclipse.ocl.examples.codegen.generator.AbstractCodeGenerator
genModelHelper, metaModelManager, nameManager, ORG_ECLIPSE_JDT_ANNOTATION_NON_NULL, ORG_ECLIPSE_JDT_ANNOTATION_NULLABLE
 
Constructor Summary
JavaCodeGenerator(MetaModelManager metaModelManager)
           
 
Method Summary
 BoxingAnalyzer createBoxingAnalyzer()
           
 CG2JavaPreVisitor createCG2JavaPreVisitor()
           
 CommonSubexpressionEliminator createCommonSubexpressionEliminator()
           
 DependencyVisitor createDependencyVisitor()
           
 FieldingAnalyzer createFieldingAnalyzer()
           
protected  GenModelHelper createGenModelHelper()
           
protected  JavaGlobalContext createGlobalContext()
           
protected  Id2BoxedDescriptorVisitor createId2BoxedDescriptorVisitor()
           
protected  Id2EClassVisitor createId2EClassVisitor()
           
protected  NameManager createNameManager()
           
 ReferencesVisitor createReferencesVisitor()
           
 BoxedDescriptor getBoxedDescriptor(ElementId elementId)
           
 CGModelResourceFactory getCGResourceFactory()
           
 java.lang.String getConstantsClass()
           
 JavaGlobalContext getGlobalContext()
           
 GlobalPlace getGlobalPlace()
           
 Id2BoxedDescriptorVisitor getId2BoxedDescriptorVisitor()
           
 Id2EClassVisitor getId2EClassVisitor()
           
 java.lang.Boolean getIsNonNull(java.lang.reflect.Method method)
          Return true for an @NonNull annotation, false for an @Nullable annotation, null otherwise.
 Iteration2Java getIterationHelper(Iteration asIteration)
           
 java.lang.reflect.Method getLeastDerivedMethod(java.lang.Class<?> requiredClass, java.lang.String getAccessor)
           
 TypeDescriptor getTypeDescriptor(CGValuedElement cgElement)
           
 TypeDescriptor getTypeDescriptor(ElementId elementId, boolean isBoxed)
          Deprecated. 
 TypeDescriptor getTypeDescriptor(ElementId elementId, boolean isBoxed, boolean maybePrimitive)
          Deprecated. 
 UnboxedDescriptor getUnboxedDescriptor(ElementId elementId)
           
static void initPrimitive(java.lang.Class<?> class1, java.lang.Class<?> class2)
           
 java.lang.Boolean isNonNull(OperationCallExp asOperationCallExp)
          Return true if asOperationCallExp may return a nonNull value, false if asOperationCallExp may return a null value, null if no determination can be made.
 java.lang.Boolean isNonNull(Property asProperty)
          Return true if asProperty may provide a nonNull value, false if asOperationCallExp may provide a null value, null if no determination can be made.
 boolean maybePrimitive(CGValuedElement cgValue)
          Return true if cgValue could be represented by a primitive value.
protected  void optimize(CGPackage cgPackage)
          Perform the overall optimization of the CG tree.
 java.util.List<CGValuedElement> prepareGlobals()
          After overall optimization, return a sorted list of global declarations.
 
Methods inherited from class org.eclipse.ocl.examples.codegen.generator.AbstractCodeGenerator
addProblem, createAnalysisVisitor, createOptions, getDefaultIndent, getGenModelHelper, getMetaModelManager, getNameManager, getOptions, isFinal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ocl.examples.codegen.generator.CodeGenerator
getAnalyzer
 

Field Detail

javaPrimitiveClasses

public static java.util.Map<java.lang.Class<?>,java.lang.Class<?>> javaPrimitiveClasses

javaPrimitiveNames

public static java.util.Map<java.lang.String,java.lang.Class<?>> javaPrimitiveNames

knownClasses

@NonNull
public static final java.lang.Class<?>[] knownClasses
The known classes that templates may use in unqualified form. The list is here in a Java form to reduce the impact of refactoring on Acceleo templates.

Constructor Detail

JavaCodeGenerator

public JavaCodeGenerator(@NonNull
                         MetaModelManager metaModelManager)
Method Detail

initPrimitive

public static void initPrimitive(java.lang.Class<?> class1,
                                 java.lang.Class<?> class2)

createBoxingAnalyzer

@NonNull
public BoxingAnalyzer createBoxingAnalyzer()

createCommonSubexpressionEliminator

@NonNull
public CommonSubexpressionEliminator createCommonSubexpressionEliminator()

createCG2JavaPreVisitor

@NonNull
public CG2JavaPreVisitor createCG2JavaPreVisitor()

createDependencyVisitor

@NonNull
public DependencyVisitor createDependencyVisitor()

createFieldingAnalyzer

@NonNull
public FieldingAnalyzer createFieldingAnalyzer()

createGenModelHelper

@NonNull
protected GenModelHelper createGenModelHelper()
Specified by:
createGenModelHelper in class AbstractCodeGenerator

createGlobalContext

@NonNull
protected JavaGlobalContext createGlobalContext()

createId2EClassVisitor

@NonNull
protected Id2EClassVisitor createId2EClassVisitor()

createId2BoxedDescriptorVisitor

@NonNull
protected Id2BoxedDescriptorVisitor createId2BoxedDescriptorVisitor()

createNameManager

@NonNull
protected NameManager createNameManager()
Specified by:
createNameManager in class AbstractCodeGenerator

createReferencesVisitor

@NonNull
public ReferencesVisitor createReferencesVisitor()

getBoxedDescriptor

@NonNull
public BoxedDescriptor getBoxedDescriptor(@NonNull
                                                  ElementId elementId)

getCGResourceFactory

@NonNull
public CGModelResourceFactory getCGResourceFactory()

getConstantsClass

@Nullable
public java.lang.String getConstantsClass()

getGlobalContext

@NonNull
public JavaGlobalContext getGlobalContext()

getGlobalPlace

@NonNull
public GlobalPlace getGlobalPlace()

getId2BoxedDescriptorVisitor

@NonNull
public Id2BoxedDescriptorVisitor getId2BoxedDescriptorVisitor()

getId2EClassVisitor

@NonNull
public Id2EClassVisitor getId2EClassVisitor()

getIsNonNull

public java.lang.Boolean getIsNonNull(@NonNull
                                      java.lang.reflect.Method method)
Return true for an @NonNull annotation, false for an @Nullable annotation, null otherwise.


getIterationHelper

@Nullable
public Iteration2Java getIterationHelper(@NonNull
                                                  Iteration asIteration)

getLeastDerivedMethod

@Nullable
public java.lang.reflect.Method getLeastDerivedMethod(@NonNull
                                                               java.lang.Class<?> requiredClass,
                                                               @NonNull
                                                               java.lang.String getAccessor)

getTypeDescriptor

@NonNull
public TypeDescriptor getTypeDescriptor(@NonNull
                                                CGValuedElement cgElement)

getTypeDescriptor

@Deprecated
@NonNull
public TypeDescriptor getTypeDescriptor(@NonNull
                                                           ElementId elementId,
                                                           boolean isBoxed)
Deprecated. 


getTypeDescriptor

@Deprecated
@NonNull
public TypeDescriptor getTypeDescriptor(@NonNull
                                                           ElementId elementId,
                                                           boolean isBoxed,
                                                           boolean maybePrimitive)
Deprecated. 


getUnboxedDescriptor

@NonNull
public UnboxedDescriptor getUnboxedDescriptor(@NonNull
                                                      ElementId elementId)

isNonNull

@Nullable
public java.lang.Boolean isNonNull(@NonNull
                                            OperationCallExp asOperationCallExp)
Description copied from interface: CodeGenerator
Return true if asOperationCallExp may return a nonNull value, false if asOperationCallExp may return a null value, null if no determination can be made.


isNonNull

@Nullable
public java.lang.Boolean isNonNull(@NonNull
                                            Property asProperty)
Description copied from interface: CodeGenerator
Return true if asProperty may provide a nonNull value, false if asOperationCallExp may provide a null value, null if no determination can be made.


maybePrimitive

public boolean maybePrimitive(@NonNull
                              CGValuedElement cgValue)
Description copied from interface: CodeGenerator
Return true if cgValue could be represented by a primitive value. i.e. if it cannot convey a null or invalid value.


optimize

protected void optimize(@NonNull
                        CGPackage cgPackage)
Perform the overall optimization of the CG tree.


prepareGlobals

@Nullable
public java.util.List<CGValuedElement> prepareGlobals()
After overall optimization, return a sorted list of global declarations.