org.eclipse.emf.ocl.parser
Class TypeResolverImpl

java.lang.Object
  extended byorg.eclipse.emf.ocl.parser.TypeResolverImpl
All Implemented Interfaces:
TypeResolver

public class TypeResolverImpl
extends java.lang.Object
implements TypeResolver

Default implementation of the TypeResolver interface, storing the types that it generates in the a resource to support persistence of OCLExpressions referencing these types.

It is recommended that clients extend this class to customize resolution of types based on their models, rather than implementing the interface. Simply override the protected createXyzPackage() methods to determine where the resolved types are stored and the resolveXyzType() methods to create or find types are required.


Constructor Summary
TypeResolverImpl()
          Initializes me.
TypeResolverImpl(org.eclipse.emf.ecore.resource.Resource resource)
          Initializes me with a resource in which I will persist the model-based types that I generate in my associated Environment.
 
Method Summary
protected  org.eclipse.emf.ecore.EPackage createAdditionalFeaturesPackage()
          Creates the package containing the additional operations and properties parsed in my environment.
protected  org.eclipse.emf.ecore.EPackage createCollectionPackage()
          Creates the package containing the collection types that I generate.
protected  CollectionType createCollectionType(CollectionKind kind, org.eclipse.emf.ecore.EClassifier elementType)
          Creates a new collection type of the specified kind and element type, assuming that it does not already exist.
protected  org.eclipse.emf.ecore.EPackage createMessagePackage()
          Creates the package containing the message types that I generate.
protected  MessageType createMessageType(org.eclipse.emf.ecore.ENamedElement element)
          Creates a new message type for the specified element, assuming that it does not already exist.
protected  org.eclipse.emf.ecore.resource.Resource createResource()
          Creates the resource that persists my generated types.
protected  org.eclipse.emf.ecore.EClass createShadowClass(org.eclipse.emf.ecore.EClassifier type)
          Creates the shadow class to contain additional features defined for the specified OCL type.
protected  org.eclipse.emf.ecore.EPackage createTuplePackage()
          Creates the package containing the tuple types that I generate.
protected  TupleType createTupleType(java.util.List parts)
          Creates a new tuple type from the specified parts, assuming that it does not already exist.
protected  org.eclipse.emf.ecore.EPackage createTypePackage()
          Creates the package containing the type types that I generate.
protected  TypeType createTypeType(org.eclipse.emf.ecore.EClassifier type)
          Creates a new type type for the specified type, assuming that it does not already exist.
protected  CollectionType findCollectionType(CollectionKind kind, org.eclipse.emf.ecore.EClassifier elementType)
          Finds an existing collection type matching the specified kind and element type, if any has already been created.
protected  org.eclipse.emf.ecore.EOperation findMatchingOperation(org.eclipse.emf.ecore.EClass shadow, org.eclipse.emf.ecore.EOperation operation)
          Finds an operation already existing in the specified shadow class that matches the specified operation signature.
protected  org.eclipse.emf.ecore.EStructuralFeature findMatchingProperty(org.eclipse.emf.ecore.EClass shadow, org.eclipse.emf.ecore.EStructuralFeature property)
          Finds a property already existing in the specified shadow class that matches the specified property signature.
protected  MessageType findMessageType(org.eclipse.emf.ecore.ENamedElement element)
          Finds an existing message type matching the specified element, if any has already been created.
protected  org.eclipse.emf.ecore.EClass findShadowClass(org.eclipse.emf.ecore.EClassifier type)
          Finds the shadow class to contain additional features defined for the specified OCL type, if it already exists.
protected  TupleType findTupleType(java.util.List parts)
          Finds an existing tuple type matching the specified parts, if any has already been created.
