- All Superinterfaces:
Scope
A publicly available API for the internal parse context that allows for
parsing SQL fragements.
This type is a Scope
with independent lifecycle and its own
Scope.data()
map.
- Author:
- Lukas Eder
-
Method Summary
Modifier and TypeMethodDescriptionchar
The character at the currentposition()
.char
character
(int pos) The character at positionposition(int)
.char @NotNull []
Get access to the underlying SQL string.@NotNull ParseContext
characters
(char[] newCharacters) Update the underlying SQL string.@NotNull ParserException
An exception that can be thrown from the current position.@NotNull LanguageContext
The current language context.boolean
parse
(char c) Parse a single character or fail if it cannot be parsed.boolean
Parse a string or fail if it cannot be parsed.@NotNull SQLDialectCategory
Convenient access toSettings.getParseDialect()
's category.@NotNull Condition
Parse aCondition
expression or fail if the current expression is not a condition.@NotNull DataType<?>
Parse aDataType
expression or fail if the current expression is not a data type.@NotNull SQLDialect
Convenient access toSettings.getParseDialect()
.@NotNull SQLDialect
Convenient access toSettings.getParseDialect()
's family.@NotNull Field<?>
Parse aField
expression or fail if the current expression is not a field.boolean
parseFunctionNameIf
(String name) Try parsing a function name.boolean
parseFunctionNameIf
(String... names) Try parsing any function name.@NotNull Name
Parse an (unqualified) identifier or fail if the current token is not an identifier.@Nullable Name
Try parsing an (unqualified) identifier.boolean
parseIf
(char c) Try parsing a single character.boolean
Try parsing a string.boolean
parseKeyword
(String keyword) Parse a keyword or fail if the keyword cannot be parsed.boolean
parseKeyword
(String... keywords) Parse any keyword or fail if none of the keywords could be parsed.boolean
parseKeywordIf
(String keyword) Try parsing a keyword.boolean
parseKeywordIf
(String... keywords) Try parsing any keyword.<T> @NotNull List<T>
parseList
(String separator, Function<? super ParseContext, ? extends T> element) Convenience method to parse a list of at least 1 elements.<T> @NotNull List<T>
parseList
(Predicate<? super ParseContext> separator, Function<? super ParseContext, ? extends T> element) Convenience method to parse a list of at least 1 elements.@NotNull Name
Parse a name (a qualified identifier) or fail if the current token is not a name.@Nullable Name
Try parsing a name (a qualified identifier).<T> T
parseParenthesised
(char open, Function<? super ParseContext, ? extends T> content, char close) Convenience method to parse parenthesised content.<T> T
parseParenthesised
(String open, Function<? super ParseContext, ? extends T> content, String close) Convenience method to parse parenthesised content.<T> T
parseParenthesised
(Function<? super ParseContext, ? extends T> content) Convenience method to parse parenthesised content.@NotNull Long
Parse a signed integer literal or fail if the current token is not a signed integer literal.@Nullable Long
Try parsing an signed integer literal.@NotNull SortField<?>
Parse aSortField
expression or fail if the current expression is not a sort field.@NotNull String
Parse a string literal or fail if the current token is not a string literal.@Nullable String
Try parsing a string literal.@NotNull Table<?>
Parse aTable
expression or fail if the current expression is not a table.@NotNull Long
Parse an unsigned integer literal or fail if the current token is not an unsigned integer literal.@Nullable Long
Try parsing an unsigned integer literal.boolean
peek
(char c) Peek at the next character.boolean
Peek at the next characters.boolean
peekKeyword
(String keyword) Peek at the next keyword.boolean
peekKeyword
(String... keywords) Peek at the next keyword.int
position()
The current position.boolean
position
(int newPosition) Set the current position to a new one.Methods inherited from interface org.jooq.Scope
configuration, creationTime, data, data, data, dialect, dsl, family, settings
-
Method Details
-
parseDialect
Convenient access toSettings.getParseDialect()
. -
parseFamily
Convenient access toSettings.getParseDialect()
's family. -
parseCategory
Convenient access toSettings.getParseDialect()
's category. -
languageContext
The current language context. -
characters
char @NotNull [] characters()Get access to the underlying SQL string. -
characters
Update the underlying SQL string.This replaces the current SQL string being parsed by a new one. Callers must ensure this
ParseContext
maintains a consistentcharacters()
andposition()
. -
character
char character()The character at the currentposition()
. -
character
char character(int pos) The character at positionposition(int)
. -
position
int position()The current position. -
position
boolean position(int newPosition) Set the current position to a new one.- Returns:
- Always returns true.
-
peek
boolean peek(char c) Peek at the next character.- Returns:
- Whether the next character is the expected one.
- See Also:
-
peek
Peek at the next characters.- Returns:
- Whether the next characters are the expected ones.
- See Also:
-
peekKeyword
Peek at the next keyword.- Returns:
- Whether the next keyword is the expected one.
- See Also:
-
peekKeyword
Peek at the next keyword.- Returns:
- Whether the next keyword is any of the expected ones.
- See Also:
-
parse
Parse a single character or fail if it cannot be parsed.- Returns:
- Always returns true.
- Throws:
ParserException
- if the character could not be parsed.
-
parseIf
boolean parseIf(char c) Try parsing a single character.- Returns:
- Whether the character could be parsed.
-
parse
Parse a string or fail if it cannot be parsed.- Returns:
- Always returns true.
- Throws:
ParserException
- if the string could not be parsed.
-
parseIf
Try parsing a string.- Returns:
- Whether the string could be parsed.
-
parseKeyword
Parse a keyword or fail if the keyword cannot be parsed.The argument keyword should be in UPPER CASE and is allowed to contain spaces. Spaces separating keyword parts are interpreted as any arbitrary amount of whitespace. For example, when parsing
"ORDER BY"
, then"order by"
will be parsed as well.- Returns:
- Always returns true.
- Throws:
ParserException
- if the keyword could not be parsed.
-
parseKeywordIf
Try parsing a keyword.The argument keyword should be in UPPER CASE and is allowed to contain spaces. Spaces separating keyword parts are interpreted as any arbitrary amount of whitespace. For example, when parsing
"ORDER BY"
, then"order by"
will be parsed as well.- Returns:
- Whether the keyword could be parsed.
-
parseKeywordIf
Try parsing any keyword.- Returns:
- Whether any of the keywords could be parsed.
-
parseKeyword
Parse any keyword or fail if none of the keywords could be parsed.- Returns:
- Always returns true.
- Throws:
ParserException
- if none of the keywords could be parsed.
-
parseIdentifier
Parse an (unqualified) identifier or fail if the current token is not an identifier.- Returns:
- The parsed identifier.
- Throws:
ParserException
- if no identifier could be parsed.
-
parseIdentifierIf
Try parsing an (unqualified) identifier.- Returns:
- The identifier if it could be parsed, or
null
if the current token is not an identifier.
-
parseName
Parse a name (a qualified identifier) or fail if the current token is not a name.- Returns:
- The parsed name.
- Throws:
ParserException
- if no name could be parsed.
-
parseNameIf
Try parsing a name (a qualified identifier).- Returns:
- The name if it could be parsed, or
null
if the current token is not a name.
-
parseFunctionNameIf
Try parsing a function name.- Returns:
- Whether the function name could be parsed.
-
parseFunctionNameIf
Try parsing any function name.- Returns:
- Whether any function name could be parsed.
-
parseStringLiteral
Parse a string literal or fail if the current token is not a string literal.- Returns:
- The parsed string literal.
- Throws:
ParserException
- if no string literal could be parsed.
-
parseStringLiteralIf
Try parsing a string literal.- Returns:
- The string literal if it could be parsed, or
null
if the current token is not a string literal.
-
parseUnsignedIntegerLiteral
Parse an unsigned integer literal or fail if the current token is not an unsigned integer literal.- Returns:
- The unsigned integer literal.
- Throws:
ParserException
- if no unsigned integer literal could be parsed.
-
parseUnsignedIntegerLiteralIf
Try parsing an unsigned integer literal.- Returns:
- The unsigned integer literal if it could be parsed, or
null
if the current token is not an unsigned integer literal.
-
parseSignedIntegerLiteral
Parse a signed integer literal or fail if the current token is not a signed integer literal.- Returns:
- The signed integer literal.
- Throws:
ParserException
- if no signed integer literal could be parsed.
-
parseSignedIntegerLiteralIf
Try parsing an signed integer literal.- Returns:
- The signed integer literal if it could be parsed, or
null
if the current token is not an signed integer literal.
-
parseDataType
Parse aDataType
expression or fail if the current expression is not a data type.- Returns:
- The data type.
- Throws:
ParserException
- if no data type expression could be parsed.
-
parseField
Parse aField
expression or fail if the current expression is not a field.- Returns:
- The parsed field.
- Throws:
ParserException
- if no field expression could be parsed.
-
parseSortField
Parse aSortField
expression or fail if the current expression is not a sort field.- Returns:
- The parsed sort field.
- Throws:
ParserException
- if no sort field expression could be parsed.
-
parseCondition
Parse aCondition
expression or fail if the current expression is not a condition.- Returns:
- The parsed condition.
- Throws:
ParserException
- if no condition expression could be parsed.
-
parseTable
Parse aTable
expression or fail if the current expression is not a table.- Returns:
- The parsed table.
- Throws:
ParserException
- if no table expression could be parsed.
-
parseList
@NotNull <T> @NotNull List<T> parseList(String separator, Function<? super ParseContext, ? extends T> element) Convenience method to parse a list of at least 1 elements. -
parseList
@NotNull <T> @NotNull List<T> parseList(Predicate<? super ParseContext> separator, Function<? super ParseContext, ? extends T> element) Convenience method to parse a list of at least 1 elements. -
parseParenthesised
Convenience method to parse parenthesised content. -
parseParenthesised
Convenience method to parse parenthesised content. -
parseParenthesised
<T> T parseParenthesised(String open, Function<? super ParseContext, ? extends T> content, String close) Convenience method to parse parenthesised content. -
exception
An exception that can be thrown from the current position.
-