Class StatementDetector

  • All Implemented Interfaces:

    public final class StatementDetector
    extends java.lang.Object
    implements TokenVisitor
    Detects the type of statement, and - optionally - whether a DML statement has a RETURNING clause.

    If the detected statement type is UPDATE, DELETE, INSERT, UPDATE OR INSERT and MERGE, it identifies the affected table and - optionally - whether or not a RETURNING clause is present (delegated to a ReturningClauseDetector).

    The types of statements detected are informed by the needs of Jaybird, and may change between point releases.

    Mark Rotteveel
    • Constructor Detail

      • StatementDetector

        public StatementDetector​(boolean detectReturning)
        Detect statement type and - optionally - returning clause.
        detectReturning - true detect returning clause, false do not detect returning clause
    • Method Detail

      • visitToken

        public void visitToken​(Token token,
                               VisitorRegistrar visitorRegistrar)
        Description copied from interface: TokenVisitor
        Notifies the visitor of a token.
        Specified by:
        visitToken in interface TokenVisitor
        token - Token
        visitorRegistrar - Visitor registrar (can be used to remove itself, or add other visitors)
      • complete

        public void complete​(VisitorRegistrar visitorRegistrar)
        Description copied from interface: TokenVisitor
        Signals that the last token was produced and the statement text was fully parsed.
        Specified by:
        complete in interface TokenVisitor
        visitorRegistrar - Visitor registrar (can be used to remove itself, or add other visitors)
      • getStatementType

        public LocalStatementType getStatementType()
        detected statement type, UNKNOWN when no tokens have been received (nothing was parsed)