Top Description Methods
org.jooq

public Interface Scope

Known Direct Subinterfaces
org.jooq.BindingScope, org.jooq.CacheContext, org.jooq.TransactionContext, org.jooq.VisitContext, org.jooq.ConverterContext, org.jooq.DiagnosticsContext, org.jooq.GeneratorContext, org.jooq.RecordContext, org.jooq.ResourceManagingScope, org.jooq.MigrationContext, org.jooq.ParseContext, org.jooq.DSLContext, org.jooq.ExecuteContext, org.jooq.Migration, org.jooq.ExecuteScope, org.jooq.Meta
Known Direct Implementers
org.jooq.impl.AbstractScope
Imports
java.time.Instant, java.util.Map, org.jooq.conf.Settings, org.jooq.impl.DSL, org.jetbrains.annotations.NotNull, .Nullable

Scope implementations provide access to a variety of objects that are available from a given scope.

The scope of the various objects contained in this type (e.g. configuration(), settings(), etc.) are implementation dependent and will be specified by the concrete subtype of Scope. Examples of such scope types are:

One of Scope's most interesting features for client code implementing any SPI is the data() map, which provides access to a Map where client code can register user-defined values for the entire lifetime of a scope. For instance, in an ExecuteListener implementation that measures time for fetching data, it is perfectly possible to store timestamps in that map:


class FetchTimeMeasuringListener extends DefaultExecuteListener {
    @Override
    public void fetchStart(ExecuteContext ctx) {

        // Put any arbitrary object in this map:
        ctx.data("org.jooq.example.fetch-start-time", System.nanoTime());
    }

    @Override
    public void fetchEnd(ExecuteContext ctx) {

        // Retrieve that object again in a later step:
        Long startTime = (Long) ctx.data("org.jooq.example.fetch-start-time");
        System.out.println("Time taken: " + (System.nanoTime() - startTime) / 1000 / 1000.0 + " ms");
    }
}

Author
Lukas Eder

Method Summary

Modifier and TypeMethod and Description
public @NotNull Configuration
configuration()

The configuration of the current scope.

public @NotNull Instant
creationTime()

The time, according to Configuration#clock(), when this Scope was created.

public @NotNull Map<Object, Object>

Returns:

The custom data. This is never null
data
()

Get all custom data from this Scope.

public @Nullable Object

Returns:

The custom data or null if no such data is contained in this Scope
data
(Object
A key to identify the custom data
key
)

Get some custom data from this Scope.

public @Nullable Object

Returns:

The previously set custom data or null if no data was previously set for the given key
data
(Object
A key to identify the custom data
key
,
Object
The custom data
value
)

Set some custom data to this Scope.

public @NotNull SQLDialect
dialect()

The SQLDialect wrapped by this context.

public @NotNull DSLContext
dsl()

Wrap the configuration() in a DSLContext, providing access to the configuration-contextual DSL to construct executable queries.

public @NotNull SQLDialect
family()

The SQLDialect#family() wrapped by this context.

public @NotNull Settings
settings()

The settings wrapped by this context.

Method Detail

configurationback to summary
public @NotNull Configuration configuration()

The configuration of the current scope.

Annotations
@NotNull
creationTimeback to summary
public @NotNull Instant creationTime()

The time, according to Configuration#clock(), when this Scope was created.

Annotations
@NotNull
databack to summary
public @NotNull Map<Object, Object> data()

Get all custom data from this Scope.

This is custom data that was previously set to the context using data(Object, Object). Use custom data if you want to pass data to QueryPart objects for a given Scope.

Returns:@NotNull Map<Object, Object>

The custom data. This is never null

Annotations
@NotNull
databack to summary
public @Nullable Object data(Object key)

Get some custom data from this Scope.

This is custom data that was previously set to the context using data(Object, Object). Use custom data if you want to pass data to QueryPart objects for a given Scope

Parameters
key:Object

A key to identify the custom data

Returns:@Nullable Object

The custom data or null if no such data is contained in this Scope

Annotations
@Nullable
databack to summary
public @Nullable Object data(Object key, Object value)

Set some custom data to this Scope.

This is custom data that was previously set to the context using data(Object, Object). Use custom data if you want to pass data to QueryPart objects for a given Scope.

Parameters
key:Object

A key to identify the custom data

value:Object

The custom data

Returns:@Nullable Object

The previously set custom data or null if no data was previously set for the given key

Annotations
@Nullable
dialectback to summary
public @NotNull SQLDialect dialect()

The SQLDialect wrapped by this context.

This method is a convenient way of accessing configuration().dialect().

Annotations
@NotNull
dslback to summary
public @NotNull DSLContext dsl()

Wrap the configuration() in a DSLContext, providing access to the configuration-contextual DSL to construct executable queries.

Annotations
@NotNull
familyback to summary
public @NotNull SQLDialect family()

The SQLDialect#family() wrapped by this context.

This method is a convenient way of accessing configuration().family().

Annotations
@NotNull
settingsback to summary
public @NotNull Settings settings()

The settings wrapped by this context.

This method is a convenient way of accessing configuration().settings().

Annotations
@NotNull