## org.eclipse.emf.ocl.parser
Class EcoreEnvironment

    java.lang.Object
      org.eclipse.emf.ocl.parser.EcoreEnvironment

All Implemented Interfaces:
  Environment, PersistentEnvironment

Direct Known Subclasses:
  ReverseCompatibilityEnvironment

Deprecated. Use the `EcoreEnvironment` class, instead.

    @Deprecated
    public class EcoreEnvironment

extends Object
implements PersistentEnvironment

An Environment stores the variables created while evaluating an OCL expression, including self. It also stores the package, if the OCL package statement is used. Methods are provided for querying whether variable, property, operation, and association class reference names belong to the environment.

This environment provides persistence of dynamically-generated types via its `TypeResolver`'s resource. The default resolver implementation uses the most basic resource implementation, which does not support persistence, so clients requiring persistence should initialize it with their own resource. Persistence of `Variable`s is virtual: the variables are stored in a resource that reconstructs variables on-the-fly from data encoded in their URI fragments.

Nested Class Summary
`class` `EcoreEnvironment.Access` Deprecated.

Field Summary

Fields inherited from interface org.eclipse.emf.ocl.parser.Environment
`ANNOTATION_URI_BODY, ANNOTATION_URI_DEFINE, ANNOTATION_URI_DERIVE, ANNOTATION_URI_INIT`

Constructor Summary
`EcoreEnvironment(Environment parent)` Deprecated.
`EcoreEnvironment(EPackage pkg)` Deprecated. Create an environment, set the default package from a package statement, and set the package registry to the global package registry.
`EcoreEnvironment(EPackage pkg, EPackage.Registry reg)` Deprecated. Create an environment, set the default package from a package statement, and set the package registry

