Top Description Methods
org.jooq

public Interface ParseContext

extends Scope
Known Direct Implementers
org.jooq.impl.DefaultParseContext
Imports
java.util.List, java.util.function.Function, .Predicate, org.jooq.conf.Settings, org.jooq.impl.ParserException, org.jetbrains.annotations.NotNull, .Nullable

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 data() map.

Author
Lukas Eder

Method Summary

Modifier and TypeMethod and Description
public char
character()

The character at the current position().

public char
character(int pos)

The character at position position(int).

public @NotNull char[]
characters()

Get access to the underlying SQL string.

public @NotNull ParseContext
characters(char[] newCharacters)

Update the underlying SQL string.

public @NotNull ParserException
exception(String message)

An exception that can be thrown from the current position.

public @NotNull LanguageContext
languageContext()

The current language context.

public boolean

Returns:

Always returns true.
parse
(char c)

Parse a single character or fail if it cannot be parsed.

public boolean

Returns:

Always returns true.
parse
(String string)

Parse a string or fail if it cannot be parsed.

public @NotNull SQLDialectCategory
parseCategory()

Convenient access to Settings#getParseDialect()'s category.

public @NotNull Condition

Returns:

The parsed condition.
parseCondition
()

Deprecated as a consequence of Condition being deprecated.
Parse a Condition expression or fail if the current expression is not a condition.
public @NotNull DataType<?>

Returns:

The data type.
parseDataType
()

Parse a DataType expression or fail if the current expression is not a data type.

public @NotNull SQLDialect
public @NotNull SQLDialect
parseFamily()

Convenient access to Settings#getParseDialect()'s family.

public @NotNull Field<?>

Returns:

The parsed field.
parseField
()

Deprecated as a consequence of Field being deprecated.
Parse a Field expression or fail if the current expression is not a field.
public boolean

Returns:

Whether the function name could be parsed.
parseFunctionNameIf
(String name)

Try parsing a function name.

public boolean

Returns:

Whether any function name could be parsed.
parseFunctionNameIf
(String... names)

Try parsing any function name.

public @NotNull Name

Returns:

The parsed identifier.
parseIdentifier
()

Parse an (unqualified) identifier or fail if the current token is not an identifier.

public @Nullable Name

Returns:

The identifier if it could be parsed, or null if the current token is not an identifier.
parseIdentifierIf
()

Try parsing an (unqualified) identifier.

public boolean

Returns:

Whether the character could be parsed.
parseIf
(char c)

Try parsing a single character.

public boolean

Returns:

Whether the string could be parsed.
parseIf
(String string)

Try parsing a string.

public boolean

Returns:

Always returns true.
parseKeyword
(String keyword)

Parse a keyword or fail if the keyword cannot be parsed.

public boolean

Returns:

Always returns true.
parseKeyword
(String... keywords)

Parse any keyword or fail if none of the keywords could be parsed.

public boolean

Returns:

Whether the keyword could be parsed.
parseKeywordIf
(String keyword)

Try parsing a keyword.

public boolean

Returns:

Whether any of the keywords could be parsed.
parseKeywordIf
(String... keywords)

Try parsing any keyword.

public <T> @NotNull List<T>
parseList(String separator, Function<? super ParseContext, ? extends T> element)

Convenience method to parse a list of at least 1 elements.

public <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.

public @NotNull Name

Returns:

The parsed name.
parseName
()

Parse a name (a qualified identifier) or fail if the current token is not a name.

public @Nullable Name

Returns:

The name if it could be parsed, or null if the current token is not a name.
parseNameIf
()

Try parsing a name (a qualified identifier).

public <T> T
parseParenthesised(Function<? super ParseContext, ? extends T> content)

Convenience method to parse parenthesised content.

public <T> T
parseParenthesised(char open, Function<? super ParseContext, ? extends T> content, char close)

Convenience method to parse parenthesised content.

public <T> T
parseParenthesised(String open, Function<? super ParseContext, ? extends T> content, String close)

Convenience method to parse parenthesised content.

public @NotNull Long

Returns:

The signed integer literal.
parseSignedIntegerLiteral
()

Parse a signed integer literal or fail if the current token is not a signed integer literal.

public @Nullable Long

Returns:

The signed integer literal if it could be parsed, or null if the current token is not an signed integer literal.
parseSignedIntegerLiteralIf
()

Try parsing an signed integer literal.

public @NotNull SortField<?>

Returns:

The parsed sort field.
parseSortField
()

Parse a SortField expression or fail if the current expression is not a sort field.

public @NotNull String

Returns:

The parsed string literal.
parseStringLiteral
()

Parse a string literal or fail if the current token is not a string literal.

public @Nullable String

Returns:

The string literal if it could be parsed, or null if the current token is not a string literal.
parseStringLiteralIf
()

Try parsing a string literal.

public @NotNull Table<?>

Returns:

The parsed table.
parseTable
()

Parse a Table expression or fail if the current expression is not a table.

public @NotNull Long

Returns:

The unsigned integer literal.
parseUnsignedIntegerLiteral
()

