Package gudusoft.gsqlparser.parser
Class SqlParseResult
Object
gudusoft.gsqlparser.parser.SqlParseResult
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for constructing SqlParseResult instances. -
Method Summary
Modifier and TypeMethodDescriptionintGet the error code.Get the error message if parsing failed.longGet interpreter time in milliseconds.getLexer()Get the lexer instance (for backward compatibility).Get the parser instance (for backward compatibility).longGet parsing time in milliseconds.Get the secondary parser instance (for Oracle PL/SQL parser).longGet semantic analysis time in milliseconds.Get the list of source tokens.Get the list of parsed SQL statements.Get detailed syntax errors.longGet tokenization time in milliseconds.longGet total time (all phases combined) in milliseconds.booleanCheck if parsing resulted in errors.booleanCheck if parsing was successful.toString()
-
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
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
Get tokenization time in milliseconds.- Returns:
- tokenization time in ms
-
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
Get interpreter time in milliseconds.- Returns:
- interpreter time in ms
-
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
Check if parsing resulted in errors.- Returns:
- true if there were errors, false otherwise
-
isSuccessful
Check if parsing was successful.- Returns:
- true if no errors, false otherwise
-
toString
-