Package com.sap.cds.ql.cqn
Interface CqnVisitor
public interface CqnVisitor
A
CqnToken
tree visitor conform to the visitor design pattern.
Classes implementing this interface operate on a tree of CqnTokens
,
such as CQN expressions, predicates and values.
When a visitor is passed as an argument to a token's accept
method,
generally the accept
methods of the token's children are called
first. Afterwards the visit
method that is most specific to the
parent token is invoked. Classes implementing this interface may override the
default visit
method to perform arbitrary operations.
Consider the following example with the visitor implementation:
CqnVisitor visitor = new CqnVisitor() { @Override public void visit(CqnComparisonPredicate comparison) { System.out.println(comparison.operator()); } @Override public void visit(CqnElementRef elementRef) { System.out.println(elementRef.displayName()); } @Override public void visit(CqnStringLiteral literal) { System.out.println(literal.value()); } };and the comparison predicate:
Predicate compPredicate = CQL.comparison(CQL.get("name"), Operator.IS, CQL.constant("Peter"));Calling the
compPredicate.accept(visitor)
will produce the following
output:
name Peter ISNote the order in which the nodes are visited. As per
CqnComparisonPredicate.accept(com.sap.cds.ql.cqn.CqnVisitor)
the visitor is first dispatched to the
left and right values of the comparison. Afterwards the
visit(CqnComparisonPredicate comparison)
method is called.-
Method Summary
Modifier and TypeMethodDescriptiondefault void
visit
(CqnArithmeticExpression expr) Called for each traversedarithmetic expression
default void
Called for each traversedarithmetic negation
default void
visit
(CqnBetweenPredicate between) Called for each traversedBETWEEN predicate
default void
visit
(CqnBooleanLiteral bool) Called for each traversedBoolean literal
default void
visit
(CqnComparisonPredicate comparison) Called for each traversedcomparison predicate
default void
visit
(CqnConnectivePredicate connective) Called for each traversedconnective predicate
, i.e.default void
visit
(CqnContainmentTest test) Called for each traversedcontainment test
default void
visit
(CqnElementRef elementRef) Called for each traversedelement reference
default void
visit
(CqnEntitySelector selector) Called for each traversedentity selector
unless the more specific methodsvisit(CqnExpand)
orvisit(CqnSelect)
are implementeddefault void
visit
(CqnEtagPredicate etag) Called for each traversedETag predicate
default void
visit
(CqnExistsSubquery exists) Called for each traversedexists subquery
default void
Called for each traversedexpand specification
default void
visit
(CqnExpression expr) Called for each traversedexpression
unless the more specific methodsvisit(CqnArithmeticExpression)
,visit(CqnArithmeticNegation)
orvisit(CqnPredicate)
are implementeddefault void
Called for each traversedfunction call
default void
Called for each traversedinline specification
default void
visit
(CqnInPredicate in) Called for each traversedIN predicate
default void
visit
(CqnListValue list) Called for each traversedlist value
default void
visit
(CqnLiteral<?> literal) Called for each traversedliteral
unless the more specific methodsvisit(CqnBooleanLiteral)
,visit(CqnNumericLiteral)
,visit(CqnStringLiteral)
orvisit(CqnTemporalLiteral)
are implementeddefault void
visit
(CqnMatchPredicate match) Called for each traversedmatch predicate
default void
visit
(CqnNegation neg) Called for each traversedlogical negation
default void
visit
(CqnNullValue nil) Called for each traversedNULL value
default void
visit
(CqnNumericLiteral<?> number) Called for each traversednumeric literal
default void
visit
(CqnParameter param) Called for each traversedparameter
default void
Called for each traversedplain value
default void
visit
(CqnPredicate pred) Called for each traversedpredicate
unless the more specific methodsvisit(CqnComparisonPredicate)
,visit(CqnSearchPredicate)
,visit(CqnConnectivePredicate)
,visit(CqnInPredicate)
,visit(CqnNegation)
,visit(CqnExistsSubquery)
,visit(CqnMatchPredicate)
orvisit(CqnMatchPredicate)
are implementeddefault void
visit
(CqnSearchPredicate search) Called for each traversedsearch predicate
default void
default void
visit
(CqnSelectListItem sli) Called for each traversedselect list item
unless the more specific methodsvisit(CqnSelectListValue)
orvisit(CqnStar)
are implementeddefault void
visit
(CqnSelectListValue slv) Called for each traversedselect list value
default void
visit
(CqnSortSpecification sortSpec) Called for each traversedsort specification
default void
Called for each traversedstar token
default void
visit
(CqnStringLiteral string) Called for each traversedstring literal
default void
visit
(CqnStructuredTypeRef typeRef) Called for each traversedstructured type reference
default void
visit
(CqnTemporalLiteral<?> temporal) Called for each traversedtemporal literal
default void
Called for each traversedvector
-
Method Details
-
visit
Called for each traversedfunction call
- Parameters:
func
- the function call
-
visit
Called for each traversedstructured type reference
- Parameters:
typeRef
- the structured type reference
-
visit
Called for each traversedelement reference
- Parameters:
elementRef
- the element reference
-
visit
Called for each traversedplain value
- Parameters:
plain
- the plain value
-
visit
Called for each traversedstar token
- Parameters:
star
- the star token
-
visit
Called for each traversedselect list value
- Parameters:
slv
- the select list value
-
visit
Called for each traversedselect list item
unless the more specific methodsvisit(CqnSelectListValue)
orvisit(CqnStar)
are implemented- Parameters:
sli
- the select list item
-
visit
Called for each traversedsort specification
- Parameters:
sortSpec
- the sort specification
-
visit
Called for each traversedexpression
unless the more specific methodsvisit(CqnArithmeticExpression)
,visit(CqnArithmeticNegation)
orvisit(CqnPredicate)
are implemented- Parameters:
expr
- the expression
-
visit
Called for each traversedarithmetic expression
- Parameters:
expr
- the arithmetic expression
-
visit
Called for each traversedarithmetic negation
- Parameters:
neg
- the arithmetic negation
-
visit
Called for each traversedpredicate
unless the more specific methodsvisit(CqnComparisonPredicate)
,visit(CqnSearchPredicate)
,visit(CqnConnectivePredicate)
,visit(CqnInPredicate)
,visit(CqnNegation)
,visit(CqnExistsSubquery)
,visit(CqnMatchPredicate)
orvisit(CqnMatchPredicate)
are implemented- Parameters:
pred
- the predicate
-
visit
Called for each traversedcomparison predicate
- Parameters:
comparison
- the comparison predicate
-
visit
Called for each traversedsearch predicate
- Parameters:
search
- the search predicate
-
visit
Called for each traversedconnective predicate
, i.e. logical conjunction or disjunction- Parameters:
connective
- the connective predicate
-
visit
Called for each traversedIN predicate
- Parameters:
in
- the IN predicate
-
visit
Called for each traversedBETWEEN predicate
- Parameters:
between
- the BETWEEN predicate
-
visit
Called for each traversedETag predicate
- Parameters:
etag
- the ETag predicate
-
visit
Called for each traversedlogical negation
- Parameters:
neg
- the logical negation
-
visit
Called for each traversedcontainment test
- Parameters:
test
- the containment test
-
visit
Called for each traversedliteral
unless the more specific methodsvisit(CqnBooleanLiteral)
,visit(CqnNumericLiteral)
,visit(CqnStringLiteral)
orvisit(CqnTemporalLiteral)
are implemented- Parameters:
literal
- the literal
-
visit
Called for each traversedstring literal
- Parameters:
string
- the string literal
-
visit
Called for each traversedBoolean literal
- Parameters:
bool
- the Boolean literal
-
visit
Called for each traversednumeric literal
- Parameters:
number
- the numeric literal
-
visit
Called for each traversedtemporal literal
- Parameters:
temporal
- the temporal literal
-
visit
Called for each traversedvector
- Parameters:
vector
- the vector
-
visit
Called for each traversedNULL value
- Parameters:
nil
- the NULL value
-
visit
Called for each traversedparameter
- Parameters:
param
- the parameter
-
visit
Called for each traversedinline specification
- Parameters:
inline
- the inline specification
-
visit
Called for each traversedexpand specification
- Parameters:
expand
- the expand specification
-
visit
Called for each traversedexists subquery
- Parameters:
exists
- the exists subquery
-
visit
Called for each traversedmatch predicate
- Parameters:
match
- the match predicate
-
visit
Called for each traversedlist value
- Parameters:
list
- the list value
-
visit
-
visit
Called for each traversedentity selector
unless the more specific methodsvisit(CqnExpand)
orvisit(CqnSelect)
are implemented- Parameters:
selector
- the entity selector
-