Module org.jooq
Package org.jooq

Interface ParseContext

All Superinterfaces:
Scope

public interface ParseContext extends Scope
A publicly available API for the internal parse context that allows for parsing SQL fragements.
Author:
Lukas Eder
  • Method Details

    • parseDialect

      @NotNull @NotNull SQLDialect parseDialect()
      Convenient access to Settings.getParseDialect().
    • parseFamily

      @NotNull @NotNull SQLDialect parseFamily()
      Convenient access to Settings.getParseDialect()'s family.
    • languageContext

      @NotNull @NotNull LanguageContext languageContext()
      The current language context.
    • character

      char character()
      The character at the current position().
    • character

      char character(int pos)
      The character at position position(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:
      parse(char)
    • peek

      boolean peek(String string)
      Peek at the next characters.
      Returns:
      Whether the next characters are the expected ones.
      See Also:
      parse(String)
    • peekKeyword

      boolean peekKeyword(String keyword)
      Peek at the next keyword.
      Returns:
      Whether the next keyword is the expected one.
      See Also:
      parseKeywordIf(String)
    • peekKeyword

      boolean peekKeyword(String... keywords)
      Peek at the next keyword.
      Returns:
      Whether the next keyword is any of the expected ones.
      See Also:
      peekKeyword(String), parseKeywordIf(String)
    • parse

      boolean parse(char c) throws ParserException
      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

      boolean parse(String string) throws ParserException
      Parse a string or fail if it cannot be parsed.
      Returns:
      Always returns true.
      Throws:
      ParserException - if the string could not be parsed.
    • parseIf

      boolean parseIf(String string)
      Try parsing a string.
      Returns:
      Whether the string could be parsed.
    • parseKeyword

      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:
      Always returns true.
      Throws:
      ParserException - if the keyword could not be parsed.
    • parseKeywordIf

      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:
      Whether the keyword could be parsed.
    • parseKeywordIf

      boolean parseKeywordIf(String... keywords)
      Try parsing any keyword.
      Returns:
      Whether any of the keywords could be parsed.
    • parseKeyword

      boolean parseKeyword(String... keywords) throws ParserException
      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

      @NotNull @NotNull Name parseIdentifier() throws ParserException
      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

      @Nullable @Nullable Name 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

      @NotNull @NotNull Name parseName() throws ParserException
      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

      @Nullable @Nullable Name 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

      boolean parseFunctionNameIf(String name)
      Try parsing a function name.
      Returns:
      Whether the function name could be parsed.
    • parseFunctionNameIf

      boolean parseFunctionNameIf(String... names)
      Try parsing any function name.
      Returns:
      Whether any function name could be parsed.
    • parseStringLiteral

      @NotNull @NotNull String parseStringLiteral() throws ParserException
      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

      @Nullable @Nullable String 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

      @NotNull @NotNull Long parseUnsignedIntegerLiteral() throws ParserException
      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

      @Nullable @Nullable Long 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

      @NotNull @NotNull Long parseSignedIntegerLiteral() throws ParserException
      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

      @Nullable @Nullable Long 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

      @NotNull @NotNull DataType<?> parseDataType() throws ParserException
      Parse a DataType 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

      @NotNull @NotNull Field<?> parseField() throws ParserException
      Parse a Field 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

      @NotNull @NotNull SortField<?> parseSortField() throws ParserException
      Parse a SortField 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

      @NotNull @NotNull Condition parseCondition() throws ParserException
      Parse a Condition 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

      @NotNull @NotNull Table<?> parseTable() throws ParserException
      Parse a Table 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

      <T> T parseParenthesised(Function<? super ParseContext,​? extends T> content)
      Convenience method to parse parenthesised content.
    • parseParenthesised

      <T> T parseParenthesised(char open, Function<? super ParseContext,​? extends T> content, char close)
      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

      @NotNull @NotNull ParserException exception(String message)
      An exception that can be thrown from the current position.