org.eclipse.ocl.examples.impactanalyzer.impl
Class ImpactAnalyzerImpl

java.lang.Object
  extended by org.eclipse.ocl.examples.impactanalyzer.impl.ImpactAnalyzerImpl
All Implemented Interfaces:
ImpactAnalyzer

public class ImpactAnalyzerImpl
extends java.lang.Object
implements ImpactAnalyzer

Implementation of the ImpactAnalyzer


Constructor Summary
ImpactAnalyzerImpl(OCLExpression expression, boolean notifyOnNewContextElements, ActivationOption configuration, OCLFactory oclFactory)
          Creates a new impact analyzer for the OCL expression given.
ImpactAnalyzerImpl(OCLExpression expression, boolean notifyOnNewContextElements, OppositeEndFinder oppositeEndFinder, ActivationOption configuration, OCLFactory oclFactory)
           
ImpactAnalyzerImpl(OCLExpression expression, org.eclipse.emf.ecore.EClass context, boolean notifyOnNewContextElements, ActivationOption configuration, OCLFactory oclFactory)
           
ImpactAnalyzerImpl(OCLExpression expression, org.eclipse.emf.ecore.EClass context, boolean notifyOnNewContextElements, OppositeEndFinder oppositeEndFinder, ActivationOption configuration, OCLFactory oclFactory)
           
 
Method Summary
protected  ContextTypeRetriever createContextTypeRetriever()
           
 EventFilter createFilterForExpression()
          Creates a filter for the given OCL expression, which matches at least all events that cause the expression to change its value on one or more context elements.
protected  FilterSynthesisImpl createFilterSynthesis(OCLExpression expression, boolean notifyOnNewContextElements, OCL ocl)
           
protected  InstanceScopeAnalysis createInstanceScopeAnalysis()
           
 java.util.Collection<org.eclipse.emf.ecore.EObject> getContextObjects(org.eclipse.emf.ecore.EObject evaluationResult)
          Determines a superset of the set of context objects for which the overall #expression managed by this instance scope analysis results in evaluationResult or a collection containing evaluationResult.
 java.util.Collection<org.eclipse.emf.ecore.EObject> getContextObjects(org.eclipse.emf.common.notify.Notification event)
          For a change notification event calculates a superset of the set of context objects for which expression may have changed its value due to the change indicated by the event.
protected  OCLExpression getExpression()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImpactAnalyzerImpl

public ImpactAnalyzerImpl(OCLExpression expression,
                          boolean notifyOnNewContextElements,
                          ActivationOption configuration,
                          OCLFactory oclFactory)
Creates a new impact analyzer for the OCL expression given. For event filter synthesis (see createFilterForExpression()) no context type is required. Should getContextObjects(Notification) be called later, a context type may be needed. When this constructor is used, it is inferred on demand using the ContextTypeRetriever, visiting all subexpressions looking for self occurrences and picking their type.

Should you conveniently have the context type available, consider using ImpactAnalyzerImpl(OCLExpression, EClass, boolean, ActivationOption, OCLFactory) instead.

Parameters:
notifyNewContextElements - The analyzer can be parameterized during construction such that it either registers for creation events on the context type or not. Registering for element creation on the context type is useful for invariants / constraints because when a new element is created, validating the constraint may be useful. For other use cases, registering for element creation may not be so useful. For example, when a type inferencer defines its rules using OCL, it only wants to receive update events after the element has been fully initialized from those OCL expressions. In those cases, some framework may be responsible for the initial evaluation of those OCL expressions on new element, and therefore, context element creation events are not of interest.

ImpactAnalyzerImpl

public ImpactAnalyzerImpl(OCLExpression expression,
                          org.eclipse.emf.ecore.EClass context,
                          boolean notifyOnNewContextElements,
                          ActivationOption configuration,
                          OCLFactory oclFactory)

ImpactAnalyzerImpl

public ImpactAnalyzerImpl(OCLExpression expression,
                          boolean notifyOnNewContextElements,
                          OppositeEndFinder oppositeEndFinder,
                          ActivationOption configuration,
                          OCLFactory oclFactory)
Parameters:
oppositeEndFinder - used during partial navigation and for metamodel queries
notifyNewContextElements - The analyzer can be parameterized during construction such that it either registers for creation events on the context type or not. Registering for element creation on the context type is useful for invariants / constraints because when a new element is created, validating the constraint may be useful. For other use cases, registering for element creation may not be so useful. For example, when a type inferencer defines its rules using OCL, it only wants to receive update events after the element has been fully initialized from those OCL expressions. In those cases, some framework may be responsible for the initial evaluation of those OCL expressions on new element, and therefore, context element creation events are not of interest.

ImpactAnalyzerImpl

public ImpactAnalyzerImpl(OCLExpression expression,
                          org.eclipse.emf.ecore.EClass context,
                          boolean notifyOnNewContextElements,
                          OppositeEndFinder oppositeEndFinder,
                          ActivationOption configuration,
                          OCLFactory oclFactory)
Parameters:
oppositeEndFinder - used during partial navigation and for metamodel queries
notifyNewContextElements - The analyzer can be parameterized during construction such that it either registers for creation events on the context type or not. Registering for element creation on the context type is useful for invariants / constraints because when a new element is created, validating the constraint may be useful. For other use cases, registering for element creation may not be so useful. For example, when a type inferencer defines its rules using OCL, it only wants to receive update events after the element has been fully initialized from those OCL expressions. In those cases, some framework may be responsible for the initial evaluation of those OCL expressions on new element, and therefore, context element creation events are not of interest.
Method Detail

createContextTypeRetriever

protected ContextTypeRetriever createContextTypeRetriever()

createFilterForExpression

public EventFilter createFilterForExpression()
Description copied from interface: ImpactAnalyzer
Creates a filter for the given OCL expression, which matches at least all events that cause the expression to change its value on one or more context elements. Note that also events may be matched that don't actually lead to a change. The filter synthesis is "conservative" in this sense.

Specified by:
createFilterForExpression in interface ImpactAnalyzer
Returns:
the filter matching all relevant events

createFilterSynthesis

protected FilterSynthesisImpl createFilterSynthesis(OCLExpression expression,
                                                    boolean notifyOnNewContextElements,
                                                    OCL ocl)

getContextObjects

public java.util.Collection<org.eclipse.emf.ecore.EObject> getContextObjects(org.eclipse.emf.common.notify.Notification event)
Description copied from interface: ImpactAnalyzer
For a change notification event calculates a superset of the set of context objects for which expression may have changed its value due to the change indicated by the event. As implied by "superset," the result set may contain context elements for which the expression's value may happen to not have changed.

Specified by:
getContextObjects in interface ImpactAnalyzer
Parameters:
event - the event to calculate for
Returns:
all relevant context objects; always a valid collection, never null

getContextObjects

public java.util.Collection<org.eclipse.emf.ecore.EObject> getContextObjects(org.eclipse.emf.ecore.EObject evaluationResult)
Description copied from interface: ImpactAnalyzer
Determines a superset of the set of context objects for which the overall #expression managed by this instance scope analysis results in evaluationResult or a collection containing evaluationResult. The result is always a valid collection, never null, but possibly empty.

Specified by:
getContextObjects in interface ImpactAnalyzer
Parameters:
evaluationResult - has to be a non-null EObject because backwards navigation is not easily possible for primitive-typed values and is impossible from null values for now.

createInstanceScopeAnalysis

protected InstanceScopeAnalysis createInstanceScopeAnalysis()

getExpression

protected OCLExpression getExpression()