Class ParserContext.Builder

Object
gudusoft.gsqlparser.parser.ParserContext.Builder
Enclosing class:
ParserContext

public static class ParserContext.Builder extends Object
Builder for constructing ParserContext instances.

The Builder pattern provides:

  • Flexible construction with optional parameters
  • Readable, fluent API
  • Default values for optional parameters
  • Immutability of final ParserContext object

Example:

 ParserContext ctx = new ParserContext.Builder(EDbVendor.dbvoracle)
     .sqlText("SELECT * FROM dual")
     .enablePartialParsing(true)
     .metaDatabase(myMetaDb)
     .build();
 
  • Constructor Details

    • Builder

      public Builder(EDbVendor vendor)
      Create a builder with required vendor parameter.
      Parameters:
      vendor - the database vendor (required)
  • Method Details

    • sqlText

      Set SQL text to parse.
      Parameters:
      sqlText - the SQL text
      Returns:
      this builder for method chaining
    • sqlFilename

      Set SQL filename to read from.
      Parameters:
      sqlFilename - the SQL filename
      Returns:
      this builder for method chaining
    • sqlInputStream

      Set SQL input stream to read from.
      Parameters:
      sqlInputStream - the SQL input stream
      Returns:
      this builder for method chaining
    • sqlCharset

      Set SQL character set for file reading.
      Parameters:
      sqlCharset - the character set name
      Returns:
      this builder for method chaining
    • enablePartialParsing

      public ParserContext.Builder enablePartialParsing(boolean enablePartialParsing)
      Enable/disable partial parsing.
      Parameters:
      enablePartialParsing - true to enable partial parsing
      Returns:
      this builder for method chaining
    • singlePLBlock

      public ParserContext.Builder singlePLBlock(boolean singlePLBlock)
      Set single PL block mode.
      Parameters:
      singlePLBlock - true for single PL block
      Returns:
      this builder for method chaining
    • onlyNeedRawParseTree

      public ParserContext.Builder onlyNeedRawParseTree(boolean onlyNeedRawParseTree)
      Set if only raw parse tree is needed.
      Parameters:
      onlyNeedRawParseTree - true if only raw parse tree needed
      Returns:
      this builder for method chaining
    • teradataUtilityType

      Set Teradata utility type.
      Parameters:
      teradataUtilityType - the Teradata utility type
      Returns:
      this builder for method chaining
    • sqlStatementHandle

      Set SQL statement handle callback.
      Parameters:
      sqlStatementHandle - the statement handle callback
      Returns:
      this builder for method chaining
    • tokenHandle

      Set token handle callback.
      Parameters:
      tokenHandle - the token handle callback
      Returns:
      this builder for method chaining
    • tokenListHandle

      Set token list handle callback.
      Parameters:
      tokenListHandle - the token list handle callback
      Returns:
      this builder for method chaining
    • metaDatabase

      Set metadata database for column/table resolution.
      Parameters:
      metaDatabase - the metadata database
      Returns:
      this builder for method chaining
    • sqlEnv

      Set SQL environment.
      Parameters:
      sqlEnv - the SQL environment
      Returns:
      this builder for method chaining
    • dumpResolverLog

      public ParserContext.Builder dumpResolverLog(boolean dumpResolverLog)
      Enable/disable resolver log dumping.
      Parameters:
      dumpResolverLog - true to dump resolver log
      Returns:
      this builder for method chaining
    • enableTimeLogging

      public ParserContext.Builder enableTimeLogging(boolean enableTimeLogging)
      Enable/disable time logging.
      Parameters:
      enableTimeLogging - true to enable time logging
      Returns:
      this builder for method chaining
    • frameStack

      public ParserContext.Builder frameStack(Stack<gudusoft.gsqlparser.compiler.TFrame> frameStack)
      Set frame stack for compiler context.
      Parameters:
      frameStack - the frame stack
      Returns:
      this builder for method chaining
    • gsqlparser

      Set reference to TGSqlParser facade for backfilling metadata.
      Parameters:
      gsqlparser - TGSqlParser instance
      Returns:
      this builder
    • build

      public ParserContext build()
      Build the immutable ParserContext.
      Returns:
      a new immutable ParserContext instance