Parse an unsigned integer literal or fail if the current token is not an unsigned integer literal.

public @Nullable Long

Returns:

The unsigned integer literal if it could be parsed, or null if the current token is not an unsigned integer literal.
parseUnsignedIntegerLiteralIf
()

Try parsing an unsigned integer literal.

public boolean

Returns:

Whether the next character is the expected one.
peek
(char c)

Peek at the next character.

public boolean

Returns:

Whether the next characters are the expected ones.
peek
(String string)

Peek at the next characters.

public boolean

Returns:

Whether the next keyword is the expected one.
peekKeyword
(String keyword)

Peek at the next keyword.

public boolean

Returns:

Whether the next keyword is any of the expected ones.
peekKeyword
(String... keywords)

Peek at the next keyword.

public int
position()

The current position.

public boolean

Returns:

Always returns true.
position
(int newPosition)

Set the current position to a new one.

Inherited from org.jooq.Scope:
configurationcreationTimedatadatadatadialectdslfamilysettings

Method Detail

characterback to summary
public char character()

The character at the current position().

characterback to summary
public char character(int pos)

The character at position position(int).

charactersback to summary
public @NotNull char[] characters()

Get access to the underlying SQL string.

charactersback to summary
public @NotNull ParseContext characters(char[] newCharacters)

Update the underlying SQL string.

This replaces the current SQL string being parsed by a new one. Callers must ensure this ParseContext maintains a consistent characters() and position().

Annotations
@NotNull
exceptionback to summary
public @NotNull ParserException exception(String message)

An exception that can be thrown from the current position.

Annotations
@NotNull
languageContextback to summary
public @NotNull LanguageContext languageContext()

The current language context.

Annotations
@NotNull
parseback to summary
public boolean parse(char c) throws ParserException

Parse a single character or fail if it cannot be parsed.

Returns:boolean

Always returns true.

Exceptions
ParserException:
if the character could not be parsed.
parseback to summary
public boolean parse(String string) throws ParserException

Parse a string or fail if it cannot be parsed.

Returns:boolean

Always returns true.

Exceptions
ParserException:
if the string could not be parsed.
parseCategoryback to summary
public @NotNull SQLDialectCategory parseCategory()

Convenient access to Settings#getParseDialect()'s category.

Annotations
@NotNull
parseConditionback to summary
public @NotNull Condition parseCondition() throws ParserException

Deprecated

as a consequence of Condition being deprecated. See corresponding docs for further information.

Parse a Condition expression or fail if the current expression is not a condition.

Returns:@NotNull Condition

The parsed condition.

Annotations
@NotNull
Exceptions
ParserException:
if no condition expression could be parsed.
parseDataTypeback to summary
public @NotNull DataType<?> parseDataType() throws ParserException

Parse a DataType expression or fail if the current expression is not a data type.

Returns:@NotNull DataType<?>

The data type.

Annotations
@NotNull
Exceptions
ParserException:
if no data type expression could be parsed.
parseDialectback to summary
public @NotNull SQLDialect parseDialect()

Convenient access to Settings#getParseDialect().

Annotations
@NotNull
parseFamilyback to summary
public @NotNull SQLDialect parseFamily()

Convenient access to Settings#getParseDialect()'s family.

Annotations
@NotNull
parseFieldback to summary
public @NotNull Field<?> parseField() throws ParserException

Deprecated

as a consequence of Field being deprecated. See corresponding docs for further information.

Parse a Field expression or fail if the current expression is not a field.

Returns:@NotNull Field<?>

The parsed field.

Annotations
@NotNull
Exceptions
ParserException:
if no field expression could be parsed.
parseFunctionNameIfback to summary
public boolean parseFunctionNameIf(String name)

Try parsing a function name.

Returns:boolean

Whether the function name could be parsed.

parseFunctionNameIfback to summary
public boolean parseFunctionNameIf(String... names)

Try parsing any function name.

Returns:boolean

Whether any function name could be parsed.

parseIdentifierback to summary
public @NotNull Name parseIdentifier() throws ParserException

Parse an (unqualified) identifier or fail if the current token is not an identifier.

Returns:@NotNull Name

The parsed identifier.

Annotations
@NotNull
Exceptions
ParserException:
if no identifier could be parsed.
parseIdentifierIfback to summary
public @Nullable Name parseIdentifierIf()

Try parsing an (unqualified) identifier.

Returns:@Nullable Name

The identifier if it could be parsed, or null if the current token is not an identifier.

Annotations
@Nullable
parseIfback to summary
public boolean parseIf(char c)

Try parsing a single character.

Returns:boolean

Whether the character could be parsed.

parseIfback to summary
public boolean parseIf(String string)

Try parsing a string.

Returns:boolean

Whether the string could be parsed.

parseKeywordback to summary
public boolean parseKeyword(String keyword) throws ParserException

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:boolean

Always returns true.

Exceptions
ParserException:
if the keyword could not be parsed.
parseKeywordback to summary
public boolean parseKeyword(String... keywords) throws ParserException