Method Summary
`boolean` `addElement(String name, Variable elem, boolean exp)` Deprecated. Adds a variable declaration to the environment.
`protected void` `collectStates(EClassifier owner, List pathPrefix, List states)` Deprecated. Implemented by subclasses to find all states in the specified owner type that match the given path name prefix and add them to the accumulator list.
`protected TypeResolver` `createTypeResolver()` Deprecated. Creates a new type resolver for use with this environment.
`void` `deleteElement(String name)` Deprecated. Removes a name when it goes out of scope.
`static EPackage` `findPackage(List packageNames)` Deprecated. Looks in the EMF registry for a package with the specified qualified package name.
`static EPackage` `findPackage(List packageNames, EPackage.Registry registry)` Deprecated. Looks in the given registry for a package with the specified qualified package name.
`EClass` `getAssociationClass(EReference reference)` Deprecated. Obtains the association class that the specified reference represents, as an `EClass`, if any.
`EClassifier` `getContextClassifier()` Deprecated. Obtains the context classifier of this environment.
`EOperation` `getContextOperation()` Deprecated. Obtains the context operation of this environment, if it is an operation context.
`EStructuralFeature` `getContextProperty()` Deprecated. Obtains the context property of this environment, if it is a property context.
`String` `getDescription(ENamedElement namedElement)` Deprecated. Default implementation just gets the name of the named element's `eClass` or, if it is an `ETypedElement`, the name of its type.
`EnvironmentFactory` `getFactory()` Deprecated. Obtains the factory that created me, or an appropriate default factory if I was not created using a factory.
`EList` `getMemberEnds(EClass associationClass)` Deprecated. Obtains the ends of the specified association class as a list of `EReference`s.
`static EClassifier` `getOCLCollectionType(EClassifier type, boolean isOrdered, boolean isUnique)` Deprecated. Obtains the appropriate OCL collection type for an `EClassifier`, according to the collection's orderedness and uniqueness.
`static EClassifier` `getOCLType(EClassifier type)` Deprecated. Obtains the appropriate OCL type for an `EClassifier`, if it corresponds to an OCL primitive type.
`static EClassifier` `getOCLType(ETypedElement typedElement)` Deprecated. Obtains the appropriate OCL type for an Ecore typed element, according to its type, multiplicity, orderedness, and uniqueness.
`Environment` `getParent()` Deprecated. get the parent environment
`EList` `getQualifiers(EStructuralFeature property)` Deprecated. Gets the qualifiers of an association end.
`Variable` `getSelfVariable()` Deprecated. Gets the self variable, looking it up in a parent environment if necessary.
`EList` `getSignals(EClassifier owner)` Deprecated. By default, return an empty list because Ecore does not support the modeling of signals.
`String` `getStateName(EObject state)` Deprecated. Ecore does not model states, so this method returns null.
`EList` `getStates(EClassifier owner, List pathPrefix)` Deprecated. Obtains the states matching the specified path prefix in the owner type by trying the `collectStates(org.eclipse.emf.ecore.EClassifier, java.util.List, java.util.List)` method on it and, recursively, its supertypes to find all matches.
`TypeResolver` `getTypeResolver()` Deprecated. Obtains a type resolver to be used to create (and cache) concrete bindings for the generic OCL types, based on the user model types provided by this environment.
`Collection` `getVariables()` Deprecated. Returns the `Variable`s registered in me explicitly.
`static String` `initialLower(ENamedElement elem)` Deprecated. Gets the name of a named `elem`ent with its initial character in lower case.
`boolean` `isAssociationClass(EClass eclass)` Deprecated. Determines whether the specified `eclass` is an association class.
`boolean` `isEmpty()` Deprecated. Is the environment empty?
`boolean` `isQuery(EOperation operation)` Deprecated. Determines whether the specified `operation` is a query operation.
`Variable` `lookup(String name)` Deprecated. returns the VariableDeclaration for a variable Looks in parent environment scope if not found in current scope.
`EClass` `lookupAssociationClassReference(EClassifier parentClassifier, String name)` Deprecated. Find reference in the specified class to the named association class.
`Variable` `lookupImplicitSourceForAssociationClass(String name)` Deprecated. Return the variable declaration in namedElements which references the named association class.
`Variable` `lookupImplicitSourceForOperation(String name, EList params)` Deprecated. Return the Variable declaration in namedElements which contains the name as an EOperation.
`Variable` `lookupImplicitSourceForProperty(String name)` Deprecated. Return the most appropriate matching variable to use as the implicit source of a call to the specified property.
`Variable` `lookupLocal(String name)` Deprecated. Returns the VariableDeclaration for a variable name.
`EOperation` `lookupOperation(EClassifier owner, String name, EList args)` Deprecated. Find the operation in the specified class.
`EPackage` `lookupPackage(List path)` Deprecated. Finds the EPackage corresponding to the path: name::...
`EClassifier` `lookupPathName(List names)` Deprecated. Finds the EClassifier corresponding to the path: name::...
`EStructuralFeature` `lookupProperty(EClassifier owner, String name)` Deprecated. Find a property defined or inherited by the specified classifier.
`EClass` `lookupSignal(EClassifier owner, String name, EList args)` Deprecated. Find a received signal in the specified classifier.
`void` `setContextOperation(EOperation operation)` Deprecated.
`void` `setContextProperty(EStructuralFeature property)` Deprecated.
`protected void` `setFactory(EnvironmentFactory factory)` Deprecated. Sets the factory that created me.
`void` `setParent(Environment env)` Deprecated. Set the parent environment
`void` `setSelfVariable(Variable var)` Deprecated. Sets the "self" variable that is the implicit source of any attribute, association end, or operation call.

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

Constructor Detail

### EcoreEnvironment

    public EcoreEnvironment(EPackage pkg)

  Deprecated.
  Create an environment, set the default package from a package statement, and set the package registry to the global package registry.

  Parameters:
    `pkg` -

### EcoreEnvironment

    public EcoreEnvironment(EPackage pkg,
                            EPackage.Registry reg)

  Deprecated.
  Create an environment, set the default package from a package statement, and set the package registry

  Parameters:
    `pkg` -
    `reg` -

### EcoreEnvironment

    public EcoreEnvironment(Environment parent)

  Deprecated.

Method Detail

