## org.eclipse.ocl.uml
Class UMLEnvironment

    java.lang.Object
      org.eclipse.ocl.lpg.AbstractBasicEnvironment
          org.eclipse.ocl.AbstractEnvironment<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject>
              org.eclipse.ocl.uml.UMLEnvironment

All Implemented Interfaces:
  Environment<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject>, Environment.Internal<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject>, Environment.Lookup<Package,Classifier,Operation,Property>, BasicEnvironment, Customizable, Adaptable

    public class UMLEnvironment

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

Implementation of the `Environment` for parsing OCL expressions on UML models. The `UMLEnvironment` uses a client-supplied resource set to look up UML `Package`s in UML resources. It also uses an `EPackage` registry to find the corresponding Ecore definitions of packages when evaluating expressions on instances of the UML model (in the case of evaluation on UML2-generated API objects).

Nested Class Summary

Nested classes/interfaces inherited from class org.eclipse.ocl.AbstractEnvironment
`AbstractEnvironment.VariableEntry`

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

Field Summary

Fields inherited from interface org.eclipse.ocl.Environment
`OCL_NAMESPACE_URI, RESULT_VARIABLE_NAME, SELF_VARIABLE_NAME`

Constructor Summary
`protected` `UMLEnvironment(Environment<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject> parent)` Initializes me with a parent environment.
`protected` `UMLEnvironment(EPackage.Registry registry, ResourceSet rset)` Initializes me with a package registry for looking up the Ecore representations of UML packages and a resource set for looking up UML packages in UML resources.
`protected` `UMLEnvironment(EPackage.Registry registry, ResourceSet rset, Resource resource)` Initializes me with a package registry for looking up the Ecore representations of UML packages, a resource set for looking up UML packages in UML resources, and a resource from which to load myself.

Method Summary
`protected TypeResolver<Classifier,Operation,Property>` `createTypeResolver()` Deprecated. Override the `createTypeResolver(Resource)` method, instead, handling the case where the resource is `null`
`protected TypeResolver<Classifier,Operation,Property>` `createTypeResolver(Resource resource)` Creates a new type resolver for use with this environment.
`Property` `defineAttribute(Classifier owner, Variable<Classifier,Parameter> variable, Constraint constraint)` In processing an additional attribute definition, constructs the property and associates it with its definition constraint.
`Operation` `defineOperation(Classifier owner, String name, Classifier type, List<Variable<Classifier,Parameter>> params, Constraint constraint)` In processing an additional operation definition, constructs the operation and associates it with its definition constraint.
`protected void` `findNonNavigableAssociationEnds(Classifier classifier, String name, List<Property> ends)` Searches for non-navigable association ends with the specified `name` at the given `classifier`'s end of an association.
`protected void` `findUnnamedAssociationEnds(Classifier classifier, String name, List<Property> ends)` Searches for unnamed association ends using the specified `name` at the given `classifier`'s end of an association.
`Constraint` `getDefinition(Object feature)` Obtains the definition constraint of the specified feature, if it is an additional attribute or operation defined via an OCL constraint.
`EnvironmentFactory<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject>` `getFactory()` Obtains the factory that created me, or an appropriate default factory if I was not created using a factory.
`FormattingHelper` `getFormatter()` I provide a custom formatting helper for UML metamodel.
`OCLFactory` `getOCLFactory()` Obtains a factory for the creation of types that are parameterized by model elements.
`OCLStandardLibrary<Classifier>` `getOCLStandardLibrary()` Obtains the collection of core types representing the OCL Standard Library.
`protected ResourceSet` `getResourceSet()` Obtains the resource set in which I look for UML packages when resolving package names.
`List<State>` `getStates(Classifier owner, List<String> pathPrefix)` Retrieves a list of all possible states of the specified `owner` whose paths are prefixed by the specified partial name.
`TypeResolver<Classifier,Operation,Property>` `getTypeResolver()` 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.
`protected Package` `getUMLMetamodel()` Obtains the UML metamodel library, loaded in my resource set.
`UMLReflection<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint>` `getUMLReflection()` Obtains a utility for for reflection on the UML metaclasses that are used by the OCL abstract syntax.
`boolean` `isInPostcondition(OCLExpression<Classifier> exp)` Checks whether the specified OCL expression is in an operation postcondition constraint.
`protected boolean` `isUnnamed(Property associationEnd)` Queries whether the specified association end has no name.
`Classifier` `lookupClassifier(List<String> names)` Finds the classifier identified by the specified sequence of names (a qualified name).
`Package` `lookupPackage(List<String> path)` Finds the package identified by the specified sequence of names (a qualified name). Implements the inherited specification by looking in my resource set for a resource containing the specified package.
`protected void` `setFactory(EnvironmentFactory<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject> factory)` Sets the factory that created me.
`void` `setParent(Environment<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject> env)` Sets my parent environment.
`void` `undefine(Object feature)` Removes the definition of an additional operation or property.

