org.eclipse.emf.ocl.parser
Interface EnvironmentFactory

All Known Implementing Classes:
AbstractEnvironmentFactory

public interface EnvironmentFactory

A facotry 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 Ecore metamodel, extended by UML constructs defined and/or used by the OCL language. Many of these mappings are optional (e.g., OclState, OclMessage, AssociationClass).

This interface is not intended to be implemented by clients "directly". It is highly recommended to extend the AbstractEnvironmentFactory or EcoreEnvironmentFactory class, instead.


Field Summary
static EnvironmentFactory ECORE_INSTANCE
          An instance that creates Environments suitable for parsing OCL expressions on the Ecore metamodel.
 
Method Summary
 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.
 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.
 java.util.Map createExtentMap(java.lang.Object object)
          Creates an extent map for invocation of OclType.allInstances() using the specified object as a context from which to find the scope in which OCL classifier extents are defined.
 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.
 

Field Detail

ECORE_INSTANCE

public static final EnvironmentFactory ECORE_INSTANCE
An instance that creates Environments suitable for parsing OCL expressions on the Ecore metamodel. This factory expects classifiers to be instances of the EClassifier type and operations to be EOperations.

Method Detail

createPackageContext

public Environment createPackageContext(java.util.List pathname)
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.

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

createClassifierContext

public 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.

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

Parameters:
context - the context object or classifier
Returns:
the environment
See Also:
EnvironmentFactory.createOperationContext(Object, Object)

createOperationContext

public 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. Note that operation contexts can be defined in the context of any classifier to which that operation is applicable.

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)
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.

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

createEnvironment

public 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

public 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

createExtentMap

public java.util.Map createExtentMap(java.lang.Object object)
Creates an extent map for invocation of OclType.allInstances() using the specified object as a context from which to find the scope in which OCL classifier extents are defined. This scope may be a resource, resource set, or some metamodel-specific scope. Note that in the case that the object is not an EObject but is, instead, some primitive type, then this may be difficult to determine.

Clients are encourage to do what they can to optimize this mapping, by lazy initialization of key-value pairs, workspace indices, or whatever means is available. Note that the map will only ever be accessed by key (Map.get(java.lang.Object)); it will never be queried for all entries, all keys, all values, etc. This knowledge could help optimization.

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.