### getOCLType

    public static EClassifier getOCLType(ETypedElement typedElement)

  Deprecated.
  Obtains the appropriate OCL type for an Ecore typed element, according to its type, multiplicity, orderedness, and uniqueness. The mapping is as follows:
  - single-valued: EDataTypes map to corresponding OCL primitives where possible. Not a collection type
  - multi-valued: element type mapped to OCL primitives where possible. Overall type maps to a collection type:
    - ordered, unique: ordered set type
    - ordered, non-unique: sequence type
    - non-ordered, unique: set type
    - non-ordered, non-unique: bag type

  Parameters:
    `typedElement` - the ECore typed element to get the OCL type for
  Returns:
    the corresponding OCL type
  See Also:
    `getOCLType(EClassifier)`, `getOCLCollectionType(EClassifier, boolean, boolean)`

### getOCLType

    public static EClassifier getOCLType(EClassifier type)

  Deprecated.
  Obtains the appropriate OCL type for an `EClassifier`, if it corresponds to an OCL primitive type.

  Parameters:
    `type` - the type to convert to an OCL type
  Returns:
    the corresponding OCL type

### getOCLCollectionType

    public static EClassifier getOCLCollectionType(EClassifier type,
                                                   boolean isOrdered,
                                                   boolean isUnique)

  Deprecated.
  Obtains the appropriate OCL collection type for an `EClassifier`, according to the collection's orderedness and uniqueness. The mapping is as follows:
  - ordered, unique: ordered set type
  - ordered, non-unique: sequence type
  - non-ordered, unique: set type
  - non-ordered, non-unique: bag type

  Note that the collection's element `type` is mapped to an OCL primitive type where possible.

  Parameters:
    `type` - the type to get the corresponding OCL collection type for
    `isOrdered` - whether the OCL type should be ordered
    `isUnique` - whether the OCL type should be unique
  Returns:
    the corresponding OCL type
  See Also:
    `getOCLType(EClassifier)`

### getFactory

    public EnvironmentFactory getFactory()

  Deprecated.
  Description copied from interface: `Environment`
  Obtains the factory that created me, or an appropriate default factory if I was not created using a factory. This factory can be used to create nested environments within me.

  Specified by:
    `getFactory` in interface `Environment`
  Returns:
    my originating factory
  See Also:
    `EnvironmentFactory.createEnvironment(Environment)`

### setFactory

    protected void setFactory(EnvironmentFactory factory)

  Deprecated.
  Sets the factory that created me. This method should only be invoked by that factory.

  Parameters:
    `factory` - my originating factory

### setParent

    public void setParent(Environment env)

  Deprecated.
  Set the parent environment

  Specified by:
    `setParent` in interface `Environment`
  Parameters:
    `env` -

### getParent

    public Environment getParent()

  Deprecated.
  get the parent environment

  Specified by:
    `getParent` in interface `Environment`
  Returns:
    Environment

### getContextClassifier

    public EClassifier getContextClassifier()

  Deprecated.
  Description copied from interface: `Environment`
  Obtains the context classifier of this environment.

  Specified by:
    `getContextClassifier` in interface `Environment`
  Returns:
    the context classifier

### getContextOperation

    public EOperation getContextOperation()

  Deprecated.
  Description copied from interface: `Environment`
  Obtains the context operation of this environment, if it is an operation context.

  Specified by:
    `getContextOperation` in interface `Environment`
  Returns:
    the context operation, or `null` if this is not an operation environment

### setContextOperation

    public void setContextOperation(EOperation operation)

  Deprecated.

### getContextProperty

    public EStructuralFeature getContextProperty()

  Deprecated.
  Description copied from interface: `Environment`
  Obtains the context property of this environment, if it is a property context.

  Specified by:
    `getContextProperty` in interface `Environment`
  Returns:
    the context property, or `null` if this is not a property environment

### setContextProperty

    public void setContextProperty(EStructuralFeature property)

  Deprecated.

### getTypeResolver

    public TypeResolver getTypeResolver()

  Deprecated.
  Description copied from interface: `PersistentEnvironment`
  Obtains a type resolver to be used to create (and cache) concrete bindings for the generic OCL types, based on the user model types provided by this environment.

  Specified by:
    `getTypeResolver` in interface `PersistentEnvironment`
  Returns:
    the type resolver

