org.eclipse.emf.importer.java.builder
Class JavaEcoreBuilder

java.lang.Object
  extended byorg.eclipse.emf.importer.java.builder.JavaEcoreBuilder

public class JavaEcoreBuilder
extends Object


Field Summary
protected  BasicDiagnostic basicDiagnostic
           
protected  Set demandCreatedEDataTypes
          The set of data types that were created without setting the instance class.
protected static Pattern eAnnotationDetailExpression
           
protected static Pattern eAnnotationExpression
           
protected  Map eClassToSuperTypeNamesMap
          The map from a class to its base class names.
protected  Map eModelElementToIDOMNodeMap
          The map from a model element to the corresponding JDOM node.
protected  Map eOperationToExceptionTypeNamesMap
          The map from an operation to its exception type names.
protected  Map ePackageToOrderingMap
          The map from package to the map of ordering constants.
protected  Map ePackageToPrefixMap
          The map from package to the it's prefix.
protected  Map eReferenceToOppositeNameMap
          The map from a reference to the name it's opposite.
protected  Map eTypedElementToInstanceTypeNameMap
          The map from a typed element to its datatype's instance type name.
protected  Map eTypedElementToTypeNameMap
          The map from a typed element to its type name.
protected static Pattern extendsAnnotationExpression
          The pattern for extracting the @extends annotations.
protected  Collection externalGenModels
          All the external GenModels from all required projects.
protected  Map externalPackageNameToEPackageMap
          The map from a package name to the corresponding package.
protected  boolean foundJava
           
protected  GenModel genModel
          The GenModel being generated.
protected  IFile genModelFile
          The file being generated.
protected static Pattern implementsAnnotationExpression
          The pattern for extracting the @implements annotations.
protected static org.eclipse.jdt.core.jdom.DOMFactory jdomFactory
          The factory used to create JDOM.
protected static Pattern modelAnnotationExpression
          The pattern for extracting the @model annotations.
protected static Pattern modelDocExpression
          The pattern for extracting the model documentation.
protected  GenModel oldGenModelVersion
          The old version to against which to reconcile.
protected  Map packageNameToEPackageMap
          The map from a package name to the corresponding package.
protected  Collection usedGenPackages
          All the used GenPackages.
 
Constructor Summary
JavaEcoreBuilder(IFile genModelFile)
          Creates a builder for the given file.
JavaEcoreBuilder(IFile genModelFile, GenModel oldGenModelVersion)
           
JavaEcoreBuilder(IFile genModelFile, GenModel oldGenModelVersion, GenModel genModel)
           
 
Method Summary
protected  IPath analyseProject(IProject project)
           
protected  void analyzeCompilationUnit(org.eclipse.jdt.core.jdom.IDOMCompilationUnit compilationUnit)
          Walks the compilation unit to analyze the type.
protected  void analyzeField(EEnum eEnum, org.eclipse.jdt.core.jdom.IDOMField field)
          Creates EEnumLiteral as appropriate.
protected  void analyzeMethod(EClass eClass, org.eclipse.jdt.core.jdom.IDOMMethod method)
          Creates an EOperation, EAttribute, or EReference as appropriate.
protected  ETypedElement analyzeMethod(EClass eClass, String modelAnnotation, String methodName, String returnType, String[] parameterNames, String[] parameterTypes, String[] exceptionTypes)
           
protected  void analyzeType(org.eclipse.jdt.core.jdom.IDOMType type)
          Walks the type either as an EClass or an ENum to analyze either the methods or the fields.
 void computeEPackages(Monitor monitor, ModelImporter modelImporter)
           
protected  EStructuralFeature createFeature(EClass eClass, String name, EClassifier eType)
           
protected  ResourceSet createResourceSet()
           
 void determineExternalPackages(GenPackage genPackage)
           
protected  void determineExternalPackages(GenPackage genPackage, ModelImporter modelImporter)
           
protected  void error(String message)
          Produces another IStatus in the MultiStatus.
protected  List extractEAnnotations(String modelAnnotation)
           
 void getAllGenModelFiles(Collection result, IContainer container)
          Walks the container recursively.
 void getAllGenModelFiles(Collection result, IFile file)
          Walks the container recursively.
 void getAllReferencedProjects(Collection result, IProject[] projects)
          Walks the projects recursively.
 Diagnostic getDiagnostic()
          Returns the diagnostic.
protected  String getExtendsAnnotation(String comment)
          Returns the @extends/@implements annotation contents, or null.
protected  String getFilteredModelAnnotations(String modelAnnotation, String filter)
          Returns the filtered matches xyzAttribute-name="value" or of xyxAttribute-name='value', or null.
 GenModel getGenModel()
          Returns the generator model.
protected  String getModelAnnotation(String comment)
          Returns the @model annotation contents, or null.
protected  String getModelAnnotationAttribute(String modelAnnotation, String attributeName)
          Returns the unquoted value of attribute-name="value" or of attribute-name='value', or null.
