Module org.jooq
Package org.jooq.impl

Class CallbackParseListener

java.lang.Object
org.jooq.impl.CallbackParseListener
All Implemented Interfaces:
EventListener, ParseListener

@Pro public final class CallbackParseListener extends Object implements ParseListener
A ParseListener that allows for functional composition.

For example:

 ParseListener listener = ParseListener
   .onParseField(ctx -> something())
   .onParseCondition(ctx -> something());
 
Author:
Lukas Eder
  • Constructor Details

    • CallbackParseListener

      public CallbackParseListener()
  • Method Details

    • parseStart

      public final void parseStart(ParseContext ctx)
      Description copied from interface: ParseListener
      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().

      Specified by:
      parseStart in interface ParseListener
    • parseEnd

      public final void parseEnd(ParseContext ctx)
      Description copied from interface: ParseListener
      Callback method invoked after the parser successfully completes parsing a SQL string.

      Use this to clean up resources or perform post-parsing validations.

      Specified by:
      parseEnd in interface ParseListener
    • parseField

      public final Field<?> parseField(ParseContext ctx)
      Description copied from interface: ParseListener
      Attempt to parse a Field 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 of A and B. Client code does not have to (and should not) handle the + operator, or its precedence.

      Specified by:
      parseField in interface ParseListener
      Returns:
      The Field expression if a field could be parsed, or null otherwise.
    • parseTable

      public final Table<?> parseTable(ParseContext ctx)
      Description copied from interface: ParseListener
      Attempt to parse a Table 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 of A and B. Client code does not have to (and should not) handle the join operator, or its precedence.

      Specified by:
      parseTable in interface ParseListener
      Returns:
      The Table expression if a table could be parsed, or null otherwise.
    • parseCondition

      public final Condition parseCondition(ParseContext ctx)
      Description copied from interface: ParseListener
      Attempt to parse a Condition 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 of A and B. Client code does not have to (and should not) handle the or operator, or its precedence.

      Specified by:
      parseCondition in interface ParseListener
      Returns:
      The Condition expression if a condition could be parsed, or null otherwise.
    • onParseStart

      public final CallbackParseListener onParseStart(Consumer<? super ParseContext> newOnParseStart)
    • onParseEnd

      public final CallbackParseListener onParseEnd(Consumer<? super ParseContext> newOnParseEnd)
    • 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)