Methods inherited from class org.eclipse.ocl.AbstractEnvironment

`addedVariable, addElement, addHelperOperation, addHelperProperty, addOperation, addProperty, deleteElement, dispose, getAdditionalAttributes, getAdditionalOperations, getBodyCondition, getContextClassifier, getContextOperation, getContextPackage, getContextProperty, getDeriveConstraint, getInitConstraint, getInternalParent, getParent, getResource, getSelfVariable, getVariables, initialLower, isEmpty, lookup, lookupAssociationClassReference, lookupImplicitSourceForAssociationClass, lookupImplicitSourceForOperation, lookupImplicitSourceForProperty, lookupImplicitSourceForSignal, lookupImplicitSourceForState, lookupLocal, lookupOperation, lookupProperty, lookupSignal, lookupState, notOK, removedVariable, setBodyCondition, setContextOperation, setContextPackage, setContextProperty, setDeriveConstraint, setInitConstraint, setInternalParent, setParent, setSelfVariable, tryLookupAssociationClassReference, tryLookupClassifier, tryLookupOperation, tryLookupPackage, tryLookupProperty, tryLookupSignal`

Methods inherited from class org.eclipse.ocl.lpg.AbstractBasicEnvironment

`analyzerError, analyzerError, analyzerError, analyzerWarning, basicGetOptions, clearOptions, createDefaultProblemHandler, getAdapter, getASTMapping, getASTNodeToCSTNodeMap, getOptions, getParser, getProblemHandler, getValue, initASTMapping, isEnabled, lexerError, parserError, problem, putOptions, removeOption, removeOptions, setASTNodeToCSTNodeMap, setOption, setParent, setParser, setProblemHandler, utilityError, validatorError`

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

Methods inherited from interface org.eclipse.ocl.lpg.BasicEnvironment
`analyzerError, analyzerError, analyzerError, analyzerWarning, getASTMapping, getParser, getProblemHandler, initASTMapping, lexerError, parserError, problem, setParser, setProblemHandler, utilityError, validatorError`

Methods inherited from interface org.eclipse.ocl.util.Adaptable
`getAdapter`

Methods inherited from interface org.eclipse.ocl.options.Customizable
`clearOptions, getOptions, getValue, isEnabled, putOptions, removeOption, removeOptions, setOption`

Constructor Detail

### UMLEnvironment

    protected UMLEnvironment(EPackage.Registry registry,
                             ResourceSet rset)

  Initializes me with a package registry for looking up the Ecore representations of UML packages and a resource set for looking up UML packages in UML resources.

  Parameters:
    `registry` - the Ecore package registry to use
    `rset` - the resource set to use

### UMLEnvironment

    protected UMLEnvironment(EPackage.Registry registry,
                             ResourceSet rset,
                             Resource resource)

  Initializes me with a package registry for looking up the Ecore representations of UML packages, a resource set for looking up UML packages in UML resources, and a resource from which to load myself.

  Parameters:
    `registry` - the Ecore package registry to use
    `rset` - the resource set to use
    `resource` - my resource for persistence

