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

java.lang.Object
  extended by org.eclipse.ocl.examples.pivot.AbstractBasicEnvironment
      extended by org.eclipse.ocl.examples.pivot.AbstractEnvironment
          extended by org.eclipse.ocl.examples.pivot.utilities.PivotEnvironment
All Implemented Interfaces:
Adaptable, BasicEnvironment, Customizable, Environment, Environment.Internal

public class PivotEnvironment
extends AbstractEnvironment

Implementation of the Environment for parsing OCL expressions on Ecore models. The EcoreEnvironment uses a client-supplied package registry (or the global registry) to look up EPackages by qualified name.

Author:
Edith Schonberg (edith), Christian W. Damus (cdamus)

Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.ocl.examples.pivot.AbstractEnvironment
AbstractEnvironment.VariableEntry
 
Nested classes/interfaces inherited from interface org.eclipse.ocl.examples.pivot.Environment
Environment.Internal, Environment.Registry
 
Field Summary
 
Fields inherited from interface org.eclipse.ocl.examples.pivot.Environment
OCL_NAMESPACE_URI, RESULT_VARIABLE_NAME, SELF_VARIABLE_NAME
 
Constructor Summary
protected PivotEnvironment(PivotEnvironment parent)
          Initializes me with a parent environment, from which I inherit such things as a package registry and a resource.
protected PivotEnvironment(PivotEnvironmentFactory factory, org.eclipse.emf.ecore.resource.Resource resource)
          Initializes me with an environment factory from which package registry and opposite end finder (if any) are obtained consistently, and from a resource in which I am persisted (and from which I load myself if it already has content).
 
Method Summary
protected  void collectStates(Type owner, java.util.List<java.lang.String> pathPrefix, java.util.List<State> states)
          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.
 Constraint getDefinition(java.lang.Object feature)
          Obtains the definition constraint of the specified feature, if it is an additional attribute or operation defined via an OCL constraint.
 EnvironmentFactory getFactory()
          Obtains the factory that created me, or an appropriate default factory if I was not created using a factory.
 OCLFactory getOCLFactory()
          Obtains a factory for the creation of types that are parameterized by model elements.
 StandardLibrary getOCLStandardLibrary()
          Obtains the collection of core types representing the OCL Standard Library.
 java.util.List<State> getStates(Type owner, java.util.List<java.lang.String> pathPrefix)
          Obtains the states matching the specified path prefix in the owner type by trying the collectStates(org.eclipse.ocl.examples.pivot.Type, java.util.List, java.util.List) method on it and, recursively, its supertypes to find all matches.
 TypeManager getTypeManager()
           
 
Methods inherited from class org.eclipse.ocl.examples.pivot.AbstractEnvironment
addElement, dispose, getContextClassifier, getContextPackage, getInternalParent, getParent, getSelfVariable, notOK, setContextOperation, setContextPackage, setContextProperty, setInternalParent, setParent, setSelfVariable
 
Methods inherited from class org.eclipse.ocl.examples.pivot.AbstractBasicEnvironment
basicGetOptions, clearOptions, getAdapter, getOptions, getValue, isEnabled, putOptions, removeOption, removeOptions, setOption, setParent
 
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.examples.pivot.Adaptable
getAdapter
 
Methods inherited from interface org.eclipse.ocl.examples.pivot.Customizable
clearOptions, getOptions, getValue, isEnabled, putOptions, removeOption, removeOptions, setOption
 

Constructor Detail

PivotEnvironment

protected PivotEnvironment(PivotEnvironmentFactory factory,
                           org.eclipse.emf.ecore.resource.Resource resource)
Initializes me with an environment factory from which package registry and opposite end finder (if any) are obtained consistently, and from a resource in which I am persisted (and from which I load myself if it already has content).

Parameters:
reg - a package registry
resource - a resource, which may or may not already have content
Since:
3.1

PivotEnvironment

protected PivotEnvironment(PivotEnvironment parent)
Initializes me with a parent environment, from which I inherit such things as a package registry and a resource.

Parameters:
parent - my parent environment
Method Detail

getFactory

public EnvironmentFactory 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)

getStates

public java.util.List<State> getStates(Type owner,
                                       java.util.List<java.lang.String> pathPrefix)
Obtains the states matching the specified path prefix in the owner type by trying the collectStates(org.eclipse.ocl.examples.pivot.Type, 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.ocl.examples.pivot.Type, java.util.List, java.util.List) method.

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(Type owner,
                             java.util.List<java.lang.String> pathPrefix,
                             java.util.List<State> states)
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 qualified name, specifying the parent of the states to be collection
states - a list of states directly owned by the namespace indicated by path prefix, within the owner type
See Also:
getStates(Type, List)

getDefinition

public Constraint getDefinition(java.lang.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

getOCLStandardLibrary

public StandardLibrary 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 Environments constructed by a particular EnvironmentFactory.

Returns:
the OCL Standard Library implementation for this environment

getTypeManager

public TypeManager getTypeManager()

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