protected  String getModelAnnotationAttributes(String modelAnnotation, String attributeName)
          Returns the space separated concatenation of the unquoted value of each attribute-name="value" or attribute-name='value' repeat, or null.
protected  String getModelDocumentation(String comment)
          Returns the model documentation, or null.
protected  int getOrderingValue(ENamedElement eNamedElement, Map nameToIDMap)
           
 Collection getUsedGenPackages()
          Returns the list of used GenPackages.
protected  void handleETypedElement(ETypedElement eTypedElement, String name, String type, String modelAnnotation, String identifierName)
           
protected  EClassifier resolve(EModelElement eModelElement, String typeName)
           
protected  EClassifier resolve(EModelElement eModelElement, String typeName, boolean recordDemandCreatedEDataType)
           
protected  EClass resolveMapEntry(EPackage ePackage, EClassifier keyEClassifier, EClassifier valueEClassifier)
           
protected  EClassifier resolveType(ETypedElement eTypedElement)
           
protected  void sort(EList eList, Map nameToIDMap)
           
 void traverse(IContainer container, Set visited)
          Walks the container recursively.
 void traverse(IFile file)
          Analyzes .java files as JDOM compilation units.
 void used(EModelElement modelElement)
           
protected  void warning(String message)
          Produces another IStatus in the MultiStatus, with warning severity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jdomFactory

protected static org.eclipse.jdt.core.jdom.DOMFactory jdomFactory
The factory used to create JDOM.


genModelFile

protected IFile genModelFile
The file being generated.


genModel

protected GenModel genModel
The GenModel being generated.


externalPackageNameToEPackageMap

protected Map externalPackageNameToEPackageMap
The map from a package name to the corresponding package. These are populated from the GenModels of required projects.


packageNameToEPackageMap

protected Map packageNameToEPackageMap
The map from a package name to the corresponding package. These are populated on demand during traversal as modeled class and enums are discovered.


ePackageToOrderingMap

protected Map ePackageToOrderingMap
The map from package to the map of ordering constants. These are populated as the package interface is traversed.


ePackageToPrefixMap

protected Map ePackageToPrefixMap
The map from package to the it's prefix. These are populated as the package interfaces are traversed.


eModelElementToIDOMNodeMap

protected Map eModelElementToIDOMNodeMap
The map from a model element to the corresponding JDOM node. These are populated during traversal as each model element is created.


eTypedElementToTypeNameMap

protected Map eTypedElementToTypeNameMap
The map from a typed element to its type name. These are populated during traversal as each typed element is created. They must be patched after traversal is completed.


eTypedElementToInstanceTypeNameMap

protected Map eTypedElementToInstanceTypeNameMap
The map from a typed element to its datatype's instance type name. These are populated during traversal as each typed element is created. They must be patched after traversal is completed. They are only needed if the instance must be determined bottom up.


demandCreatedEDataTypes

protected Set demandCreatedEDataTypes
The set of data types that were created without setting the instance class.


eClassToSuperTypeNamesMap

protected Map eClassToSuperTypeNamesMap
The map from a class to its base class names. These are populated during traversal as each class is created. They must be patched after traversal is completed.


eOperationToExceptionTypeNamesMap

protected Map eOperationToExceptionTypeNamesMap
The map from an operation to its exception type names. These are populated during traversal as each operation is created. They must be patched after traversal is completed.


eReferenceToOppositeNameMap

protected Map eReferenceToOppositeNameMap
The map from a reference to the name it's opposite. These are populated during traversal as each reference with an opposite is created. They must be patched after traversal and patching of typed elements is completed. The opposite found as a feature of the type.


externalGenModels

protected Collection externalGenModels
All the external GenModels from all required projects.


usedGenPackages

protected Collection usedGenPackages
All the used GenPackages.


basicDiagnostic

protected BasicDiagnostic basicDiagnostic

foundJava

protected boolean foundJava

oldGenModelVersion

protected GenModel oldGenModelVersion
The old version to against which to reconcile.


modelDocExpression

protected static Pattern modelDocExpression
The pattern for extracting the model documentation.


modelAnnotationExpression

protected static Pattern modelAnnotationExpression
The pattern for extracting the @model annotations.


extendsAnnotationExpression

protected static Pattern extendsAnnotationExpression
The pattern for extracting the @extends annotations.


implementsAnnotationExpression

protected static Pattern implementsAnnotationExpression
The pattern for extracting the @implements annotations.


eAnnotationExpression

protected static Pattern eAnnotationExpression

eAnnotationDetailExpression

protected static Pattern eAnnotationDetailExpression
Constructor Detail

JavaEcoreBuilder

public JavaEcoreBuilder(IFile genModelFile)
Creates a builder for the given file.


JavaEcoreBuilder

public JavaEcoreBuilder(IFile genModelFile,
                        GenModel oldGenModelVersion)

JavaEcoreBuilder

public JavaEcoreBuilder(IFile genModelFile,
                        GenModel oldGenModelVersion,
                        GenModel genModel)