### UMLEnvironment

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

  Initializes me with a parent environment. I inherit my package registry, resource set, and resource from it.

  Parameters:
    `parent` - my parent environment

Method Detail

### getFactory

    public EnvironmentFactory<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject> getFactory()

  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.

  Returns:
    my originating factory
  See Also:
    `EnvironmentFactory.createEnvironment(Environment)`

### setFactory

    protected void setFactory(EnvironmentFactory<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject> factory)

  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<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject> env)

  Description copied from interface: `Environment`
  Sets my parent environment. The parent environment should not generally be set to `null` if it was not already `null`.

  Parameters:
    `env` - my new parent environment

### getOCLStandardLibrary

    public OCLStandardLibrary<Classifier> getOCLStandardLibrary()

  Description copied from interface: `Environment`
  Obtains the collection of core types representing the OCL Standard Library. These are the singleton or generic instances of the OCL-defined classifiers such as `OclAny`, `Collection(T)`, etc. Implementers of OCL metamodel bindings are encouraged to share a single instance of the standard library amonst all of the `Environment`s constructed by a particular `EnvironmentFactory`.

  Returns:
    the OCL Standard Library implementation for this environment

### getResourceSet

    protected final ResourceSet getResourceSet()

  Obtains the resource set in which I look for UML packages when resolving package names.

  Returns:
    my resource set

### getUMLMetamodel

    protected Package getUMLMetamodel()

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

  Returns:
    the UML metamodel

### getTypeResolver

    public TypeResolver<Classifier,Operation,Property> getTypeResolver()

  Description copied from interface: `Environment`
  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. These are the types that are parameterized by particular user model elements: collections of particular classifiers, meta-types for particular classifiers, message types for particular operations or signals, and tuple types.

  Returns:
    the type resolver

### getOCLFactory

    public OCLFactory getOCLFactory()

  Description copied from interface: `Environment`
  Obtains a factory for the creation of types that are parameterized by model elements. This type factory must create types that are instances of the metaclass describing classifiers in the client metamodel.

  Returns:
    the appropriate type factory

### getUMLReflection

    public UMLReflection<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint> getUMLReflection()

  Description copied from interface: `Environment`
  Obtains a utility for for reflection on the UML metaclasses that are used by the OCL abstract syntax.

  Returns:
    the appropriate reflection instance

### createTypeResolver

    @Deprecated
    protected TypeResolver<Classifier,Operation,Property> createTypeResolver()

  Deprecated. Override the `createTypeResolver(Resource)` method, instead, handling the case where the resource is `null`

  Creates a new type resolver for use with this environment, persisted in a default resource.

  Returns:
    a new type resolver

### createTypeResolver

    protected TypeResolver<Classifier,Operation,Property> createTypeResolver(Resource resource)

  Creates a new type resolver for use with this environment.

  Subclasses may override.

  Parameters:
    `resource` - the resource for the type resolver's persistence
  Returns:
    a new type resolver
  Since:
    1.2

### lookupPackage

    public Package lookupPackage(List<String> path)

  Finds the package identified by the specified sequence of names (a qualified name).

  Implements the inherited specification by looking in my resource set for a resource containing the specified package.

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

### lookupClassifier

    public Classifier lookupClassifier(List<String> names)

  Description copied from interface: `Environment`
  Finds the classifier identified by the specified sequence of names (a qualified name).

  Parameters:
    `names` - the qualified name
  Returns:
    the matching classifier, or `null` if not found

### findNonNavigableAssociationEnds

    protected void findNonNavigableAssociationEnds(Classifier classifier,
                                                   String name,
                                                   List<Property> ends)

  Description copied from class: `AbstractEnvironment`
  Searches for non-navigable association ends with the specified `name` at the given `classifier`'s end of an association. Subclasses should reimplement this method if they support non-navigable association ends.

  Overrides:
    `findNonNavigableAssociationEnds` in class `AbstractEnvironment<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject>`
  Parameters:
    `classifier` - a classifier at an association end
    `name` - the non-navigable end name to look for
    `ends` - collects the ends found by the subclass implementation