Parse any keyword or fail if none of the keywords could be parsed.

Returns:boolean

Always returns true.

Exceptions
ParserException:
if none of the keywords could be parsed.
parseKeywordIfback to summary
public boolean parseKeywordIf(String keyword)

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:boolean

Whether the keyword could be parsed.

parseKeywordIfback to summary
public boolean parseKeywordIf(String... keywords)

Try parsing any keyword.

Returns:boolean

Whether any of the keywords could be parsed.

parseListback to summary
public <T> @NotNull List<T> parseList(String separator, Function<? super ParseContext, ? extends T> element)

Convenience method to parse a list of at least 1 elements.

Annotations
@NotNull
parseListback to summary
public <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.

Annotations
@NotNull
parseNameback to summary
public @NotNull Name parseName() throws ParserException

Parse a name (a qualified identifier) or fail if the current token is not a name.

Returns:@NotNull Name

The parsed name.

Annotations
@NotNull
Exceptions
ParserException:
if no name could be parsed.
parseNameIfback to summary
public @Nullable Name parseNameIf()

Try parsing a name (a qualified identifier).

Returns:@Nullable Name

The name if it could be parsed, or null if the current token is not a name.

Annotations
@Nullable
parseParenthesisedback to summary
public <T> T parseParenthesised(Function<? super ParseContext, ? extends T> content)

Convenience method to parse parenthesised content.

parseParenthesisedback to summary
public <T> T parseParenthesised(char open, Function<? super ParseContext, ? extends T> content, char close)

Convenience method to parse parenthesised content.

parseParenthesisedback to summary
public <T> T parseParenthesised(String open, Function<? super ParseContext, ? extends T> content, String close)

Convenience method to parse parenthesised content.

parseSignedIntegerLiteralback to summary
public @NotNull Long parseSignedIntegerLiteral() throws ParserException

Parse a signed integer literal or fail if the current token is not a signed integer literal.

Returns:@NotNull Long

The signed integer literal.

Annotations
@NotNull
Exceptions
ParserException:
if no signed integer literal could be parsed.
parseSignedIntegerLiteralIfback to summary
public @Nullable Long parseSignedIntegerLiteralIf()

Try parsing an signed integer literal.

Returns:@Nullable Long

The signed integer literal if it could be parsed, or null if the current token is not an signed integer literal.

Annotations
@Nullable
parseSortFieldback to summary
public @NotNull SortField<?> parseSortField() throws ParserException

Parse a SortField expression or fail if the current expression is not a sort field.

Returns:@NotNull SortField<?>

The parsed sort field.

Annotations
@NotNull
Exceptions
ParserException:
if no sort field expression could be parsed.
parseStringLiteralback to summary
public @NotNull String parseStringLiteral() throws ParserException

Parse a string literal or fail if the current token is not a string literal.

Returns:@NotNull String

The parsed string literal.

Annotations
@NotNull
Exceptions
ParserException:
if no string literal could be parsed.
parseStringLiteralIfback to summary
public @Nullable String parseStringLiteralIf()

Try parsing a string literal.

Returns:@Nullable String

The string literal if it could be parsed, or null if the current token is not a string literal.

Annotations
@Nullable
parseTableback to summary
public @NotNull Table<?> parseTable() throws ParserException

Parse a Table expression or fail if the current expression is not a table.

Returns:@NotNull Table<?>

The parsed table.

Annotations
@NotNull
Exceptions
ParserException:
if no table expression could be parsed.
parseUnsignedIntegerLiteralback to summary
public @NotNull Long parseUnsignedIntegerLiteral() throws ParserException

Parse an unsigned integer literal or fail if the current token is not an unsigned integer literal.

Returns:@NotNull Long

The unsigned integer literal.

Annotations
@NotNull
Exceptions
ParserException:
if no unsigned integer literal could be parsed.
parseUnsignedIntegerLiteralIfback to summary
public @Nullable Long parseUnsignedIntegerLiteralIf()

Try parsing an unsigned integer literal.

Returns:@Nullable Long

The unsigned integer literal if it could be parsed, or null if the current token is not an unsigned integer literal.

Annotations
@Nullable
peekback to summary
public boolean peek(char c)

Peek at the next character.

Returns:boolean

Whether the next character is the expected one.

See Also
parse(char)
peekback to summary
public boolean peek(String string)

Peek at the next characters.

Returns:boolean

Whether the next characters are the expected ones.

See Also
parse(String)
peekKeywordback to summary
public boolean peekKeyword(String keyword)

Peek at the next keyword.

Returns:boolean

Whether the next keyword is the expected one.

See Also
parseKeywordIf(String)
peekKeywordback to summary
public boolean peekKeyword(String... keywords)

Peek at the next keyword.

Returns:boolean

Whether the next keyword is any of the expected ones.

See Also
peekKeyword(String), parseKeywordIf(String)
positionback to summary
public int position()

The current position.

positionback to summary
public boolean position(int newPosition)

Set the current position to a new one.

Returns:boolean

Always returns true.