Method Detail

createResourceSet

protected ResourceSet createResourceSet()

analyseProject

protected IPath analyseProject(IProject project)
                        throws Exception
Throws:
Exception

computeEPackages

public void computeEPackages(Monitor monitor,
                             ModelImporter modelImporter)
                      throws Exception
Throws:
Exception

used

public void used(EModelElement modelElement)

determineExternalPackages

public void determineExternalPackages(GenPackage genPackage)

determineExternalPackages

protected void determineExternalPackages(GenPackage genPackage,
                                         ModelImporter modelImporter)

getAllReferencedProjects

public void getAllReferencedProjects(Collection result,
                                     IProject[] projects)
                              throws CoreException
Walks the projects recursively.

Throws:
CoreException

getAllGenModelFiles

public void getAllGenModelFiles(Collection result,
                                IContainer container)
                         throws CoreException
Walks the container recursively.

Throws:
CoreException

getAllGenModelFiles

public void getAllGenModelFiles(Collection result,
                                IFile file)
                         throws CoreException
Walks the container recursively.

Throws:
CoreException

traverse

public void traverse(IContainer container,
                     Set visited)
              throws CoreException
Walks the container recursively.

Throws:
CoreException

traverse

public void traverse(IFile file)
              throws CoreException
Analyzes .java files as JDOM compilation units.

Throws:
CoreException

analyzeCompilationUnit

protected void analyzeCompilationUnit(org.eclipse.jdt.core.jdom.IDOMCompilationUnit compilationUnit)
Walks the compilation unit to analyze the type.


analyzeType

protected void analyzeType(org.eclipse.jdt.core.jdom.IDOMType type)
Walks the type either as an EClass or an ENum to analyze either the methods or the fields.


analyzeMethod

protected void analyzeMethod(EClass eClass,
                             org.eclipse.jdt.core.jdom.IDOMMethod method)
Creates an EOperation, EAttribute, or EReference as appropriate.


analyzeMethod

protected ETypedElement analyzeMethod(EClass eClass,
                                      String modelAnnotation,
                                      String methodName,
                                      String returnType,
                                      String[] parameterNames,
                                      String[] parameterTypes,
                                      String[] exceptionTypes)

handleETypedElement

protected void handleETypedElement(ETypedElement eTypedElement,
                                   String name,
                                   String type,
                                   String modelAnnotation,
                                   String identifierName)

createFeature

protected EStructuralFeature createFeature(EClass eClass,
                                           String name,
                                           EClassifier eType)

analyzeField

protected void analyzeField(EEnum eEnum,
                            org.eclipse.jdt.core.jdom.IDOMField field)
Creates EEnumLiteral as appropriate.


getModelDocumentation

protected String getModelDocumentation(String comment)
Returns the model documentation, or null.


getModelAnnotation

protected String getModelAnnotation(String comment)
Returns the @model annotation contents, or null.


getExtendsAnnotation

protected String getExtendsAnnotation(String comment)
Returns the @extends/@implements annotation contents, or null.


getModelAnnotationAttribute

protected String getModelAnnotationAttribute(String modelAnnotation,
                                             String attributeName)
Returns the unquoted value of attribute-name="value" or of attribute-name='value', or null.


getModelAnnotationAttributes

protected String getModelAnnotationAttributes(String modelAnnotation,
                                              String attributeName)
Returns the space separated concatenation of the unquoted value of each attribute-name="value" or attribute-name='value' repeat, or null.


extractEAnnotations

protected List extractEAnnotations(String modelAnnotation)

getFilteredModelAnnotations

protected String getFilteredModelAnnotations(String modelAnnotation,
                                             String filter)
Returns the filtered matches xyzAttribute-name="value" or of xyxAttribute-name='value', or null.


resolve

protected EClassifier resolve(EModelElement eModelElement,
                              String typeName)

resolve

protected EClassifier resolve(EModelElement eModelElement,
                              String typeName,
                              boolean recordDemandCreatedEDataType)

resolveMapEntry

protected EClass resolveMapEntry(EPackage ePackage,
                                 EClassifier keyEClassifier,
                                 EClassifier valueEClassifier)

resolveType

protected EClassifier resolveType(ETypedElement eTypedElement)

sort

protected void sort(EList eList,
                    Map nameToIDMap)

getOrderingValue

protected int getOrderingValue(ENamedElement eNamedElement,
                               Map nameToIDMap)

getDiagnostic

public Diagnostic getDiagnostic()
Returns the diagnostic.

Returns:
the status.

getGenModel

public GenModel getGenModel()
Returns the generator model.

Returns:
the generator model.

getUsedGenPackages

public Collection getUsedGenPackages()
Returns the list of used GenPackages.

Returns:
the list of used GenPackages.

error

protected void error(String message)
Produces another IStatus in the MultiStatus.

Parameters:
message - a description of the error.

warning

protected void warning(String message)
Produces another IStatus in the MultiStatus, with warning severity.

Parameters:
message - a description of the error.

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.