### findUnnamedAssociationEnds

    protected void findUnnamedAssociationEnds(Classifier classifier,
                                              String name,
                                              List<Property> ends)

  Description copied from class: `AbstractEnvironment`
  Searches for unnamed association ends using the specified `name` at the given `classifier`'s end of an association. Subclasses should reimplement this method if they support non-navigable association ends. It is expected, in OCL, that the supplied `name` is the initial-lower-case name of the type of the unnamed end.

  Overrides:
    `findUnnamedAssociationEnds` in class `AbstractEnvironment<Package,Classifier,Operation,Property,EnumerationLiteral,Parameter,State,CallOperationAction,SendSignalAction,Constraint,Class,EObject>`
  Parameters:
    `classifier` - a classifier at an association end
    `name` - the initial-lower classifier name to look for
    `ends` - collects the ends found by the subclass implementation

### isUnnamed

    protected boolean isUnnamed(Property associationEnd)

  Queries whether the specified association end has no name.

  Parameters:
    `associationEnd` - an association end
  Returns:
    whether it is unnamed

### getStates

    public List<State> getStates(Classifier owner,
                                 List<String> pathPrefix)

  Description copied from interface: `Environment`
  Retrieves a list of all possible states of the specified `owner` whose paths are prefixed by the specified partial name. If the owner is `null`, then the target of the `oclIsInState()` operation call is implicit and must be looked up in the usual way for implicit operation call targets. This method is used for content-assist.

  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)

### defineAttribute

    public Property defineAttribute(Classifier owner,
                                    Variable<Classifier,Parameter> variable,
                                    Constraint constraint)

  Description copied from interface: `Environment`
  In processing an additional attribute definition, constructs the property and associates it with its definition constraint. The operation definition is local to this environment.

  Parameters:
    `owner` - the context classifier of the property definition constraint
    `variable` - the name and type of the property (conveniently encapsulated in a variable)
    `constraint` - the definition constraint
  Returns:
    the defined property

### defineOperation

    public Operation defineOperation(Classifier owner,
                                     String name,
                                     Classifier type,
                                     List<Variable<Classifier,Parameter>> params,
                                     Constraint constraint)

  Description copied from interface: `Environment`
  In processing an additional operation definition, constructs the operation and associates it with its definition constraint. The operation definition is local to this environment.

  Parameters:
    `owner` - the context classifier of the property definition constraint
    `name` - the operation name
    `params` - the names and types of the parameters, if any (conveniently encapsulated in variables)
    `constraint` - the definition constraint
  Returns:
    the defined operation

### undefine

    public void undefine(Object feature)

  Description copied from interface: `Environment`
  Removes the definition of an additional operation or property.

  Parameters:
    `feature` - an additional property or operation

### getDefinition

    public Constraint getDefinition(Object feature)

  Description copied from interface: `Environment`
  Obtains the definition constraint of the specified feature, if it is an additional attribute or operation defined via an OCL constraint.

  Parameters:
    `feature` - a property or operation
  Returns:
    the definition constraint that defines it, or `null` if this feature is not defined by OCL

### isInPostcondition

    public boolean isInPostcondition(OCLExpression<Classifier> exp)

  Description copied from interface: `Environment`
  Checks whether the specified OCL expression is in an operation postcondition constraint. This is used in validating the usage of constructs that are only valid in postconditions (e.g., `oclIsNew()`).

  Parameters:
    `exp` - an OCL expression
  Returns:
    `true` if it is in a postcondition constraint; `false`, otherwise (including case of no constraint at all)

### getFormatter

    public FormattingHelper getFormatter()

  I provide a custom formatting helper for UML metamodel.

  Specified by:
    `getFormatter` in interface `BasicEnvironment`
  Overrides:
    `getFormatter` in class `AbstractBasicEnvironment`
  Returns:
    non-null message formatter
  Since:
    1.2

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