## org.eclipse.ocl
Interface EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>

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 (`Enumeration`s 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, EcoreEnvironmentFactory, UMLEnvironmentFactory

    public interface EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>

A factory for creating OCL parser `Environment`s. 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.

Nested Class Summary
`static interface` `EnvironmentFactory.Lookup<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>` Optional adapter interface for look-up methods that throw `LookupException`s on abnormal failures (usually ambiguous names).

Method Summary
`Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>` `createAttributeContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent, P property)` Creates an environment suitable for parsing OCL expressions on the specified `property`, which is some attribute in the client's metamodel.
`Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>` `createClassifierContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent, C context)` Creates an environment suitable for parsing OCL expressions in the specified `context`, which is some classifier in the client's model.
`Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>` `createEnvironment()` Creates a root environment, in which package contexts and/or classifier contexts will be created as nested environments.
`Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>` `createEnvironment(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent)` Creates a child environment of a specified `parent`, for definition of nested scopes.
`EvaluationEnvironment<C,O,P,CLS,E>` `createEvaluationEnvironment()` Creates a new evaluation environment to track the values of variables in an OCL expression as it is evaluated.
`EvaluationEnvironment<C,O,P,CLS,E>` `createEvaluationEnvironment(EvaluationEnvironment<C,O,P,CLS,E> parent)` Creates a new evaluation environment as a nested environment of the specified `parent`.
`EvaluationVisitor<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>` `createEvaluationVisitor(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env, EvaluationEnvironment<C,O,P,CLS,E> evalEnv, Map<? extends CLS,? extends Set<? extends E>> extentMap)` Creates a new evaluation visitor, for the evaluation of OCL expressions.
`Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>` `createInstanceContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent, 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<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>` `createOperationContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent, O operation)` Creates an environment suitable for parsing OCL expressions on the specified `operation`, which is some operation in the client's metamodel.
`Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>` `createPackageContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent, List<String> pathname)` Creates an environment suitable for parsing OCL expressions in the specified package context.
`Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>` `loadEnvironment(Resource resource)` Loads an environment from the specified `resource`.

Method Detail

### createEnvironment

    Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> 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

### createPackageContext

    Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createPackageContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent,
                                                                        List<String> 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 or null if lookup fails to locate a package
  See Also:
    `createClassifierContext(org.eclipse.ocl.Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E>, C)`, `createOperationContext(org.eclipse.ocl.Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E>, O)`, `createAttributeContext(org.eclipse.ocl.Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E>, P)`

### loadEnvironment

    Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> loadEnvironment(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<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createClassifierContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent,
                                                                           C 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<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createInstanceContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent,
                                                                         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)`, `OCLStandardLibrary.getOclAny()`

### createOperationContext

    Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createOperationContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent,
                                                                          O 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<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createAttributeContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent,
                                                                          P 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<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createEnvironment(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> 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<C,O,P,CLS,E> 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<C,O,P,CLS,E> createEvaluationEnvironment(EvaluationEnvironment<C,O,P,CLS,E> 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<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createEvaluationVisitor(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env,
                                                                                 EvaluationEnvironment<C,O,P,CLS,E> evalEnv,
                                                                                 Map<? extends CLS,? extends Set<? extends E>> extentMap)

  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.
    `extentMap` - the map of `Class`es to their extends
  Returns:
    the new evaluation visitor

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