Top Description Methods
org.jooq

public Interface Context<C extends org.jooq.Context<C>>

extends ExecuteScope
Known Direct Subinterfaces
org.jooq.BindContext, org.jooq.RenderContext
Known Direct Implementers
org.jooq.impl.AbstractContext
Imports
java.sql.PreparedStatement, java.text.DecimalFormat, java.util.function.Consumer, org.jooq.RenderContext.CastMode, org.jooq.conf.ParamType, .RenderKeywordCase, .Settings, org.jooq.exception.DataAccessException, org.jooq.impl.DSL, org.jetbrains.annotations.NotNull, .Nullable

A context type that is used for rendering SQL or for binding.

This type implements Scope and thus has a lifecycle defined by the rendering or binding operation.

The data() map contents are maintained for the entirety of the rendering or binding operation, and are passed along to child Scope types, including e.g.

Author
Lukas Eder
See Also
BindContext, RenderContext

Method Summary

Modifier and TypeMethod and Description
public @NotNull BindContext
bindValue(Object value, Field<?> field)

Deprecated as a consequence of Field being deprecated.
Bind a value using a specific type.
public @NotNull RenderContext.CastMode
castMode()

The currently applied cast mode for bind values.

public C
castMode(RenderContext.CastMode mode)

Set the new cast mode for castMode().

public C
castMode(RenderContext.CastMode mode, Consumer<? super C> consumer)

Set the new cast mode for castMode() for the scope of a Consumer.

public C
castModeIf(RenderContext.CastMode mode, boolean condition)

Set the new cast mode for castMode(), if a condition is true.

public C
data(Object key, Object value, Consumer<? super C> consumer)

Set a data value for a key for the scope of a Consumer.

public boolean
declareAliases()

Whether the current context is rendering a SQL alias declarations in declareTables() or declareFields() sections.

public C
declareAliases(boolean declareTables)

Whether the current context is rendering a SQL alias declarations in declareTables() or declareFields() sections.

public C
declareAliases(boolean declareTables, Consumer<? super C> consumer)

Whether the current context is rendering a SQL alias declarations in declareTables() or declareFields() sections for the scope of a Consumer.

public boolean
declareCTE()

Whether the current context is rendering a common table expression (e.g. a CommonTableExpression in the WITH clause of the query).

public C
declareCTE(boolean declareCTE)

Set the new context value for declareCTE().

public C
declareCTE(boolean declareCTE, Consumer<? super C> consumer)

Set the new context value for declareCTE() for the scope of a Consumer.

public boolean
declareFields()

Whether the current context is rendering a SQL field declaration (e.g. a Field in the SELECT clause of the query).

public C
declareFields(boolean declareFields)

Set the new context value for declareFields().

public C
declareFields(boolean declareFields, Consumer<? super C> consumer)

Set the new context value for declareFields() for the scope of a Consumer.

public boolean
declareTables()

Whether the current context is rendering a SQL table declaration (e.g. a Table in the FROM or JOIN clause of the query).

public C
declareTables(boolean declareTables)

Set the new context value for declareTables().

public C
declareTables(boolean declareTables, Consumer<? super C> consumer)

Set the new context value for declareTables() for the scope of a Consumer.

public boolean
declareWindows()

Whether the current context is rendering a SQL window declaration (e.g. a WindowDefinition in the WINDOW clause of the query).

public C
declareWindows(boolean declareWindows)

Set the new context value for declareWindows().

public C
declareWindows(boolean declareWindows, Consumer<? super C> consumer)

Set the new context value for declareWindows() for the scope of a Consumer.

public boolean
derivedTableSubquery()

Whether the current context is rendering a derived table subquery.

public C
derivedTableSubquery(boolean derivedTableSubquery)

Set the new context value for derivedTableSubquery().

public DecimalFormat
doubleFormat()

A formatter to produce scientific notation for Double types.

public C
end(Clause clause)

Deprecated as a consequence of Clause being deprecated.
public DecimalFormat
floatFormat()

A formatter to produce scientific notation for Float types.

public C
format(boolean format)

Override the value of Settings#isRenderFormatted().

public boolean
public C
formatIndentEnd()

Stop indenting subsequent SQL by one level (two characters), if Settings#isRenderFormatted() is set to true.

public C
formatIndentEnd(int indent)

Stop indenting subsequent SQL by a number of characters, if Settings#isRenderFormatted() is set to true.

public C
formatIndentLockEnd()

