- All Superinterfaces:
EventListener
- All Known Implementing Classes:
CallbackParseListener,DefaultParseListener
This listener will be called when syntactic context allows for specific types
of objects to be parsed. Implementations must return null if
they are unable to parse anything at the given location, in case of which
default parser behaviour will apply.
- Author:
- Lukas Eder
-
Method Summary
Modifier and TypeMethodDescriptionstatic CallbackParseListeneronParseCondition(Function<? super ParseContext, ? extends Condition> onParseCondition) Create aParseListenerwith aparseCondition(ParseContext)implementation.static CallbackParseListeneronParseEnd(Consumer<? super ParseContext> onParseEnd) Create aParseListenerwith aparseEnd(ParseContext)implementation.static CallbackParseListeneronParseField(Function<? super ParseContext, ? extends Field<?>> onParseField) Create aParseListenerwith aparseField(ParseContext)implementation.static CallbackParseListeneronParseStart(Consumer<? super ParseContext> onParseStart) Create aParseListenerwith aparseStart(ParseContext)implementation.static CallbackParseListeneronParseTable(Function<? super ParseContext, ? extends Table<?>> onParseTable) Create aParseListenerwith aparseTable(ParseContext)implementation.default @Nullable ConditionAttempt to parse aConditionexpression.default voidparseEnd(ParseContext ctx) Callback method invoked after the parser successfully completes parsing a SQL string.default @Nullable Field<?>parseField(ParseContext ctx) Attempt to parse aFieldexpression.default voidparseStart(ParseContext ctx) Callback method invoked before the parser starts parsing a SQL string.default @Nullable Table<?>parseTable(ParseContext ctx) Attempt to parse aTableexpression.
-
Method Details
-
parseStart
Callback 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().- Parameters:
ctx- The context containing information about the parsing, as well as API to interact with it.- Throws:
ParserException
-
parseEnd
Callback method invoked after the parser successfully completes parsing a SQL string.Use this to clean up resources or perform post-parsing validations.
- Parameters:
ctx- The context containing information about the parsing, as well as API to interact with it.- Throws:
ParserException
-
parseField
Attempt 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.- 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. - Throws:
ParserException- Any syntax error or other exception that may have occurred while attempting to parse aFieldexpression.
-
parseTable
Attempt 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.- 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. - Throws:
ParserException- Any syntax error or other exception that may have occurred while attempting to parse aTableexpression.
-
parseCondition
Attempt 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.- 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. - Throws:
ParserException- Any syntax error or other exception that may have occurred while attempting to parse aConditionexpression.
-
onParseStart
Create aParseListenerwith aparseStart(ParseContext)implementation. -
onParseEnd
Create aParseListenerwith aparseEnd(ParseContext)implementation. -
onParseField
static CallbackParseListener onParseField(Function<? super ParseContext, ? extends Field<?>> onParseField) Create aParseListenerwith aparseField(ParseContext)implementation. -
onParseTable
static CallbackParseListener onParseTable(Function<? super ParseContext, ? extends Table<?>> onParseTable) Create aParseListenerwith aparseTable(ParseContext)implementation. -
onParseCondition
static CallbackParseListener onParseCondition(Function<? super ParseContext, ? extends Condition> onParseCondition) Create aParseListenerwith aparseCondition(ParseContext)implementation.
-