org.eclipse.ocl.examples.pivot
Interface EnvironmentFactory

Type Parameters:
PK - is substituted by the metaclass representing the metamodel's analogue for the UML 2.x Package
C - corresponds to the UML Classifier metaclass
O - corresponds to the UML Operation metaclass
P - corresponds to the UML Property metaclass
EL - corresponds to the UML EnumerationLiteral metaclass (Enumerations are simply represented as classifiers)
PM - corresponds to the UML Parameter metaclass
S - corresponds to the UML State metaclass (for metamodels that describe state machines)
COA - corresponds to the UML CallOperationAction metaclass (used in message expressions)
SSA - corresponds to the UML SendSignalAction metaclass (used in message expressions)
CT - corresponds to the UML Constraint metaclass
CLS - corresponds to the UML Class metaclass
E - corresponds to the UML Element metaclass
All Known Implementing Classes:
AbstractEnvironmentFactory, PivotEnvironmentFactory

public interface EnvironmentFactory

A factory for creating OCL parser Environments. Clients of the OCL parser that wish to use OCL with their metamodels can provide the parser a factory that creates the suitable environments. The environment provides mappings from the client's metamodel to the UML concepts required by the parser (corresponding to the generic type parameters, below). Many of these mappings are optional (e.g., state machines, signals, and association classes aren't supported by all metamodels).

This interface is not intended to be implemented to be implemented "directly" by providers of metamodel bindings. It is highly recommended to extend the AbstractEnvironmentFactory class, instead.

Since 1.2, the AbstractEnvironmentFactory implements the Adaptable interface and provides an adapter for the EnvironmentFactory.Lookup interface. Use the OCLUtil.getAdapter(EnvironmentFactory, Class) method to obtain adapters for any factory instance.

Author:
Christian W. Damus (cdamus)

Method Summary
 Environment createAttributeContext(Environment parent, Property property)
          Creates an environment suitable for parsing OCL expressions on the specified property, which is some attribute in the client's metamodel.
 Environment createClassifierContext(Environment parent, Type context)
          Creates an environment suitable for parsing OCL expressions in the specified context, which is some classifier in the client's model.
 Environment createEnvironment()
          Creates a root environment, in which package contexts and/or classifier contexts will be created as nested environments.
 Environment createEnvironment(Environment parent)
          Creates a child environment of a specified parent, for definition of nested scopes.
 EvaluationEnvironment createEvaluationEnvironment()
          Creates a new evaluation environment to track the values of variables in an OCL expression as it is evaluated.
 EvaluationEnvironment createEvaluationEnvironment(EvaluationEnvironment parent)
          Creates a new evaluation environment as a nested environment of the specified parent.
 EvaluationVisitor createEvaluationVisitor(Environment env, EvaluationEnvironment evalEnv, ModelManager modelManager)
          Creates a new evaluation visitor, for the evaluation of OCL expressions.
 Environment createInstanceContext(Environment parent, java.lang.Object context)
          Creates an environment suitable for parsing OCL expressions on the specified context object, which is an instance of some classifier in the client's model.
 Environment createOperationContext(Environment parent, Operation operation)
          Creates an environment suitable for parsing OCL expressions on the specified operation, which is some operation in the client's metamodel.
 Environment loadEnvironment(org.eclipse.emf.ecore.resource.Resource resource)
          Loads an environment from the specified resource.
 

Method Detail

createEnvironment

Environment createEnvironment()
Creates a root environment, in which package contexts and/or classifier contexts will be created as nested environments. All operation body constraints, attribute initial/derived value constraints, and definitions of additional attributes and operations should be maintained by the root environment, so that they will be accessible from constraints parsed in any nested environment.

Returns:
a new root environment

loadEnvironment

Environment loadEnvironment(org.eclipse.emf.ecore.resource.Resource resource)
Loads an environment from the specified resource. If not already loaded, this method will load the resource. This resource will subsequently be used to persist new OCL constraints, so supplying a new, empty resource will allow the client to determine where the environment is persisted.

Parameters:
resource - a resource containing the persisted environment

createClassifierContext

Environment createClassifierContext(Environment parent,
                                    Type context)
Creates an environment suitable for parsing OCL expressions in the specified context, which is some classifier in the client's model.

Parameters:
context - the context classifier
Returns:
the environment
See Also:
#createOperationContext(Environment, Object), #createAttributeContext(Environment, Object), createInstanceContext(Environment, Object)

createInstanceContext

Environment createInstanceContext(Environment parent,
                                  java.lang.Object context)
Creates an environment suitable for parsing OCL expressions on the specified context object, which is an instance of some classifier in the client's model.

The context may be an instance of a model class or a data type value on which an OCL expression would be evaluated. Note that the actual OCL context classifier (as an OCL type or classifier) will be inferred from the context instance according to the metamodel that the environment factory supports, if possible. If not possible, then the OclAny type is assumed.

Parameters:
context - the context object or value
Returns:
the environment
See Also:
#createClassifierContext(Environment, Object), StandardLibrary#getOclAny()

createOperationContext

Environment createOperationContext(Environment parent,
                                   Operation operation)
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.

Parameters:
parent - the parent environment, defining the classifier context
operation - an operation in the client's metamodel
Returns:
the environment
See Also:
#createClassifierContext(Environment, Object)

createAttributeContext

Environment createAttributeContext(Environment parent,
                                   Property property)
Creates an environment suitable for parsing OCL expressions on the specified property, which is some attribute in the client's metamodel. Note that attribute contexts can be defined in the context of any classifier in which that attribute is available.

Parameters:
parent - the parent environment, defining the classifier context
property - an attribute in the client's metamodel
Returns:
the environment
See Also:
#createClassifierContext(Environment, Object)

createEnvironment

Environment createEnvironment(Environment parent)
Creates a child environment of a specified parent, for definition of nested scopes.

Parameters:
parent - the parent environment
Returns:
the child environment

createEvaluationEnvironment

EvaluationEnvironment createEvaluationEnvironment()
Creates a new evaluation environment to track the values of variables in an OCL expression as it is evaluated.

Returns:
a new evaluation environment

createEvaluationEnvironment

EvaluationEnvironment createEvaluationEnvironment(EvaluationEnvironment parent)
Creates a new evaluation environment as a nested environment of the specified parent.

Parameters:
parent - a nesting evaluation environment
Returns:
a new nested evaluation environment

createEvaluationVisitor

EvaluationVisitor createEvaluationVisitor(Environment env,
                                          EvaluationEnvironment evalEnv,
                                          ModelManager modelManager)
Creates a new evaluation visitor, for the evaluation of OCL expressions.

Parameters:
env - the environment in which the expression was originally parsed (or some compatible environment)
evalEnv - the evaluation environment that the visitor is to use for tracking variables, navigating properties, etc.
modelManager - the map of Classes to their extends
Returns:
the new evaluation visitor