public abstract class AbstractVisitor<T,C,O,P,EL,PM,S,COA,SSA,CT> extends java.lang.Object implements Visitor<T,C,O,P,EL,PM,S,COA,SSA,CT>
An abstract implementation of the Visitor
API, in which subclasses
need only selectively override handleXxx(...)
methods for
internal AST nodes and visitXxx(...)
methods for leaf nodes.
The result
value is convenient for accumulating the result of the
visitation. In the subclass, simply assign/modify the result value as
necessary in the overridden visitation methods, and this framework will
ensure that it is returned as the overall value of the
Visitable.accept(Visitor)
call.
Modifier and Type | Field and Description |
---|---|
protected T |
result
Accumulator for the result of the AST visitation.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractVisitor()
Initializes me.
|
protected |
AbstractVisitor(T initialValue)
Initializes me with an initial value for my result.
|
Modifier and Type | Method and Description |
---|---|
protected ExpressionInOCL<C,PM> |
getSpecification(CT constraint)
Overridden by subclasses interested in visiting constraints, to get the
constraint's specification.
|
protected T |
handleAssociationClassCallExp(AssociationClassCallExp<C,P> callExp,
T sourceResult,
java.util.List<T> qualifierResults)
Visits the specified association-class call with the results of visiting
its source and qualifiers (if any).
|
protected T |
handleCollectionItem(CollectionItem<C> item,
T itemResult)
Visits the specified collection item with the result of visiting
its item expression.
|
protected T |
handleCollectionLiteralExp(CollectionLiteralExp<C> literalExp,
java.util.List<T> partResults)
Visits the specified collection literal expression with the results of visiting
its parts (if any).
|
protected T |
handleCollectionRange(CollectionRange<C> range,
T firstResult,
T lastResult)
Visits the specified collection range with the results of visiting
its first and last expressions.
|
protected T |
handleConstraint(CT constraint,
T specificationResult)
Visits the specified constraint with the results of visiting
its specification.
|
protected T |
handleExpressionInOCL(ExpressionInOCL<C,PM> expression,
T contextResult,
T resultResult,
java.util.List<T> parameterResults,
T bodyResult)
Visits the specified expression-in-OCL with the results of visiting
its context variable, its result variable (if any), its parameter
variables (if any), and its body expression.
|
protected T |
handleIfExp(IfExp<C> ifExp,
T conditionResult,
T thenResult,
T elseResult)
Visits the specified if expression with the results of visiting
its condition, then, and else expressions.
|
protected T |
handleIterateExp(IterateExp<C,PM> callExp,
T sourceResult,
java.util.List<T> variableResults,
T resultResult,
T bodyResult)
Visits the specified iterate expression with the results of visiting
its source, its iterator variables, its result variable, and its body
expression.
|
protected T |
handleIteratorExp(IteratorExp<C,PM> callExp,
T sourceResult,
java.util.List<T> variableResults,
T bodyResult)
Visits the specified iterator expression with the results of visiting
its source, its iterator variables, and its body expression.
|
protected T |
handleLetExp(LetExp<C,PM> letExp,
T variableResult,
T inResult)
Visits the specified let expression with the results of visiting
its variable and in expression.
|
protected T |
handleMessageExp(MessageExp<C,COA,SSA> messageExp,
T targetResult,
java.util.List<T> argumentResults)
Visits the specified message expression with the results of visiting
its target and arguments (if any).
|
protected T |
handleOperationCallExp(OperationCallExp<C,O> callExp,
T sourceResult,
java.util.List<T> argumentResults)
Visits the specified operation call with the results of visiting
its source and arguments (if any).
|
protected T |
handlePropertyCallExp(PropertyCallExp<C,P> callExp,
T sourceResult,
java.util.List<T> qualifierResults)
Visits the specified property call with the results of visiting
its source and qualifiers (if any).
|
protected T |
handleTupleLiteralExp(TupleLiteralExp<C,P> literalExp,
java.util.List<T> partResults)
Visits the specified tuple literal expression with the results of visiting
its parts (if any).
|
protected T |
handleTupleLiteralPart(TupleLiteralPart<C,P> part,
T valueResult)
Visits the specified tuple literal part with the results of visiting
its value (if any).
|
protected T |
handleVariable(Variable<C,PM> variable,
T initResult)
Visits the specified variable with the results of visiting
its initializer (if any).
|
protected T |
safeVisit(Visitable v)
A null-safe visitation of the specified visitable.
|
T |
visitAssociationClassCallExp(AssociationClassCallExp<C,P> callExp)
Visits the association-class-call source and then its qualifiers (if any).
|
T |
visitBooleanLiteralExp(BooleanLiteralExp<C> literalExp)
Simply returns
result . |
T |
visitCollectionItem(CollectionItem<C> item)
Visits the item's item expression.
|
T |
visitCollectionLiteralExp(CollectionLiteralExp<C> literalExp)
Visits the collection literal's parts.
|
T |
visitCollectionRange(CollectionRange<C> range)
Visits the range's first and last expressions.
|
T |
visitConstraint(CT constraint)
Visits the constraint's specification, if any (and if the
getSpecification(Object) method is overridden). |
T |
visitEnumLiteralExp(EnumLiteralExp<C,EL> literalExp)
Simply returns
result . |
T |
visitExpressionInOCL(ExpressionInOCL<C,PM> expression)
Visits the expressions context variable, its parameter variables (if any),
its result variable (if any), and finally its body expression.
|
T |
visitIfExp(IfExp<C> ifExp)
Visits the if expression's condition, then, and else expressions.
|
T |
visitIntegerLiteralExp(IntegerLiteralExp<C> literalExp)
Simply returns
result . |
T |
visitInvalidLiteralExp(InvalidLiteralExp<C> literalExp)
Simply returns
result . |
T |
visitIterateExp(IterateExp<C,PM> callExp)
Visits the iterate's source, then its iterator variables,
result variable, and body expression.
|
T |
visitIteratorExp(IteratorExp<C,PM> callExp)
Visits the iterator's source, then its variables, followed by its body
expression.
|
T |
visitLetExp(LetExp<C,PM> letExp)
Visits the let's variable declaration then its 'in' expression.
|
T |
visitMessageExp(MessageExp<C,COA,SSA> messageExp)
Visits the message expression's target and then its arguments.
|
T |
visitNullLiteralExp(NullLiteralExp<C> literalExp)
Simply returns
result . |
T |
visitOperationCallExp(OperationCallExp<C,O> callExp)
Visits the operation-call source and then its arguments.
|
T |
visitPropertyCallExp(PropertyCallExp<C,P> callExp)
Visits the property-call source and then its qualifiers (if any).
|
T |
visitRealLiteralExp(RealLiteralExp<C> literalExp)
Simply returns
result . |
T |
visitStateExp(StateExp<C,S> stateExp)
Simply returns
result . |
T |
visitStringLiteralExp(StringLiteralExp<C> literalExp)
Simply returns
result . |
T |
visitTupleLiteralExp(TupleLiteralExp<C,P> literalExp)
Visits the tuple literal's parts.
|
T |
visitTupleLiteralPart(TupleLiteralPart<C,P> part)
Visits the tuple literal part's value, if any.
|
T |
visitTypeExp(TypeExp<C> t)
Simply returns
result . |
T |
visitUnlimitedNaturalLiteralExp(UnlimitedNaturalLiteralExp<C> literalExp)
Simply returns
result . |
T |
visitUnspecifiedValueExp(UnspecifiedValueExp<C> unspecExp)
Simply returns
result . |
T |
visitVariable(Variable<C,PM> variable)
Visits the variable's initialization expression (if any).
|
T |
visitVariableExp(VariableExp<C,PM> v)
Simply returns
result . |
protected T result
protected AbstractVisitor()
protected AbstractVisitor(T initialValue)
initialValue
- my initial result valueprotected T safeVisit(Visitable v)
v
- a visitable, or null
null
if the visitable is null
;
otherwise, the result of visiting itpublic T visitOperationCallExp(OperationCallExp<C,O> callExp)
handleOperationCallExp(OperationCallExp, Object, List)
.protected T handleOperationCallExp(OperationCallExp<C,O> callExp, T sourceResult, java.util.List<T> argumentResults)
callExp
- the operation call expressionsourceResult
- the result of visiting the expression's sourceargumentResults
- the results of visiting the expression's
arguments, or an empty list if there are no argumentsresult
, by defaultvisitOperationCallExp(OperationCallExp)
public T visitVariableExp(VariableExp<C,PM> v)
result
.public T visitPropertyCallExp(PropertyCallExp<C,P> callExp)
handlePropertyCallExp(PropertyCallExp, Object, List)
.protected T handlePropertyCallExp(PropertyCallExp<C,P> callExp, T sourceResult, java.util.List<T> qualifierResults)
sourceResult
will be null
in that case.callExp
- the property call expression, if there is a sourcesourceResult
- the result of visiting the expression's sourcequalifierResults
- the results of visiting the expression's
qualifiers, or an empty list if there are no qualifiersresult
, by defaultvisitPropertyCallExp(PropertyCallExp)
public T visitAssociationClassCallExp(AssociationClassCallExp<C,P> callExp)
handleAssociationClassCallExp(AssociationClassCallExp, Object, List)
.protected T handleAssociationClassCallExp(AssociationClassCallExp<C,P> callExp, T sourceResult, java.util.List<T> qualifierResults)
callExp
- the association-class call expressionsourceResult
- the result of visiting the expression's sourcequalifierResults
- the results of visiting the expression's
qualifiers, or an empty list if there are no qualifiersresult
, by defaultvisitAssociationClassCallExp(AssociationClassCallExp)
public T visitVariable(Variable<C,PM> variable)
handleVariable(Variable, Object)
.protected T handleVariable(Variable<C,PM> variable, T initResult)
variable
- the variableinitResult
- the result of visiting the expression's initializer,
or null
if it has noneresult
, by defaultvisitVariable(Variable)
public T visitIfExp(IfExp<C> ifExp)
handleIfExp(IfExp, Object, Object, Object)
.protected T handleIfExp(IfExp<C> ifExp, T conditionResult, T thenResult, T elseResult)
ifExp
- the if expressionconditionResult
- the result of visiting the expression's conditionthenResult
- the result of visiting the expression's thenelseResult
- the result of visiting the expression's elseresult
, by defaultvisitIfExp(IfExp)
public T visitMessageExp(MessageExp<C,COA,SSA> messageExp)
handleMessageExp(MessageExp, Object, List)
.protected T handleMessageExp(MessageExp<C,COA,SSA> messageExp, T targetResult, java.util.List<T> argumentResults)
messageExp
- the message expressiontargetResult
- the result of visiting the expression's targetargumentResults
- the results of visiting the expression's
arguments, or an empty list if there are no argumentsresult
, by defaultvisitMessageExp(MessageExp)
public T visitUnspecifiedValueExp(UnspecifiedValueExp<C> unspecExp)
result
.public T visitIntegerLiteralExp(IntegerLiteralExp<C> literalExp)
result
.public T visitUnlimitedNaturalLiteralExp(UnlimitedNaturalLiteralExp<C> literalExp)
result
.public T visitRealLiteralExp(RealLiteralExp<C> literalExp)
result
.public T visitStringLiteralExp(StringLiteralExp<C> literalExp)
result
.public T visitBooleanLiteralExp(BooleanLiteralExp<C> literalExp)
result
.public T visitNullLiteralExp(NullLiteralExp<C> literalExp)
result
.public T visitInvalidLiteralExp(InvalidLiteralExp<C> literalExp)
result
.public T visitTupleLiteralExp(TupleLiteralExp<C,P> literalExp)
handleTupleLiteralExp(TupleLiteralExp, List)
.protected T handleTupleLiteralExp(TupleLiteralExp<C,P> literalExp, java.util.List<T> partResults)
literalExp
- the tuple literal expressionpartResults
- the results of visiting the expression's
parts, or an empty list if there are no partsresult
, by defaultvisitTupleLiteralExp(TupleLiteralExp)
public T visitTupleLiteralPart(TupleLiteralPart<C,P> part)
handleTupleLiteralPart(TupleLiteralPart, Object)
.protected T handleTupleLiteralPart(TupleLiteralPart<C,P> part, T valueResult)
part
- the tuple literal partvalueResult
- the result of visiting the expression's value, or
null
if it has no valueresult
, by defaultvisitTupleLiteralPart(TupleLiteralPart)
public T visitLetExp(LetExp<C,PM> letExp)
handleLetExp(LetExp, Object, Object)
.protected T handleLetExp(LetExp<C,PM> letExp, T variableResult, T inResult)
letExp
- the let expressionvariableResult
- the result of visiting the expression's variableinResult
- the result of visiting the expression's in expressionresult
, by defaultvisitLetExp(LetExp)
public T visitEnumLiteralExp(EnumLiteralExp<C,EL> literalExp)
result
.public T visitCollectionLiteralExp(CollectionLiteralExp<C> literalExp)
handleCollectionLiteralExp(CollectionLiteralExp, List)
.protected T handleCollectionLiteralExp(CollectionLiteralExp<C> literalExp, java.util.List<T> partResults)
literalExp
- the collection literal expressionpartResults
- the results of visiting the expression's
parts, or an empty list if there are no partsresult
, by defaultvisitCollectionLiteralExp(CollectionLiteralExp)
public T visitCollectionItem(CollectionItem<C> item)
handleCollectionItem(CollectionItem, Object)
protected T handleCollectionItem(CollectionItem<C> item, T itemResult)
item
- the collection itemitemResult
- the result of visiting the item's item expressionresult
, by defaultvisitCollectionItem(CollectionItem)
public T visitCollectionRange(CollectionRange<C> range)
handleCollectionRange(CollectionRange, Object, Object)
.protected T handleCollectionRange(CollectionRange<C> range, T firstResult, T lastResult)
range
- the collection rangefirstResult
- the result of visiting the range's first expressionlastResult
- the result of visiting the range's last expressionresult
, by defaultvisitCollectionRange(CollectionRange)
public T visitIteratorExp(IteratorExp<C,PM> callExp)
handleIteratorExp(IteratorExp, Object, List, Object)
.protected T handleIteratorExp(IteratorExp<C,PM> callExp, T sourceResult, java.util.List<T> variableResults, T bodyResult)
callExp
- the iterator expressionsourceResult
- the result of visiting the expression's sourcevariableResults
- the results of visiting the expression's
iterator variablesbodyResult
- the result of visiting the expression's bodyresult
, by defaultvisitIteratorExp(IteratorExp)
public T visitIterateExp(IterateExp<C,PM> callExp)
handleIterateExp(IterateExp, Object, List, Object, Object)
.protected T handleIterateExp(IterateExp<C,PM> callExp, T sourceResult, java.util.List<T> variableResults, T resultResult, T bodyResult)
callExp
- the iterate expressionsourceResult
- the result of visiting the expression's sourcevariableResults
- the results of visiting the expression's
iterator variablesresultResult
- the result of visiting the expressions' result variablebodyResult
- the result of visiting the expression's bodyresult
, by defaultvisitIterateExp(IterateExp)
public T visitExpressionInOCL(ExpressionInOCL<C,PM> expression)
handleExpressionInOCL(ExpressionInOCL, Object, Object, List, Object)
.protected T handleExpressionInOCL(ExpressionInOCL<C,PM> expression, T contextResult, T resultResult, java.util.List<T> parameterResults, T bodyResult)
expression
- the expression-in-OCLcontextResult
- the result of visiting the expression's context variableresultResult
- the result of visiting the expressions' result variable,
or null
if there is no result variableparameterResults
- the results of visiting the expression's
parameter variables, or an empty list if there are nonebodyResult
- the result of visiting the expression's bodyresult
, by defaultvisitExpressionInOCL(ExpressionInOCL)
public T visitConstraint(CT constraint)
getSpecification(Object)
method is overridden).
Returns the result of handleConstraint(Object, Object)
.protected T handleConstraint(CT constraint, T specificationResult)
constraint
- the constraintspecificationResult
- the result of visiting the constraint's
specification, or null
if either it has none or the
getSpecification(Object)
method is not overriddenresult
, by default
#see getSpecification(Object)
visitConstraint(Object)
protected ExpressionInOCL<C,PM> getSpecification(CT constraint)
constraint
- a constraintvisitConstraint(Object)