org.eclipse.emf.ocl.parser
Class AbstractEnvironmentFactory

java.lang.Object
  extended byorg.eclipse.emf.ocl.parser.AbstractEnvironmentFactory
All Implemented Interfaces:
EnvironmentFactory
Direct Known Subclasses:
EcoreEnvironmentFactory

public abstract class AbstractEnvironmentFactory
extends java.lang.Object
implements EnvironmentFactory

Partial implementation of the EnvironmentFactory interface, useful for subclassing for client metamodels. This abstract class takes care of some of the more common (and mundane) chores, such as:

The subclass's responsibility is to define how to:

This class is intended to be extended by clients, for the purpose of implementing metamodel-specified environment factories.


Field Summary
 
Fields inherited from interface org.eclipse.emf.ocl.parser.EnvironmentFactory
ECORE_INSTANCE
 
Constructor Summary
protected AbstractEnvironmentFactory()
          Initializes me.
 
Method Summary
protected abstract  org.eclipse.emf.ecore.EClassifier asEClassifier(java.lang.Object context)
          Adapts the specified client metamodel context to the EClassifier API.
protected abstract  org.eclipse.emf.ecore.EOperation asEOperation(java.lang.Object operation)
          Adapts the specified client metamodel operation to the EOperation API.
protected abstract  org.eclipse.emf.ecore.EStructuralFeature asEStructuralFeature(java.lang.Object property)
          Adapts the specified client metamodel property to the EStructuralFeature API.
 Environment createClassifierContext(java.lang.Object context)
          Creates an environment suitable for parsing OCL expressions on the specified object, which is some classifier in the client's metamodel or an instance thereof.
protected abstract  Environment createEnvironment(org.eclipse.emf.ecore.EPackage packageContext)
          Implemented by subclasses to create a new environment implementation on the specified package context.
 EvaluationEnvironment createEvaluationEnvironment()
          Default evaluation environment is implemented as a Map of String ==> Object.
 java.util.Map createExtentMap(java.lang.Object object)
          Default implementation considers the resource containing an EObject as defining the scope of the OCL classifier extents.
 Environment createOperationContext(java.lang.Object context, java.lang.Object operation)
          Creates an environment suitable for parsing OCL expressions on the specified operation, which is some operation in the client's metamodel.
 Environment createPackageContext(java.util.List pathname)
          Creates an environment suitable for parsing OCL expressions in the specified package context.
 Environment createPropertyContext(java.lang.Object context, java.lang.Object property)
          Creates an environment suitable for parsing OCL expressions on the specified property, which is some property in the client's metamodel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.emf.ocl.parser.EnvironmentFactory
createEnvironment
 

Constructor Detail

AbstractEnvironmentFactory

protected AbstractEnvironmentFactory()
Initializes me.

Method Detail

createEnvironment

protected abstract Environment createEnvironment(org.eclipse.emf.ecore.EPackage packageContext)
Implemented by subclasses to create a new environment implementation on the specified package context. The package is obtained from the context classifier, which is adapted from the client metamodel by the AbstractEnvironmentFactory.asEClassifier(Object) method.

Parameters:
packageContext - the OCL package context (not null)
Returns:
the corresponding environment

asEClassifier

protected abstract org.eclipse.emf.ecore.EClassifier asEClassifier(java.lang.Object context)
Adapts the specified client metamodel context to the EClassifier API. This might just return the context if it already is an EClassifier, or might return its type if it is an instance of an EClassifier, or adapt it by some other means to the EClassifier API.

Parameters:
context - a classifier in the client metamodel's definition of what an OCL classifier is, or an instance thereof
Returns:
the Ecore representation of the client's classifier

asEOperation

protected abstract org.eclipse.emf.ecore.EOperation asEOperation(java.lang.Object operation)
Adapts the specified client metamodel operation to the EOperation API.

Parameters:
operation - an operation in the client metamodel's definition of what an OCL operation is
Returns:
the Ecore representation of the client's operation

asEStructuralFeature

protected abstract org.eclipse.emf.ecore.EStructuralFeature asEStructuralFeature(java.lang.Object property)
Adapts the specified client metamodel property to the EStructuralFeature API.

Parameters:
property - a property in the client metamodel's definition of what an OCL property is
Returns:
the Ecore representation of the client's property

createClassifierContext

public Environment createClassifierContext(java.lang.Object context)
Description copied from interface: EnvironmentFactory
Creates an environment suitable for parsing OCL expressions on the specified object, which is some classifier in the client's metamodel or an instance thereof.

The context may be either the specific model element or primitive value on which an OCL expression would be evaluated, or it may be an EClassifier of the target metamodel against which an OCL expression would be parsed. Note that, in the former case, the actual OCL context classifier (as an OCL type or EClassifier) will be inferred from the context object according to the nature of the environment factory

Specified by:
createClassifierContext in interface EnvironmentFactory
Parameters:
context - the context object or classifier
Returns:
the environment
See Also:
EnvironmentFactory.createOperationContext(Object, Object)

createPackageContext

public Environment createPackageContext(java.util.List pathname)
Description copied from interface: EnvironmentFactory
Creates an environment suitable for parsing OCL expressions in the specified package context. This context will become a classifier context when the "self" variable is defined.

Specified by:
createPackageContext in interface EnvironmentFactory
Parameters:
pathname - the qualified package name (the ::-separated parts)
Returns:
the environment
See Also:
EnvironmentFactory.createClassifierContext(Object), EnvironmentFactory.createOperationContext(Object, Object)

createOperationContext

public Environment createOperationContext(java.lang.Object context,
                                          java.lang.Object operation)
Description copied from interface: EnvironmentFactory
Creates an environment suitable for parsing OCL expressions on the specified operation, which is some operation in the client's metamodel. Note that operation contexts can be defined in the context of any classifier to which that operation is applicable.

Specified by:
createOperationContext in interface EnvironmentFactory
Parameters:
operation - an operation in the client's metamodel
Returns:
the environment
See Also:
EnvironmentFactory.createClassifierContext(Object)

createPropertyContext

public Environment createPropertyContext(java.lang.Object context,
                                         java.lang.Object property)
Description copied from interface: EnvironmentFactory
Creates an environment suitable for parsing OCL expressions on the specified property, which is some property in the client's metamodel. Note that property contexts can be defined in the context of any classifier in which that property is available.

Specified by:
createPropertyContext in interface EnvironmentFactory
Parameters:
property - a property (structural feature) in the client's metamodel
Returns:
the environment
See Also:
EnvironmentFactory.createClassifierContext(Object)

createEvaluationEnvironment

public EvaluationEnvironment createEvaluationEnvironment()
Default evaluation environment is implemented as a Map of String ==> Object.

Specified by:
createEvaluationEnvironment in interface EnvironmentFactory
Returns:
a new evaluation environment

createExtentMap

public java.util.Map createExtentMap(java.lang.Object object)
Default implementation considers the resource containing an EObject as defining the scope of the OCL classifier extents. In the case that the specified object is not an EObject, we have no access to any such scope, so all extents will be empty.

Specified by:
createExtentMap in interface EnvironmentFactory
Parameters:
object - a context object in the scope that covers the OCL classifier extents
Returns:
the extent map

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