protected  TypeType findTypeType(org.eclipse.emf.ecore.EClassifier type)
          Finds an existing type type matching the specified type, if any has already been created.
 org.eclipse.emf.ecore.EPackage getAdditionalFeaturesPackage()
          Obtains the package containing the additional operations and properties parsed in my environment.
 org.eclipse.emf.ecore.EPackage getCollectionPackage()
          Obtains the package containing the collection types that I generate.
 org.eclipse.emf.ecore.EPackage getMessagePackage()
          Obtains the package containing the message types that I generate.
 org.eclipse.emf.ecore.resource.Resource getResource()
          Obtains the resource in which the types that I generate are stored for persistence.
 org.eclipse.emf.ecore.EPackage getTuplePackage()
          Obtains the package containing the tuple types that I generate.
 org.eclipse.emf.ecore.EPackage getTypePackage()
          Obtains the package containing the type types that I generate.
 org.eclipse.emf.ecore.EClassifier resolve(org.eclipse.emf.ecore.EClassifier type)
          Resolves the specified type, returning my own persistent type instance representing the same OCL type.
 org.eclipse.emf.ecore.EOperation resolveAdditionalOperation(org.eclipse.emf.ecore.EClassifier owner, org.eclipse.emf.ecore.EOperation operation)
          Resolves the specified "additional operation" defined by the OCL client on the specified owner type.
 org.eclipse.emf.ecore.EStructuralFeature resolveAdditionalProperty(org.eclipse.emf.ecore.EClassifier owner, org.eclipse.emf.ecore.EStructuralFeature property)
          Resolves the specified "additional property" defined by the OCL client on the specified owner type.
 CollectionType resolveCollectionType(CollectionKind kind, org.eclipse.emf.ecore.EClassifier elementType)
          Resolves the collection type of the specified kind and element type, either created anew or previously created.
 MessageType resolveMessageType(org.eclipse.emf.ecore.EClass signal)
          Resolves the type for a message expression referencing the specified signal.
 MessageType resolveMessageType(org.eclipse.emf.ecore.EOperation operation)
          Resolves the type for a message expression referencing the specified operation.
 TupleType resolveTupleType(java.util.List parts)
          Resolves the tuple type consisting of the specified parts, in no particular order, either created anew or previously created.
 TypeType resolveTypeType(org.eclipse.emf.ecore.EClassifier type)
          Resolves the type for a type expression referencing the specified type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeResolverImpl

public TypeResolverImpl()
Initializes me. I create my own resource for persistence of model-based types.


TypeResolverImpl

public TypeResolverImpl(org.eclipse.emf.ecore.resource.Resource resource)
Initializes me with a resource in which I will persist the model-based types that I generate in my associated Environment.

Parameters:
resource - my resource
Method Detail

resolve

public org.eclipse.emf.ecore.EClassifier resolve(org.eclipse.emf.ecore.EClassifier type)
Description copied from interface: TypeResolver
Resolves the specified type, returning my own persistent type instance representing the same OCL type.

The type may have been newly created by the parser and be a duplicate of a type previously resolved, or it may actually be a type that was previously resolved. In the latter case, the type is returned as is. The null type is considered to be resolved (i.e., the result is also null).

Usually, this method will delegate to one of the resolveXyzType() methods defined by this interface.

Specified by:
resolve in interface TypeResolver
Returns:
the resolved type, or type if it is already resolved
See Also:

getResource

public org.eclipse.emf.ecore.resource.Resource getResource()
Description copied from interface: TypeResolver
Obtains the resource in which the types that I generate are stored for persistence.

Specified by:
getResource in interface TypeResolver
Returns:
my resource

createResource

protected org.eclipse.emf.ecore.resource.Resource createResource()
Creates the resource that persists my generated types. Subclasses requiring persistence must override this default implementation, as it creates a resource that does not support persistence and does not have a useful URI. A subclass could even find some other resource, such as that which will store the expressions parsed in this environment.

Returns:
the new resource

getCollectionPackage

public org.eclipse.emf.ecore.EPackage getCollectionPackage()
Obtains the package containing the collection types that I generate.

Returns:
my collection type package

createCollectionPackage

protected org.eclipse.emf.ecore.EPackage createCollectionPackage()
Creates the package containing the collection types that I generate.

Returns:
the new collection type package

resolveCollectionType

