## org.eclipse.ocl.uml
Class UMLEnvironmentFactory

    java.lang.Object
      org.eclipse.ocl.AbstractEnvironmentFactory<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject>
          org.eclipse.ocl.uml.UMLEnvironmentFactory

All Implemented Interfaces:
  EnvironmentFactory<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject>, Adaptable

    public class UMLEnvironmentFactory

extends AbstractEnvironmentFactory<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject>

Implementation of the `EnvironmentFactory` for parsing OCL expressions on UML models.

The parser environments created by the UML environment factory support OCL expressions at both the metamodel (M2) and user model (M1) levels. For user model constraints, use the classifier in the model as the context classifier in invocations of an `OCL` or an `OCLHelper` created by it. For metamodel OCL (used, for example, to query the user model, itself) use the metaclass of any element in the user model as the context classifier. A convenient way to obtain this metaclass is via the `OCLUMLUtil.getMetaclass(org.eclipse.uml2.uml.Element)` method.

Nested Class Summary

Nested classes/interfaces inherited from interface org.eclipse.ocl.EnvironmentFactory
`EnvironmentFactory.Lookup<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>`

Constructor Summary
`UMLEnvironmentFactory()` Initializes me.
`UMLEnvironmentFactory(EPackage.Registry registry, ResourceSet rset)` Initializes me with a resource set and package registry that the environments I create will use to look up UML packages and their Ecore definitions.
`UMLEnvironmentFactory(ResourceSet rset)` Initializes me with a resource set that the environments I create will use (along with its package registry) to look up UML packages and their Ecore definitions.

Method Summary
`UMLEnvironment` `createEnvironment()` Creates a root environment, in which package contexts and/or classifier contexts will be created as nested environments.

`Environment<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject>`

`createEnvironment(Environment<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject> parent)`
Creates a child environment of a specified `parent`, for definition of nested scopes.

`EvaluationEnvironment<Classifier,Operation,Property,Class,EObject>` `createEvaluationEnvironment()` Creates a new evaluation environment to track the values of variables in an OCL expression as it is evaluated.
`EvaluationEnvironment<Classifier,Operation,Property,Class,EObject>` `createEvaluationEnvironment(EvaluationEnvironment<Classifier,Operation,Property,Class,EObject> parent)` Creates a new evaluation environment as a nested environment of the specified `parent`.
`protected Classifier` `getClassifier(Object context)` Obtains client metamodel's classifier for the specified `context` object, which may be an instance of a classifier in the user model or may actually be a classifier in the user model.
`EPackage.Registry` `getEPackageRegistry()` Obtains the package registry that the environment I create will use to look up the Ecore definitions of UML packages.
`ResourceSet` `getResourceSet()` Obtains the resource set that the environment I create will use to find UML packages.
`protected Package` `getUMLMetamodel()` Obtains the UML metamodel library, loaded in my resource set.
`Environment<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject>` `loadEnvironment(Resource resource)` Loads an environment from the specified `resource`.
`protected Package` `lookupPackage(List<String> pathname)` Looks up the package identified by the specified qualified name by whatever means is appropriate to the particular environment implementation.

Methods inherited from class org.eclipse.ocl.AbstractEnvironmentFactory
`createAttributeContext, createClassifierContext, createEvaluationVisitor, createInstanceContext, createOperationContext, createPackageContext, createPackageContext, getAdapter, isEvaluationTracingEnabled, setEvaluationTracingEnabled`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### UMLEnvironmentFactory

    public UMLEnvironmentFactory()

  Initializes me. Environments that I create will use a private resource set and its package registry to look up UML packages and their Ecore definitions.

### UMLEnvironmentFactory

    public UMLEnvironmentFactory(ResourceSet rset)

  Initializes me with a resource set that the environments I create will use (along with its package registry) to look up UML packages and their Ecore definitions.

  Parameters:
    `rset` - my resource set (must not by `null`)

### UMLEnvironmentFactory

    public UMLEnvironmentFactory(EPackage.Registry registry,
                                 ResourceSet rset)

  Initializes me with a resource set and package registry that the environments I create will use to look up UML packages and their Ecore definitions.

  Parameters:
    `registry` - my package registry (must not be `null`)
    `rset` - my resource set (must not be `null`)

Method Detail

### createEnvironment

    public UMLEnvironment createEnvironment()

  Description copied from interface: `EnvironmentFactory`
  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

    public Environment<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject> loadEnvironment(Resource resource)

  Description copied from interface: `EnvironmentFactory`
  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

### getEPackageRegistry

    public final EPackage.Registry getEPackageRegistry()

  Obtains the package registry that the environment I create will use to look up the Ecore definitions of UML packages.

  Returns:
    my package registry

### getResourceSet

    public final ResourceSet getResourceSet()

  Obtains the resource set that the environment I create will use to find UML packages.

  Returns:
    my resource set

### getUMLMetamodel

    protected Package getUMLMetamodel()

  Obtains the UML metamodel library, loaded in my resource set.

  Returns:
    the UML metamodel

### lookupPackage

    protected Package lookupPackage(List<String> pathname)

  Description copied from class: `AbstractEnvironmentFactory`
  Looks up the package identified by the specified qualified name by whatever means is appropriate to the particular environment implementation.

  Specified by:
    `lookupPackage` in class `AbstractEnvironmentFactory<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject>`
  Parameters:
    `pathname` - the qualified name of the package to find
  Returns:
    the matching package, or `null` if none is found

### getClassifier

    protected Classifier getClassifier(Object context)

  Description copied from class: `AbstractEnvironmentFactory`
  Obtains client metamodel's classifier for the specified `context` object, which may be an instance of a classifier in the user model or may actually be a classifier in the user model.

  Specified by:
    `getClassifier` in class `AbstractEnvironmentFactory<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject>`
  Parameters:
    `context` - a context object or classifier
  Returns:
    the user model's classifier for this context object, or the context itself if it is a classifier

### createEnvironment

    public Environment<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject> createEnvironment(Environment<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject> parent)

  Description copied from interface: `EnvironmentFactory`
  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<Classifier,Operation,Property,Class,EObject> createEvaluationEnvironment()

  Description copied from interface: `EnvironmentFactory`
  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

    public EvaluationEnvironment<Classifier,Operation,Property,Class,EObject> createEvaluationEnvironment(EvaluationEnvironment<Classifier,Operation,Property,Class,EObject> parent)

  Description copied from interface: `EnvironmentFactory`
  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

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