- 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 CallbackParseListener
onParseCondition
(Function<? super ParseContext, ? extends Condition> onParseCondition) Create aParseListener
with aparseCondition(ParseContext)
implementation.static CallbackParseListener
onParseEnd
(Consumer<? super ParseContext> onParseEnd) Create aParseListener
with aparseEnd(ParseContext)
implementation.static CallbackParseListener
onParseField
(Function<? super ParseContext, ? extends Field<?>> onParseField) Create aParseListener
with aparseField(ParseContext)
implementation.static CallbackParseListener
onParseStart
(Consumer<? super ParseContext> onParseStart) Create aParseListener
with aparseStart(ParseContext)
implementation.static CallbackParseListener
onParseTable
(Function<? super ParseContext, ? extends Table<?>> onParseTable) Create aParseListener
with aparseTable(ParseContext)
implementation.@Nullable Condition
Attempt to parse aCondition
expression.void
parseEnd
(ParseContext ctx) Callback method invoked after the parser successfully completes parsing a SQL string.@Nullable Field<?>
parseField
(ParseContext ctx) Attempt to parse aField
expression.void
parseStart
(ParseContext ctx) Callback method invoked before the parser starts parsing a SQL string.@Nullable Table<?>
parseTable
(ParseContext ctx) Attempt to parse aTable
expression.
-
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()
.- 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.
- Throws:
ParserException
-
parseField
Attempt to parse aField
expression.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 ofA
andB
. Client code does not have to (and should not) handle the+
operator, or its precedence.- Returns:
- The
Field
expression if a field could be parsed, ornull
otherwise. - Throws:
ParserException
- Any syntax error or other exception that may have occurred while attempting to parse aField
expression.
-
parseTable
Attempt to parse aTable
expression.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 ofA
andB
. Client code does not have to (and should not) handle thejoin
operator, or its precedence.- Returns:
- The
Table
expression if a table could be parsed, ornull
otherwise. - Throws:
ParserException
- Any syntax error or other exception that may have occurred while attempting to parse aTable
expression.
-
parseCondition
Attempt to parse aCondition
expression.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 ofA
andB
. Client code does not have to (and should not) handle theor
operator, or its precedence.- Returns:
- The
Condition
expression if a condition could be parsed, ornull
otherwise. - Throws:
ParserException
- Any syntax error or other exception that may have occurred while attempting to parse aCondition
expression.
-
onParseStart
Create aParseListener
with aparseStart(ParseContext)
implementation. -
onParseEnd
Create aParseListener
with aparseEnd(ParseContext)
implementation. -
onParseField
static CallbackParseListener onParseField(Function<? super ParseContext, ? extends Field<?>> onParseField) Create aParseListener
with aparseField(ParseContext)
implementation. -
onParseTable
static CallbackParseListener onParseTable(Function<? super ParseContext, ? extends Table<?>> onParseTable) Create aParseListener
with aparseTable(ParseContext)
implementation. -
onParseCondition
static CallbackParseListener onParseCondition(Function<? super ParseContext, ? extends Condition> onParseCondition) Create aParseListener
with aparseCondition(ParseContext)
implementation.
-