org.eclipse.ocl.examples.pivot.utilities
Class PivotEnvironmentFactory

java.lang.Object
  extended by org.eclipse.ocl.examples.pivot.AbstractEnvironmentFactory
      extended by org.eclipse.ocl.examples.pivot.utilities.PivotEnvironmentFactory
All Implemented Interfaces:
Adaptable, EnvironmentFactory
Direct Known Subclasses:
OCLVMEnvironmentFactory

public class PivotEnvironmentFactory
extends AbstractEnvironmentFactory

Implementation of the EnvironmentFactory for parsing OCL expressions on Ecore models.

Author:
Christian W. Damus (cdamus)

Field Summary
protected  MetaModelManager metaModelManager
           
 
Constructor Summary
PivotEnvironmentFactory()
          Initializes me.
PivotEnvironmentFactory(org.eclipse.emf.ecore.EPackage.Registry reg, MetaModelManager metaModelManager)
          Initializes me with an EPackage.Registry that the environments I create will use to look up packages.
 
Method Summary
static PivotEnvironmentFactory basicGetGlobalRegistryInstance()
           
 PivotEnvironment createEnvironment()
          Creates a root environment, in which package contexts and/or classifier contexts will be created as nested environments.
 PivotEnvironment createEnvironment(Environment parent)
          Creates a child environment of a specified parent, for definition of nested scopes.
 EvaluationEnvironment createEvaluationEnvironment()
          Creates a new evaluation environment to track the values of variables in an OCL expression as it is evaluated.
 EvaluationEnvironment createEvaluationEnvironment(EvaluationEnvironment parent)
          Creates a new evaluation environment as a nested environment of the specified parent.
static void disposeGlobalRegistryInstance()
          Dispose of the global instance; this is intended for leakage detection in tests.
protected  Type 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 used by environment that I create to look up packages.
static PivotEnvironmentFactory getGlobalRegistryInstance()
           
 MetaModelManager getMetaModelManager()
           
 PivotEnvironment loadEnvironment(org.eclipse.emf.ecore.resource.Resource resource)
          Loads an environment from the specified resource.
 
Methods inherited from class org.eclipse.ocl.examples.pivot.AbstractEnvironmentFactory
createClassifierContext, createEvaluationVisitor, createEvaluationVisitor, createInstanceContext, createOperationContext, createPackageContext, createPropertyContext, getAdapter, isEvaluationTracingEnabled, setEvaluationTracingEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

metaModelManager

@NonNull
protected final MetaModelManager metaModelManager
Constructor Detail

PivotEnvironmentFactory

public PivotEnvironmentFactory()
Initializes me. Environments that I create will use the global package registry to look up packages.


PivotEnvironmentFactory

public PivotEnvironmentFactory(@Nullable
                               org.eclipse.emf.ecore.EPackage.Registry reg,
                               @Nullable
                               MetaModelManager metaModelManager)
Initializes me with an EPackage.Registry that the environments I create will use to look up packages.

Parameters:
reg - my package registry
metaModelManager -
Method Detail

basicGetGlobalRegistryInstance

@Nullable
public static PivotEnvironmentFactory basicGetGlobalRegistryInstance()

disposeGlobalRegistryInstance

public static void disposeGlobalRegistryInstance()
Dispose of the global instance; this is intended for leakage detection in tests.


getGlobalRegistryInstance

@NonNull
public static PivotEnvironmentFactory getGlobalRegistryInstance()

createEnvironment

@NonNull
public PivotEnvironment 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

@NonNull
public PivotEnvironment loadEnvironment(@NonNull
                                                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

@Nullable
public final org.eclipse.emf.ecore.EPackage.Registry getEPackageRegistry()
Obtains the package registry used by environment that I create to look up packages.

Returns:
my package registry

createEnvironment

@NonNull
public PivotEnvironment createEnvironment(@NonNull
                                                  Environment 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

@NonNull
public EvaluationEnvironment 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

@NonNull
public EvaluationEnvironment createEvaluationEnvironment(@NonNull
                                                                 EvaluationEnvironment 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

getClassifier

@NonNull
protected Type getClassifier(@NonNull
                                     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
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

getMetaModelManager

@NonNull
public MetaModelManager getMetaModelManager()