public CollectionType resolveCollectionType(CollectionKind kind,
                                            org.eclipse.emf.ecore.EClassifier elementType)
Description copied from interface: TypeResolver
Resolves the collection type of the specified kind and element type, either created anew or previously created.

Specified by:
resolveCollectionType in interface TypeResolver
Parameters:
kind - the kind of collection type to create
elementType - the element type
Returns:
the new or existing collection type

createCollectionType

protected CollectionType createCollectionType(CollectionKind kind,
                                              org.eclipse.emf.ecore.EClassifier elementType)
Creates a new collection type of the specified kind and element type, assuming that it does not already exist.

Parameters:
kind - the kind of collection to create
elementType - the collection's element type
Returns:
the new collection type

findCollectionType

protected CollectionType findCollectionType(CollectionKind kind,
                                            org.eclipse.emf.ecore.EClassifier elementType)
Finds an existing collection type matching the specified kind and element type, if any has already been created.

Parameters:
kind - the element kind to search for
elementType - the element type to search for
Returns:
the existing collection type, or null if none found

getTuplePackage

public org.eclipse.emf.ecore.EPackage getTuplePackage()
Obtains the package containing the tuple types that I generate.

Returns:
my tuple type package

createTuplePackage

protected org.eclipse.emf.ecore.EPackage createTuplePackage()
Creates the package containing the tuple types that I generate.

Returns:
the new tuple type package

resolveTupleType

public TupleType resolveTupleType(java.util.List parts)
Description copied from interface: TypeResolver
Resolves the tuple type consisting of the specified parts, in no particular order, either created anew or previously created. The resulting type is uniquely defined by the names and types of its parts, and twp tuple types are considered equal if they have the same number of parts and their parts correspond one-for-one in name and type (order is not significant).

Specified by:
resolveTupleType in interface TypeResolver
Parameters:
parts - a list of TypedElements defining the name and type of each tuple part. The part names are unique
Returns:
the new or existing tuple type

createTupleType

protected TupleType createTupleType(java.util.List parts)
Creates a new tuple type from the specified parts, assuming that it does not already exist.

Parameters:
parts - the TypedElements describing the tuple parts
Returns:
the new tuple type

findTupleType

protected TupleType findTupleType(java.util.List parts)
Finds an existing tuple type matching the specified parts, if any has already been created.

Parameters:
parts - the TypedElements describing the tuple parts
Returns:
the existing tuple type, or null if none found

getTypePackage

public org.eclipse.emf.ecore.EPackage getTypePackage()
Obtains the package containing the type types that I generate.

Returns:
my type type package

createTypePackage

protected org.eclipse.emf.ecore.EPackage createTypePackage()
Creates the package containing the type types that I generate.

Returns:
the new type type package

resolveTypeType

public TypeType resolveTypeType(org.eclipse.emf.ecore.EClassifier type)
Description copied from interface: TypeResolver
Resolves the type for a type expression referencing the specified type. This is, effectively, the OCL metatype counterpart for the specified model type.

Specified by:
resolveTypeType in interface TypeResolver
Parameters:
type - a model type
Returns:
the new or existing type type

createTypeType

protected TypeType createTypeType(org.eclipse.emf.ecore.EClassifier type)
Creates a new type type for the specified type, assuming that it does not already exist.

Parameters:
type - the referenced model type
Returns:
the new type type

findTypeType

protected TypeType findTypeType(org.eclipse.emf.ecore.EClassifier type)
Finds an existing type type matching the specified type, if any has already been created.

Parameters:
type - the referenced model type
Returns:
the existing type type, or null if none found

getMessagePackage

public org.eclipse.emf.ecore.EPackage getMessagePackage()
Obtains the package containing the message types that I generate.

Returns:
my message type package

createMessagePackage

protected org.eclipse.emf.ecore.EPackage createMessagePackage()
Creates the package containing the message types that I generate.

Returns:
the new message type package

resolveMessageType

public MessageType resolveMessageType(org.eclipse.emf.ecore.EOperation operation)
Description copied from interface: TypeResolver
Resolves the type for a message expression referencing the specified operation.