Deprecated for removal since 3.14. - [#10317] - 3.14.0 - Do not reuse this method. It will be removed without replacement.
Stop indenting subsequent SQL at the same level as the current line, if Settings#isRenderFormatted() is set to true.
public C
formatIndentLockStart()

Deprecated for removal since 3.14. - [#10317] - 3.14.0 - Do not reuse this method. It will be removed without replacement.
Start indenting subsequent SQL at the same level as the current line, if Settings#isRenderFormatted() is set to true.
public C
formatIndentStart()

Start indenting subsequent SQL by one level (two characters), if Settings#isRenderFormatted() is set to true.

public C
formatIndentStart(int indent)

Start indenting subsequent SQL by a number of characters, if Settings#isRenderFormatted() is set to true.

public C
formatNewLine()

Render a new line character (only if Settings#isRenderFormatted() is set to true).

public C
formatNewLineAfterPrintMargin()

Render a new line character (only if Settings#isRenderFormatted() is set to true, and the formatPrintMargin(int) has been exceeded).

public C
formatPrintMargin(int margin)

Set a print margin that will be applied to formatted SQL, if Settings#isRenderFormatted() is set to true.

public C
formatSeparator()

Render a new line character (only if Settings#isRenderFormatted() is set to true), or a whitespace separator character otherwise.

public C
keyword(String keyword)

Deprecated for removal since 3.10. - 3.10.0 - [#4990] - Use DSL#keyword(String) instead.
Append a SQL keyword to the context's contained StringBuilder.
public @NotNull LanguageContext
languageContext()

The current language context.

public C
languageContext(LanguageContext languageContext)

Set the new language context for languageContext()

public C
languageContext(LanguageContext languageContext, Consumer<? super C> consumer)

Set the new language context for languageContext() for the scope of a Consumer.

public C
languageContext(LanguageContext languageContext, QueryPart topLevelForLanguageContext, Consumer<? super C> consumer)

Set the new language context for languageContext() for the scope of a Consumer.

public C
languageContextIf(LanguageContext languageContext, boolean condition)

Set the new language context for languageContext(), if a condition is true.

public C
literal(String literal)

Deprecated for removal since 3.10. - 3.10.0 - [#4990] - Use any of DSL#name(String), DSL#quotedName(String) or DSL#unquotedName(String) instead.
Append some literal to the context's contained StringBuilder.
public @NotNull String
nextAlias()

Return a new alias that is unique for the scope of one query.

public int
nextIndex()

Get the next bind index.

public @NotNull ParamType
paramType()

Specify, how bind values should be rendered.

public C
paramType(ParamType paramType)

Set the new context value for paramType().

public C
paramType(ParamType paramType, Consumer<? super C> runnable)

Set the new context value for paramType() for the scope of a Consumer.

public C
paramTypeIf(ParamType paramType, boolean condition)

Set the new context value for paramType(), if a condition is true.

public C
paramTypeIf(ParamType paramType, boolean condition, Consumer<? super C> runnable)

Set the new context value for paramType() for the scope of a Consumer, if a condition is true.

public @NotNull String
peekAlias()

Peek the next alias that will be generated by nextAlias().

public int
peekIndex()

Peek the next bind index.

public boolean
predicandSubquery()

Whether the current context is rendering a predicand subquery, i.e. a subquery that is an operand of a predicate.

public C
predicandSubquery(boolean predicandSubquery)

Set the new context value for predicandSubquery().

public boolean
qualify()

Whether query parts should render qualified names or not.

public C
qualify(boolean qualify)

Set the new context value for qualify().

public C
qualify(boolean qualify, Consumer<? super C> consumer)

Set the new context value for qualify() for the scope of a Consumer.

public boolean
qualifyCatalog()

Whether query parts should render qualified names or not.

public C
qualifyCatalog(boolean qualifyCatalog)

Set the new context value for qualifyCatalog().

public C
qualifyCatalog(boolean qualifyCatalog, Consumer<? super C> consumer)

Set the new context value for qualifyCatalog() for the scope of a Consumer.

public boolean
qualifySchema()

Whether query parts should render qualified names or not.

public C
qualifySchema(boolean qualifySchema)

Set the new context value for qualifySchema().

public C
qualifySchema(boolean qualifySchema, Consumer<? super C> consumer)

Set the new context value for qualifySchema() for the scope of a Consumer.

public boolean
quote()

Whether Name parts (and literal(String)) should be quoted.

public C
quote(boolean quote)

Set the new context value for quote().

public C
quote(boolean quote, Consumer<? super C> consumer)

Set the new context value for quote() for the scope of a Consumer.

public @NotNull String
render()

Render the context's underlying SQL statement.

public @NotNull String
render(QueryPart part)

Render a query part in a new context derived from this one.

public C
scopeEnd()

End a previous SELECT scope.

public int
scopeLevel()

Which level of scopes we're currently in, starting with 0 for the top scope.

public @NotNull QueryPart
scopeMapping(QueryPart part)

Retrieve the registered mapping for a query part in the current scope.

public C
scopeMarkEnd(QueryPart part)

Mark the end of a scoped query part.

public C
scopeMarkStart(QueryPart part)

Mark the beginning of a scoped query part.

public C
scopeRegister(QueryPart part)

Register a "special" query part in the scope, reusing the object from a higher scope, if available.

public C
scopeRegister(QueryPart part, boolean forceNew)

Register a "special" query part in the scope, allowing to force registering the object in the new scope, if a higher scope already has the object.

public C
scopeRegister(QueryPart part, boolean forceNew, QueryPart mapped)

Register a "special" query part in the scope, allowing to force registering the object in the new scope, if a higher scope already has the object, as well as providing a mapped part to map the original part to.

public C
public C
scopeStart()

Start a new scope.

public C
separatorRequired(boolean separatorRequired)

Specify that a separator will be required before the next visit(QueryPart) call, but leave the decision whether to generate a formatSeparator() or just a whitespace to that next QueryPart.

public boolean
separatorRequired()

Whether some sort of separator is required before rendering the next QueryPart.

public boolean
setOperationSubquery()

Whether the current context is rendering a set operation subquery.

public C
setOperationSubquery(boolean setOperationSubquery)

Set the new context value for setOperationSubquery().

public C
skipUpdateCount()

Skip an additional update count produced by this query.

public C
skipUpdateCounts(int skip)

Skip a number of additional update counts produced by this query.

public int
skipUpdateCounts()

The number of update counts to be skipped by this query.

public C
sql(String sql)

Append some SQL to the context's contained StringBuilder.

public C
sql(String sql, boolean literal)

Append some SQL to the context's contained StringBuilder.

public C
sql(char sql)

Append some SQL to the context's contained StringBuilder.

public C
sql(int sql)

Append some SQL to the context's contained StringBuilder.

public C
sql(long sql)

Append some SQL to the context's contained StringBuilder.

public C
sql(float sql)

Append some SQL to the context's contained StringBuilder.

public C
sql(double sql)

Append some SQL to the context's contained StringBuilder.

public C
sqlIndentEnd(String sql)

Append some SQL to the context's contained StringBuilder preceded by the usual calls to formatIndentEnd() and formatNewLine().

public C
sqlIndentEnd()

Append some SQL to the context's contained StringBuilder preceded by the usual calls to formatIndentEnd() and formatNewLine().

public C
sqlIndentEnd(char sql)

Append some SQL to the context's contained StringBuilder preceded by the usual calls to formatIndentEnd() and formatNewLine().

public C
sqlIndentStart(String sql)

Append some SQL to the context's contained StringBuilder, followed by the usual calls to formatIndentStart() and formatNewLine().

public C
sqlIndentStart()

Append some SQL to the context's contained StringBuilder, followed by the usual calls to formatIndentStart() and formatNewLine().

public C
sqlIndentStart(char sql)

Append some SQL to the context's contained StringBuilder, followed by the usual calls to formatIndentStart() and formatNewLine().

public C
start(Clause clause)

Deprecated as a consequence of Clause being deprecated.
TODO [#2667] Properties of these methods: - A clause is always started / ended, even if it isn't rendered or if it's empty!
public @Nullable PreparedStatement
statement()

Retrieve the context's underlying PreparedStatement if available, or null if this traversal does not operate on a PreparedStatement.

public boolean
stringLiteral()

whether the current context is rendering a string literal.

public C
stringLiteral(boolean stringLiteral)

Set the new context value for stringLiteral().

public boolean
subquery()

Whether the current context is rendering a subquery (nested query).

public C
subquery(boolean subquery)

Set the new context value for subquery().

public int
subqueryLevel()

Which level of subqueries we're currently in, starting with 0 for the top level query.

public @Nullable QueryPart
topLevel()

The top level QueryPart that is being rendered.

public C
topLevel(QueryPart topLevel)

Set the top level QueryPart that is being rendered.

public @Nullable QueryPart
topLevelForLanguageContext()

The top level QueryPart that is being rendered in the current languageContext().

public C
topLevelForLanguageContext(QueryPart topLevelForLanguageContext)

Set the top level QueryPart that is being rendered in the current languageContext().

public C
visit(QueryPart
The component QueryPart
part
)

Visit a QueryPart in the current Context.

public C
visit(Condition part)

Deprecated as a consequence of Condition being deprecated.
Visit a Condition as an ordinary QueryPart.
public C
visit(Field<?> part)

Deprecated as a consequence of Field being deprecated.
Visit a Field as a DSL#field(Condition), if it is a Condition, or as an ordinery QueryPart, otherwise.
public C
visit(QueryPart part, ParamType paramType)

Visit a query part with a given value for paramType().

public C
visitSubquery(QueryPart
The component QueryPart
part
)

Visit a QueryPart as a subquery in the current Context.

Inherited from org.jooq.ExecuteScope:
converterContextexecuteContext