public interface CqnVisitor
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.Modifier and Type | Method and Description |
---|---|
default void |
visit(CqnArithmeticExpression expr)
Called for each traversed
arithmetic
expression |
default void |
visit(CqnArithmeticNegation neg)
Called for each traversed
arithmetic negation |
default void |
visit(CqnBooleanLiteral bool)
Called for each traversed
Boolean literal |
default void |
visit(CqnComparisonPredicate comparison)
Called for each traversed
comparison predicate |
default void |
visit(CqnConnectivePredicate connective)
Called for each traversed
connective
predicate , i.e. |
default void |
visit(CqnContainmentTest test)
Called for each traversed
containment test |
default void |
visit(CqnElementRef elementRef)
Called for each traversed
element reference |
default void |
visit(CqnEntitySelector selector)
Called for each traversed
entity selector unless
the more specific methods visit(CqnExpand) or
visit(CqnSelect) are implemented |
default void |
visit(CqnExistsSubquery exists)
Called for each traversed
exists subquery |
default void |
visit(CqnExpand expand)
Called for each traversed
expand specification |
default void |
visit(CqnExpression expr)
Called for each traversed
expression unless the
more specific methods visit(CqnArithmeticExpression) ,
visit(CqnArithmeticNegation) or visit(CqnPredicate) are
implemented |
default void |
visit(CqnFunc func)
Called for each traversed
function call |
default void |
visit(CqnInline inline)
Called for each traversed
inline specification |
default void |
visit(CqnInPredicate in)
Called for each traversed
IN predicate |
default void |
visit(CqnListValue list)
Called for each traversed
list value |
default void |
visit(CqnLiteral<?> literal)
Called for each traversed
literal unless the more specific
methods visit(CqnBooleanLiteral) , visit(CqnNumericLiteral) ,
visit(CqnStringLiteral) or visit(CqnTemporalLiteral) are
implemented |
default void |
visit(CqnMatchPredicate match)
Called for each traversed
match predicate |
default void |
visit(CqnNegation neg)
Called for each traversed
logical negation |
default void |
visit(CqnNullValue nil)
Called for each traversed
NULL value |
default void |
visit(CqnNumericLiteral<?> number)
Called for each traversed
numeric literal |
default void |
visit(CqnParameter param)
Called for each traversed
parameter |
default void |
visit(CqnPlain plain)
Called for each traversed
plain value |
default void |
visit(CqnPredicate pred)
Called for each traversed
predicate unless the more
specific methods visit(CqnComparisonPredicate) ,
visit(CqnSearchPredicate) , visit(CqnConnectivePredicate) ,
visit(CqnInPredicate) , visit(CqnNegation) ,
visit(CqnExistsSubquery) , visit(CqnMatchPredicate) or
visit(CqnMatchPredicate) are implemented |
default void |
visit(CqnReference.Segment seg)
Deprecated.
|
default void |
visit(CqnSearchPredicate search)
Called for each traversed
search predicate |
default void |
visit(CqnSelect select) |
default void |
visit(CqnSelectListItem sli)
Called for each traversed
select list item unless
the more specific methods visit(CqnSelectListValue) or
visit(CqnStar) are implemented |
default void |
visit(CqnSelectListValue slv)
Called for each traversed
select list value |
default void |
visit(CqnSortSpecification sortSpec)
Called for each traversed
sort specification |
default void |
visit(CqnStar star)
Called for each traversed
star token |
default void |
visit(CqnStringLiteral string)
Called for each traversed
string literal |
default void |
visit(CqnStructuredTypeRef typeRef)
Called for each traversed
structured type
reference |
default void |
visit(CqnTemporalLiteral<?> temporal)
Called for each traversed
temporal literal |
default void visit(CqnFunc func)
function call
func
- the function calldefault void visit(CqnStructuredTypeRef typeRef)
structured type
reference
typeRef
- the structured type referencedefault void visit(CqnElementRef elementRef)
element reference
elementRef
- the element referencedefault void visit(CqnPlain plain)
plain value
plain
- the plain value@Deprecated default void visit(CqnReference.Segment seg)
default void visit(CqnStar star)
star token
star
- the star tokendefault void visit(CqnSelectListValue slv)
select list value
slv
- the select list valuedefault void visit(CqnSelectListItem sli)
select list item
unless
the more specific methods visit(CqnSelectListValue)
or
visit(CqnStar)
are implementedsli
- the select list itemdefault void visit(CqnSortSpecification sortSpec)
sort specification
sortSpec
- the sort specificationdefault void visit(CqnExpression expr)
expression
unless the
more specific methods visit(CqnArithmeticExpression)
,
visit(CqnArithmeticNegation)
or visit(CqnPredicate)
are
implementedexpr
- the expressiondefault void visit(CqnArithmeticExpression expr)
arithmetic
expression
expr
- the arithmetic expressiondefault void visit(CqnArithmeticNegation neg)
arithmetic negation
neg
- the arithmetic negationdefault void visit(CqnPredicate pred)
predicate
unless the more
specific methods visit(CqnComparisonPredicate)
,
visit(CqnSearchPredicate)
, visit(CqnConnectivePredicate)
,
visit(CqnInPredicate)
, visit(CqnNegation)
,
visit(CqnExistsSubquery)
, visit(CqnMatchPredicate)
or
visit(CqnMatchPredicate)
are implementedpred
- the predicatedefault void visit(CqnComparisonPredicate comparison)
comparison predicate
comparison
- the comparison predicatedefault void visit(CqnSearchPredicate search)
search predicate
search
- the search predicatedefault void visit(CqnConnectivePredicate connective)
connective
predicate
, i.e. logical conjunction or disjunctionconnective
- the connective predicatedefault void visit(CqnInPredicate in)
IN predicate
in
- the IN predicatedefault void visit(CqnNegation neg)
logical negation
neg
- the logical negationdefault void visit(CqnContainmentTest test)
containment test
test
- the containment testdefault void visit(CqnLiteral<?> literal)
literal
unless the more specific
methods visit(CqnBooleanLiteral)
, visit(CqnNumericLiteral)
,
visit(CqnStringLiteral)
or visit(CqnTemporalLiteral)
are
implementedliteral
- the literaldefault void visit(CqnStringLiteral string)
string literal
string
- the string literaldefault void visit(CqnBooleanLiteral bool)
Boolean literal
bool
- the Boolean literaldefault void visit(CqnNumericLiteral<?> number)
numeric literal
number
- the numeric literaldefault void visit(CqnTemporalLiteral<?> temporal)
temporal literal
temporal
- the temporal literaldefault void visit(CqnNullValue nil)
NULL value
nil
- the NULL valuedefault void visit(CqnParameter param)
parameter
param
- the parameterdefault void visit(CqnInline inline)
inline specification
inline
- the inline specificationdefault void visit(CqnExpand expand)
expand specification
expand
- the expand specificationdefault void visit(CqnExistsSubquery exists)
exists subquery
exists
- the exists subquerydefault void visit(CqnMatchPredicate match)
match predicate
match
- the match predicatedefault void visit(CqnListValue list)
list value
list
- the list valuedefault void visit(CqnSelect select)
default void visit(CqnEntitySelector selector)
entity selector
unless
the more specific methods visit(CqnExpand)
or
visit(CqnSelect)
are implementedselector
- the entity selectorCopyright © 2023 SAP. All rights reserved.