Class SqlParseResult

Object
gudusoft.gsqlparser.parser.SqlParseResult

public final class SqlParseResult extends Object
Immutable result of a parsing operation.

This value object encapsulates all outputs produced by SQL parsing, providing clean separation between parser implementation and result data. Once built, a SqlParseResult instance cannot be modified (immutable).

Design Pattern: Value Object + Builder

  • Immutable: Thread-safe, can be safely shared
  • Builder: Flexible construction by parser implementations
  • Clean boundaries: Input/Output separation

Contents:

  • Parse Tree: TStatementList with all parsed statements
  • Tokens: TSourceTokenList with all source tokens
  • Errors: Error code, message, and detailed syntax errors
  • Performance: Timing metrics for each phase
  • State: Lexer and parser instances (for getFlexer() compatibility)

Usage Example:

 SqlParseResult result = parser.parse(context);

 // Check for errors
 if (result.hasErrors()) {
     System.err.println(result.getErrorMessage());
     return;
 }

 // Access parsed statements
 TStatementList statements = result.getSqlStatements();
 for (int i = 0; i < statements.size(); i++) {
     TCustomSqlStatement stmt = statements.get(i);
     // Process statement...
 }
 
Since:
3.2.0.0
See Also:
  • Method Details

    • getLastTokenOfStatementBeenValidated

    • getSourceTokenList

      Get the list of source tokens.
      Returns:
      source token list, or null if tokenization failed
    • getSqlStatements

      Get the list of parsed SQL statements.
      Returns:
      statement list, or null if parsing failed
    • getErrorMessage

      Get the error message if parsing failed.
      Returns:
      error message, or empty string if no error
    • getErrorCode

      public int getErrorCode()
      Get the error code.
      Returns:
      0 if successful, non-zero if error occurred
    • getSyntaxErrors

      Get detailed syntax errors.
      Returns:
      list of syntax errors, empty if no errors
    • getTokenizationTimeMs

      public long getTokenizationTimeMs()
      Get tokenization time in milliseconds.
      Returns:
      tokenization time in ms
    • getParsingTimeMs

      public long getParsingTimeMs()
      Get parsing time in milliseconds.
      Returns:
      parsing time in ms
    • getSemanticAnalysisTimeMs

      Get semantic analysis time in milliseconds.
      Returns:
      semantic analysis time in ms
    • getInterpreterTimeMs

      public long getInterpreterTimeMs()
      Get interpreter time in milliseconds.
      Returns:
      interpreter time in ms
    • getTotalTimeMs

      public long getTotalTimeMs()
      Get total time (all phases combined) in milliseconds.
      Returns:
      total time in ms
    • getLexer

      Get the lexer instance (for backward compatibility).
      Returns:
      the lexer instance
    • getParser

      Get the parser instance (for backward compatibility).
      Returns:
      the parser instance
    • getSecondaryParser

      Get the secondary parser instance (for Oracle PL/SQL parser).
      Returns:
      the secondary parser instance, or null if not applicable
    • hasErrors

      public boolean hasErrors()
      Check if parsing resulted in errors.
      Returns:
      true if there were errors, false otherwise
    • isSuccessful

      public boolean isSuccessful()
      Check if parsing was successful.
      Returns:
      true if no errors, false otherwise
    • toString

      public String toString()
      Overrides:
      toString in class Object