### createTypeResolver

    protected TypeResolver createTypeResolver()

  Deprecated.
  Creates a new type resolver for use with this environment.

  Returns:
    a new type resolver

### isEmpty

    public boolean isEmpty()

  Deprecated.
  Is the environment empty?

  Specified by:
    `isEmpty` in interface `Environment`
  Returns:
    boolean

### lookupLocal

    public Variable lookupLocal(String name)

  Deprecated.
  Returns the VariableDeclaration for a variable name. Does not look in parent environment scopes.

  Specified by:
    `lookupLocal` in interface `Environment`
  Parameters:
    `name` -
  Returns:
    VariableDeclaration

### lookup

    public Variable lookup(String name)

  Deprecated.
  returns the VariableDeclaration for a variable Looks in parent environment scope if not found in current scope.

  Specified by:
    `lookup` in interface `Environment`
  Parameters:
    `name` -
  Returns:
    VariableDeclaration

### lookupPackage

    public EPackage lookupPackage(List path)

  Deprecated.
  Description copied from interface: `Environment`
  Finds the EPackage corresponding to the path: name::...::name If no EPackage is found, return `null`.

  Specified by:
    `lookupPackage` in interface `Environment`
  Parameters:
    `path` - the path name
  Returns:
    the package, or `null` if not found

### lookupPathName

    public EClassifier lookupPathName(List names)

  Deprecated.
  Finds the EClassifier corresponding to the path: name::...::name If no EClassifier is found, return null.

  Specified by:
    `lookupPathName` in interface `Environment`
  Parameters:
    `names` -
  Returns:
    EClassifier

### setSelfVariable

    public void setSelfVariable(Variable var)

  Deprecated.
  Description copied from interface: `Environment`
  Sets the "self" variable that is the implicit source of any attribute, association end, or operation call.

  Specified by:
    `setSelfVariable` in interface `Environment`
  Parameters:
    `var` - the "self" variable

### getSelfVariable

    public Variable getSelfVariable()

  Deprecated.
  Description copied from interface: `Environment`
  Gets the self variable, looking it up in a parent environment if necessary.

  Specified by:
    `getSelfVariable` in interface `Environment`
  Returns:
    the self variable, or `null` if none (which should not happen as there is always some classifier context)

### addElement

    public boolean addElement(String name,
                              Variable elem,
                              boolean exp)

  Deprecated.
  Adds a variable declaration to the environment. If the name is null, then a new unique temporary name is generated.

  Specified by:
    `addElement` in interface `Environment`
  Parameters:
    `name` -
    `elem` - -- variable declaration
    `exp` - -- is the variable implicit?
  Returns:
    - boolean

### deleteElement

    public void deleteElement(String name)

  Deprecated.
  Removes a name when it goes out of scope.

  Specified by:
    `deleteElement` in interface `Environment`
  Parameters:
    `name` -

### getVariables

    public Collection getVariables()

  Deprecated.
  Description copied from interface: `Environment`
  Returns the `Variable`s registered in me explicitly.

  Specified by:
    `getVariables` in interface `Environment`
  Returns:
    my variable declarations

### lookupOperation

    public EOperation lookupOperation(EClassifier owner,
                                      String name,
                                      EList args)

  Deprecated.
  Description copied from interface: `Environment`
  Find the operation in the specified class.

  Specified by:
    `lookupOperation` in interface `Environment`
  Parameters:
    `owner` - the owner type of the called operation
    `name` - the name of the called operation
    `args` - the arguments (as `OCLExpression`s) passed to the operation
  Returns:
    the matching operation, or `null` if not found

### lookupSignal

    public EClass lookupSignal(EClassifier owner,
                               String name,
                               EList args)

  Deprecated.
  Description copied from interface: `Environment`
  Find a received signal in the specified classifier.

  Specified by:
    `lookupSignal` in interface `Environment`
  Parameters:
    `owner` - the owner type of the signal reception
    `name` - the name of the signal
    `args` - the arguments (as `OCLExpression`s) passed in the signal
  Returns:
    the matching signal, or `null` if not found

