org.eclipse.ocl.examples.impactanalyzer.instanceScope
Class AbstractPathCache<StepType>

java.lang.Object
  extended by org.eclipse.ocl.examples.impactanalyzer.instanceScope.AbstractPathCache<StepType>
Direct Known Subclasses:
PathCache, TracebackStepCache

public abstract class AbstractPathCache<StepType>
extends java.lang.Object

The instance scope analysis's goal is to pre-compute steps for each PropertyCallExp subexpression in an OCL expression's expression tree. These steps can each be a graph, referring to other potentially composite steps. The graph can even be cyclic, as in the case for recursive operation calls.

During the analysis of the traceback paths, for each subexpression visited, the StepType objects for that node is stored in this cache.

Don't re-use an instance of this class for analyzing more than one expression when those expressions are dynamically parsed because in those cases, new operation calls are created dynamically which turn existing entries in the AbstractPathCache for self and parameter expressions of the operation called invalid. Additionally, all dependent paths would become invalid too. Identifying and removing those entries from a AbstractPathCache seems to cause more effort than using a new AbstractPathCache object for each expression analyzed, particularly given the fact that the step assembly only has to happen once per life-time of an OCLExpression during a session.


Constructor Summary
AbstractPathCache(OppositeEndFinder oppositeEndFinder)
           
 
Method Summary
protected abstract  StepType createStep(OCLExpression sourceExpression, org.eclipse.emf.ecore.EClass context, OperationBodyToCallMapper operationBodyToCallMapper, java.util.Stack<java.lang.String> tupleLiteralNamesToLookFor, OCLFactory oclFactory)
           
 InstanceScopeAnalysis getInstanceScopeAnalysis()
           
 OppositeEndFinder getOppositeEndFinder()
           
 StepType getOrCreateNavigationPath(OCLExpression sourceExpression, org.eclipse.emf.ecore.EClass context, OperationBodyToCallMapper operationBodyToCallMapper, java.util.Stack<java.lang.String> tupleLiteralNamesToLookFor, OCLFactory oclFactory)
           
 StepType getPathForNode(OCLExpression subexpression, java.util.Stack<java.lang.String> tupleLiteralPartNamesToLookFor)
           
 void initInstanceScopeAnalysis(InstanceScopeAnalysis instanceScopeAnalysis)
          Call only immediately after the constructor was called and only in case null was passed for the constructor's instanceScopeAnalysis argument.
 void put(OCLExpression subexpression, java.util.Stack<java.lang.String> tupleLiteralPartNamesToLookFor, StepType path)
          Also adds path to #allSteps.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPathCache

public AbstractPathCache(OppositeEndFinder oppositeEndFinder)
Method Detail

initInstanceScopeAnalysis

public void initInstanceScopeAnalysis(InstanceScopeAnalysis instanceScopeAnalysis)
Call only immediately after the constructor was called and only in case null was passed for the constructor's instanceScopeAnalysis argument.


getInstanceScopeAnalysis

public InstanceScopeAnalysis getInstanceScopeAnalysis()

getOppositeEndFinder

public OppositeEndFinder getOppositeEndFinder()

getPathForNode

public StepType getPathForNode(OCLExpression subexpression,
                               java.util.Stack<java.lang.String> tupleLiteralPartNamesToLookFor)

put

public void put(OCLExpression subexpression,
                java.util.Stack<java.lang.String> tupleLiteralPartNamesToLookFor,
                StepType path)
Also adds path to #allSteps. If the source type is null and the step is not absolute, this path cache registers as a listener on the step (see StepType#addSourceTypeChangeListener(SourceTypeChangeListener). If the target type is null, this path cache registers as target type listener on the step (see StepType#addTargetTypeChangeListener(TargetTypeChangeListener). If the step is not marked as always empty, this path cache registers as listener for a change in the step's always-empty setting. If any of these change events are received, the respective step is re-hashed into #allSteps.


getOrCreateNavigationPath

public StepType getOrCreateNavigationPath(OCLExpression sourceExpression,
                                          org.eclipse.emf.ecore.EClass context,
                                          OperationBodyToCallMapper operationBodyToCallMapper,
                                          java.util.Stack<java.lang.String> tupleLiteralNamesToLookFor,
                                          OCLFactory oclFactory)

createStep

protected abstract StepType createStep(OCLExpression sourceExpression,
                                       org.eclipse.emf.ecore.EClass context,
                                       OperationBodyToCallMapper operationBodyToCallMapper,
                                       java.util.Stack<java.lang.String> tupleLiteralNamesToLookFor,
                                       OCLFactory oclFactory)