Specified by:
resolveMessageType in interface TypeResolver
Parameters:
operation - the operation call that the message represents
Returns:
the new or existing message type

resolveMessageType

public MessageType resolveMessageType(org.eclipse.emf.ecore.EClass signal)
Description copied from interface: TypeResolver
Resolves the type for a message expression referencing the specified signal.

Specified by:
resolveMessageType in interface TypeResolver
Parameters:
signal - the signal send that the message represents
Returns:
the new or existing message type

createMessageType

protected MessageType createMessageType(org.eclipse.emf.ecore.ENamedElement element)
Creates a new message type for the specified element, assuming that it does not already exist.

Parameters:
element - the operation or signal referenced by the message type
Returns:
the new message type

findMessageType

protected MessageType findMessageType(org.eclipse.emf.ecore.ENamedElement element)
Finds an existing message type matching the specified element, if any has already been created.

Parameters:
element - the referenced model element
Returns:
the existing message type, or null if none found

getAdditionalFeaturesPackage

public org.eclipse.emf.ecore.EPackage getAdditionalFeaturesPackage()
Obtains the package containing the additional operations and properties parsed in my environment.

Returns:
my additional features package

createAdditionalFeaturesPackage

protected org.eclipse.emf.ecore.EPackage createAdditionalFeaturesPackage()
Creates the package containing the additional operations and properties parsed in my environment.

Returns:
the new additional features package

resolveAdditionalOperation

public org.eclipse.emf.ecore.EOperation resolveAdditionalOperation(org.eclipse.emf.ecore.EClassifier owner,
                                                                   org.eclipse.emf.ecore.EOperation operation)
Description copied from interface: TypeResolver
Resolves the specified "additional operation" defined by the OCL client on the specified owner type.

Specified by:
resolveAdditionalOperation in interface TypeResolver
Parameters:
owner - the type on which the additional operation is defined
operation - the additional operation
Returns:
the persistent operation

findMatchingOperation

protected org.eclipse.emf.ecore.EOperation findMatchingOperation(org.eclipse.emf.ecore.EClass shadow,
                                                                 org.eclipse.emf.ecore.EOperation operation)
Finds an operation already existing in the specified shadow class that matches the specified operation signature.

Parameters:
shadow - the shadow class to search
operation - the operation to match
Returns:
the matching operation, or null if not found

findMatchingProperty

protected org.eclipse.emf.ecore.EStructuralFeature findMatchingProperty(org.eclipse.emf.ecore.EClass shadow,
                                                                        org.eclipse.emf.ecore.EStructuralFeature property)
Finds a property already existing in the specified shadow class that matches the specified property signature.

Parameters:
shadow - the shadow class to search
property - the property to match
Returns:
the matching operation, or null if not found

resolveAdditionalProperty

public org.eclipse.emf.ecore.EStructuralFeature resolveAdditionalProperty(org.eclipse.emf.ecore.EClassifier owner,
                                                                          org.eclipse.emf.ecore.EStructuralFeature property)
Description copied from interface: TypeResolver
Resolves the specified "additional property" defined by the OCL client on the specified owner type.

Specified by:
resolveAdditionalProperty in interface TypeResolver
Parameters:
owner - the type on which the additional property is defined
property - the additional property
Returns:
the persistent property

createShadowClass

protected org.eclipse.emf.ecore.EClass createShadowClass(org.eclipse.emf.ecore.EClassifier type)
Creates the shadow class to contain additional features defined for the specified OCL type.

Parameters:
type - an OCL type
Returns:
the class containing its additional features

findShadowClass

protected org.eclipse.emf.ecore.EClass findShadowClass(org.eclipse.emf.ecore.EClassifier type)
Finds the shadow class to contain additional features defined for the specified OCL type, if it already exists.

Parameters:
type - an OCL type
Returns:
the class containing its additional features, or null if not found

Copyright 2002, 2006 IBM Corporation and others.
All Rights Reserved.