- All Implemented Interfaces:
EventListener,ParseListener
ParseListener that allows for functional composition.
For example:
ParseListener listener = ParseListener
.onParseField(ctx -> something())
.onParseCondition(ctx -> something());
- Author:
- Lukas Eder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal CallbackParseListeneronParseCondition(Function<? super ParseContext, ? extends Condition> newOnParseCondition) final CallbackParseListeneronParseEnd(Consumer<? super ParseContext> newOnParseEnd) final CallbackParseListeneronParseField(Function<? super ParseContext, ? extends Field<?>> newOnParseField) final CallbackParseListeneronParseStart(Consumer<? super ParseContext> newOnParseStart) final CallbackParseListeneronParseTable(Function<? super ParseContext, ? extends Table<?>> newOnParseTable) final ConditionAttempt to parse aConditionexpression.final voidparseEnd(ParseContext ctx) Callback method invoked after the parser successfully completes parsing a SQL string.final Field<?> parseField(ParseContext ctx) Attempt to parse aFieldexpression.final voidparseStart(ParseContext ctx) Callback method invoked before the parser starts parsing a SQL string.final Table<?> parseTable(ParseContext ctx) Attempt to parse aTableexpression.
-
Constructor Details
-
CallbackParseListener
public CallbackParseListener()
-
-
Method Details
-
parseStart
Description copied from interface:ParseListenerCallback method invoked before the parser starts parsing a SQL string.Use this to perform quick modifications to the SQL string where necessary, e.g. by removing unsupported (but irrelevant) syntax from the input string of
ParseContext.characters().- Specified by:
parseStartin interfaceParseListener- Parameters:
ctx- The context containing information about the parsing, as well as API to interact with it.
-
parseEnd
Description copied from interface:ParseListenerCallback method invoked after the parser successfully completes parsing a SQL string.Use this to clean up resources or perform post-parsing validations.
- Specified by:
parseEndin interfaceParseListener- Parameters:
ctx- The context containing information about the parsing, as well as API to interact with it.
-
parseField
Description copied from interface:ParseListenerAttempt to parse aFieldexpression.This parses a "term", meaning the callback does not interfere with any operators or operator precedence, but will be called only when a field term can appear. For example, with input SQL like
A + B, the callback is called at the positions ofAandB. Client code does not have to (and should not) handle the+operator, or its precedence.- Specified by:
parseFieldin interfaceParseListener- Parameters:
ctx- The context containing information about the parsing, as well as API to interact with it.- Returns:
- The
Fieldexpression if a field could be parsed, ornullotherwise.
-
parseTable
Description copied from interface:ParseListenerAttempt to parse aTableexpression.This parses a "table factor", meaning the callback does not interfere with any operators or operator precedence, but will be called only when a condition term can appear. For example, with input SQL like
A join B, the callback is called at the positions ofAandB. Client code does not have to (and should not) handle thejoinoperator, or its precedence.- Specified by:
parseTablein interfaceParseListener- Parameters:
ctx- The context containing information about the parsing, as well as API to interact with it.- Returns:
- The
Tableexpression if a table could be parsed, ornullotherwise.
-
parseCondition
Description copied from interface:ParseListenerAttempt to parse aConditionexpression.This parses a "predicate", meaning the callback does not interfere with any operators or operator precedence, but will be called only when a condition term can appear. For example, with input SQL like
A or B, the callback is called at the positions ofAandB. Client code does not have to (and should not) handle theoroperator, or its precedence.- Specified by:
parseConditionin interfaceParseListener- Parameters:
ctx- The context containing information about the parsing, as well as API to interact with it.- Returns:
- The
Conditionexpression if a condition could be parsed, ornullotherwise.
-
onParseStart
-
onParseEnd
-
onParseField
public final CallbackParseListener onParseField(Function<? super ParseContext, ? extends Field<?>> newOnParseField) -
onParseTable
public final CallbackParseListener onParseTable(Function<? super ParseContext, ? extends Table<?>> newOnParseTable) -
onParseCondition
public final CallbackParseListener onParseCondition(Function<? super ParseContext, ? extends Condition> newOnParseCondition)
-