org.eclipse.ocl.uml
Class UMLEnvironmentFactory

java.lang.Object
  extended by org.eclipse.ocl.AbstractEnvironmentFactory<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject>
      extended by org.eclipse.ocl.uml.UMLEnvironmentFactory
All Implemented Interfaces:
EnvironmentFactory<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject>, Adaptable

public class UMLEnvironmentFactory
extends AbstractEnvironmentFactory<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.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.

Author:
Christian W. Damus (cdamus)

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(org.eclipse.emf.ecore.EPackage.Registry registry, org.eclipse.emf.ecore.resource.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(org.eclipse.emf.ecore.resource.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<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> createEnvironment(Environment<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> parent)
          Creates a child environment of a specified parent, for definition of nested scopes.
 EvaluationEnvironment<org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> createEvaluationEnvironment()
          Creates a new evaluation environment to track the values of variables in an OCL expression as it is evaluated.
 EvaluationEnvironment<org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> createEvaluationEnvironment(EvaluationEnvironment<org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> parent)
          Creates a new evaluation environment as a nested environment of the specified parent.
protected  org.eclipse.uml2.uml.Classifier getClassifier(java.lang.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.
 org.eclipse.emf.ecore.EPackage.Registry getEPackageRegistry()
          Obtains the package registry that the environment I create will use to look up the Ecore definitions of UML packages.
 org.eclipse.emf.ecore.resource.ResourceSet getResourceSet()
          Obtains the resource set that the environment I create will use to find UML packages.
protected  org.eclipse.uml2.uml.Package getUMLMetamodel()
          Obtains the UML metamodel library, loaded in my resource set.
 Environment<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> loadEnvironment(org.eclipse.emf.ecore.resource.Resource resource)
          Loads an environment from the specified resource.
protected  org.eclipse.uml2.uml.Package lookupPackage(java.util.List<java.lang.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, createOCLAnalyzer, createOCLAnalyzer, createOCLFactoryWithHistory, createOCLSyntaxHelper, createOperationContext, createPackageContext, createPackageContext, createValidationVisitor, 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(org.eclipse.emf.ecore.resource.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(org.eclipse.emf.ecore.EPackage.Registry registry,
                             org.eclipse.emf.ecore.resource.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<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> loadEnvironment(org.eclipse.emf.ecore.resource.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 org.eclipse.emf.ecore.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 org.eclipse.emf.ecore.resource.ResourceSet getResourceSet()
Obtains the resource set that the environment I create will use to find UML packages.

Returns:
my resource set

getUMLMetamodel

protected org.eclipse.uml2.uml.Package getUMLMetamodel()
Obtains the UML metamodel library, loaded in my resource set.

Returns:
the UML metamodel

lookupPackage

protected org.eclipse.uml2.uml.Package lookupPackage(java.util.List<java.lang.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<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject>
Parameters:
pathname - the qualified name of the package to find
Returns:
the matching package, or null if none is found

getClassifier

protected org.eclipse.uml2.uml.Classifier getClassifier(java.lang.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<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.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<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> createEnvironment(Environment<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.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<org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.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<org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> createEvaluationEnvironment(EvaluationEnvironment<org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.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