Package org.firebirdsql.jdbc.parser
Class SqlParser
- java.lang.Object
-
- org.firebirdsql.jdbc.parser.SqlParser
-
- All Implemented Interfaces:
VisitorRegistrar
@InternalApi public final class SqlParser extends java.lang.Object implements VisitorRegistrar
Simple visiting SQL parser.This parser is not thread-safe.
- Since:
- 4.0.8
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SqlParser.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SqlParser
add(TokenVisitor tokenVisitor)
Fluent variant ofaddVisitor(TokenVisitor)
.void
addVisitor(TokenVisitor tokenVisitor)
Adds a visitor.boolean
isCompleted()
boolean
isParsing()
boolean
isStarted()
void
parse()
Starts parsing of the statement text.void
removeVisitor(TokenVisitor tokenVisitor)
Removes a visitor - if already registered.void
resumeParsing()
Start or resume parsing of the statement text.static SqlParser.Builder
withReservedWords(ReservedWords reservedWords)
Creates a builder for a SQL parser with a supplier of reserved words.
-
-
-
Method Detail
-
withReservedWords
public static SqlParser.Builder withReservedWords(ReservedWords reservedWords)
Creates a builder for a SQL parser with a supplier of reserved words.- Parameters:
reservedWords
- Reserved words- Returns:
- builder to complete initialization of a SQL parser
-
parse
public void parse()
Starts parsing of the statement text.- Throws:
java.lang.IllegalStateException
- Whenparse()
has already been parsed, or there are no registered visitors.- See Also:
resumeParsing()
-
resumeParsing
public void resumeParsing()
Start or resume parsing of the statement text.If the parsing process previously stalled because there were no more visitors, this continues parsing at the point the parser previously stopped. If parsing was not yet started (e.g. using
parse()
), it will start.- Throws:
java.lang.IllegalStateException
- When parsing was already completed, parsing is already in progress, or there are no registered visitors- See Also:
parse()
-
isStarted
public boolean isStarted()
-
isParsing
public boolean isParsing()
-
isCompleted
public boolean isCompleted()
-
add
public SqlParser add(TokenVisitor tokenVisitor)
Fluent variant ofaddVisitor(TokenVisitor)
.- Parameters:
tokenVisitor
- token visitor to add- Returns:
- this SQL parser
-
addVisitor
public void addVisitor(TokenVisitor tokenVisitor)
Description copied from interface:VisitorRegistrar
Adds a visitor.- Specified by:
addVisitor
in interfaceVisitorRegistrar
- Parameters:
tokenVisitor
- Token visitor
-
removeVisitor
public void removeVisitor(TokenVisitor tokenVisitor)
Description copied from interface:VisitorRegistrar
Removes a visitor - if already registered.- Specified by:
removeVisitor
in interfaceVisitorRegistrar
- Parameters:
tokenVisitor
- Token visitor
-
-