### getSignals

    public EList getSignals(EClassifier owner)

  Deprecated.
  By default, return an empty list because Ecore does not support the modeling of signals.

  Specified by:
    `getSignals` in interface `Environment`
  Parameters:
    `owner` - the owner type of the signal receptions
  Returns:
    the available signals (as `EClass`es), or an empty list if none

### lookupProperty

    public EStructuralFeature lookupProperty(EClassifier owner,
                                             String name)

  Deprecated.
  Description copied from interface: `Environment`
  Find a property defined or inherited by the specified classifier.

  Specified by:
    `lookupProperty` in interface `Environment`
  Parameters:
    `owner` - the owner of the property that we are looking for, or `null` to find an implicit owner type
    `name` - the property name
  Returns:
    the property, or `null` if it could not be found

### lookupAssociationClassReference

    public EClass lookupAssociationClassReference(EClassifier parentClassifier,
                                                  String name)

  Deprecated.
  Description copied from interface: `Environment`
  Find reference in the specified class to the named association class.

  Specified by:
    `lookupAssociationClassReference` in interface `Environment`
  Parameters:
    `parentClassifier` - the referencing class to search
    `name` - the association class name (with an initial lower case as per the OCL convention)
  Returns:
    the association class, or `null` if the specified `parent` classifier does not have any references implemented by the named association class

### initialLower

    public static String initialLower(ENamedElement elem)

  Deprecated.
  Gets the name of a named `elem`ent with its initial character in lower case.

  Parameters:
    `elem` - a named element
  Returns:
    the element's name, with an initial lower case letter

### getStates

    public EList getStates(EClassifier owner,
                           List pathPrefix)

  Deprecated.
  Obtains the states matching the specified path prefix in the owner type by trying the `collectStates(org.eclipse.emf.ecore.EClassifier, java.util.List, java.util.List)` method on it and, recursively, its supertypes to find all matches. For implicit (`null`) owners, looks up the innermost-scoped variable as the implicit source and tries again on this variable's type.

  To extend this implementation, override the `collectStates(org.eclipse.emf.ecore.EClassifier, java.util.List, java.util.List)` method.

  Specified by:
    `getStates` in interface `Environment`
  Parameters:
    `owner` - the classifier for which states are being sought. Can be `null` in the case of an oclIsInState() call on an implicit target
    `pathPrefix` - partial path name of the states being sought. This can be empty to find the first level of state names
  Returns:
    the list of all possible states directly contained in the namespace indicated by the path prefix (i.e., only one level of state nesting)

### collectStates

    protected void collectStates(EClassifier owner,
                                 List pathPrefix,
                                 List states)

  Deprecated.
  Implemented by subclasses to find all states in the specified owner type that match the given path name prefix and add them to the accumulator list. The default implementation does nothing, as Ecore does not model states.

  Implementors must only provide the states defined directly in the namespace indicated by the path prefix (i.e., only one level).

  Parameters:
    `owner` - the owner type
    `pathPrefix` - partial
    `states` - a list of states directly owned by the namespace indicated by path prefix, within the owner type

### getStateName

    public String getStateName(EObject state)

  Deprecated.
  Ecore does not model states, so this method returns null. Environments that support UML states must override this implementation.

  Specified by:
    `getStateName` in interface `Environment`
  Parameters:
    `state` - representation of a UML state
  Returns:
    its simple name

### lookupImplicitSourceForProperty

    public Variable lookupImplicitSourceForProperty(String name)

  Deprecated.
  Description copied from interface: `Environment`
  Return the most appropriate matching variable to use as the implicit source of a call to the specified property. Variables are returned based on inner-most scope first.

  Specified by:
    `lookupImplicitSourceForProperty` in interface `Environment`
  Parameters:
    `name` - the property name
  Returns:
    the matching variable

### lookupImplicitSourceForAssociationClass

    public Variable lookupImplicitSourceForAssociationClass(String name)

  Deprecated.
  Description copied from interface: `Environment`
  Return the variable declaration in namedElements which references the named association class. Variables are returned based on inner-most scope first.

  Specified by:
    `lookupImplicitSourceForAssociationClass` in interface `Environment`
  Parameters:
    `name` - the association class name to seek
  Returns:
    the matching variable declaration, or `null` if none is found

### findPackage

    public static EPackage findPackage(List packageNames)

  Deprecated.
  Looks in the EMF registry for a package with the specified qualified package name. Uses the global package registry.

  Parameters:
    `packageNames` - the qualified package name
  Returns:
    the matching EPackage, or `null` if not found

### findPackage

    public static EPackage findPackage(List packageNames,
                                       EPackage.Registry registry)

  Deprecated.
  Looks in the given registry for a package with the specified qualified package name.

  Parameters:
    `packageNames` - the qualified package name
    `registry` - the EPackage.Registry to look in
  Returns:
    the matching EPackage, or `null` if not found

### lookupImplicitSourceForOperation

    public Variable lookupImplicitSourceForOperation(String name,
                                                     EList params)
                                              throws SemanticException

  Deprecated.
  Description copied from interface: `Environment`
  Return the Variable declaration in namedElements which contains the name as an EOperation. Variables are returned based on inner-most scope first.

  Specified by:
    `lookupImplicitSourceForOperation` in interface `Environment`
  Returns:
    the matching variable declaration
  Throws:
    `SemanticException`

### getDescription

    public String getDescription(ENamedElement namedElement)

  Deprecated.
  Default implementation just gets the name of the named element's `eClass` or, if it is an `ETypedElement`, the name of its type.

  Specified by:
    `getDescription` in interface `Environment`
  Parameters:
    `namedElement` - a named element obtained by adaptation of a user model element
  Returns:
    the named element's description

### isQuery

    public boolean isQuery(EOperation operation)

  Deprecated.
  Determines whether the specified `operation` is a query operation. Note that an environment that correctly supports query operations would need to supply appropriately annotated `EOperation`s or otherwise override this method.

  Specified by:
    `isQuery` in interface `Environment`
  Parameters:
    `operation` - an operation
  Returns:
    whether it is a query operation. An `EOperation` that is not annotated is considered to be a query by default

### isAssociationClass

    public boolean isAssociationClass(EClass eclass)

  Deprecated.
  Determines whether the specified `eclass` is an association class. Note that an environment that correctly supports association classes would need to supply appropriately annotated `EClass`es.

  Specified by:
    `isAssociationClass` in interface `Environment`
  Parameters:
    `eclass` - an Ecore class
  Returns:
    whether it is an association class

### getAssociationClass

    public EClass getAssociationClass(EReference reference)

  Deprecated.
  Obtains the association class that the specified reference represents, as an `EClass`, if any. This gets the "class" aspect of the association class, for which the reference represents the "association" aspect. Note that an environment that correctly supports association classes would need to supply appropriately annotated `EReference`s.

  Specified by:
    `getAssociationClass` in interface `Environment`
  Parameters:
    `reference` - a reference
  Returns:
    the association class, or `null` if the reference does not represent an association class

### getMemberEnds

    public EList getMemberEnds(EClass associationClass)

  Deprecated.
  Obtains the ends of the specified association class as a list of `EReference`s. Note that an environment that correctly supports association classes would need to supply appropriately annotated `EClass`es.

  Specified by:
    `getMemberEnds` in interface `Environment`
  Parameters:
    `associationClass` - an EClass representing an association class
  Returns:
    the `EReference`s representing its member ends (the association roles)

### getQualifiers

    public EList getQualifiers(EStructuralFeature property)

  Deprecated.
  Gets the qualifiers of an association end. Note that an environment that correctly supports association end qualifiers would need to supply appropriately annotated `EReference`s.

  Specified by:
    `getQualifiers` in interface `Environment`
  Parameters:
    `property` - a property of the model class
  Returns:
    the qualifiers (as a list of `EStructuralFeature`s, or an empty list if the property has no qualifiers

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