public class AdaptiveFind
extends java.lang.Object
AdaptiveQuery which may begin in dynamic record
retrieval mode. If so, it switches to preselect mode as soon as possible. It is intended as the backing
implementation for converted FIND statements which can be executed in succession without requiring a new
query to be executed for each record retrieved. Candidates are combinations of FIND FIRST/NEXT and
FIND LAST/PREV, or instances of FIND NEXT and FIND PREV which operate in loops.
This type of query by its nature operates only on a single table and therefore on a single record buffer. If the record buffer already is in use, its latest record is used as a reference point for the next record to be retrieved and the query is initialized in dynamic mode. Otherwise, the query is initialized in preselect mode.
The wrapped query will always be re-created if the query's buffers (saved
at the AdaptiveFind's instantiation) have been bound to other buffers (i.e. the referenced buffer
has switched).
| Modifier and Type | Class and Description |
|---|---|
private class |
AdaptiveFind.AdaptiveFindQuery
The wrapped query to which the query navigation calls are delegated.
|
| Modifier and Type | Field and Description |
|---|---|
private DataModelObject |
dmo
The original DMO reference used to create this instance.
|
private DataModelObject[] |
externalDMOs
The original external DMOs references used for initialization.
|
private java.util.List<java.util.function.Consumer<AdaptiveFind.AdaptiveFindQuery>> |
init
|
private boolean |
initialized
Flag indicating whether this object has been initialized
|
private AdaptiveFind.AdaptiveFindQuery |
query
The real wrapped query.
|
| Constructor and Description |
|---|
AdaptiveFind()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
checkQuery()
Check the query if the referenced buffers have changed their bound buffers.
|
private void |
createQuery()
Create the
query - this will apply all recorded initialization steps. |
boolean |
first()
Retrieve the first composite row of results for the query.
|
boolean |
first(LockType lockType)
Retrieve the first composite row of results for the query.
|
AdaptiveFind |
initialize(DataModelObject dmo,
java.lang.String where,
java.lang.String sort,
boolean inverseSorting,
DataModelObject... dmos)
Convenience deferred initializer designed for a single-table adaptive query.
|
AdaptiveFind |
initialize(DataModelObject dmo,
java.lang.String where,
java.lang.String sort,
DataModelObject... dmos)
Convenience deferred initializer designed for a single-table adaptive query.
|
AdaptiveFind |
initialize(DataModelObject dmo,
java.lang.String where,
java.lang.String sort,
LockType lockType,
DataModelObject... dmos)
Convenience deferred initializer designed for a single-table adaptive query.
|
boolean |
next()
Retrieve the next composite row of results for the query.
|
boolean |
next(LockType lockType)
Retrieve the next composite row of results for the query.
|
boolean |
silentFirst()
Retrieve the first composite row of results for the query.
|
boolean |
silentFirst(LockType lockType)
Retrieve the first composite row of results for the query.
|
boolean |
silentNext()
Retrieve the next composite row of results for the query.
|
boolean |
silentNext(LockType lockType)
Retrieve the next composite row of results for the query.
|
private AdaptiveFind.AdaptiveFindQuery query
private java.util.List<java.util.function.Consumer<AdaptiveFind.AdaptiveFindQuery>> init
private boolean initialized
private DataModelObject dmo
private DataModelObject[] externalDMOs
public AdaptiveFind()
initialize() is called.public AdaptiveFind initialize(DataModelObject dmo, java.lang.String where, java.lang.String sort, DataModelObject... dmos)
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.sort - FQL order by clause.dmos - Zero or more external buffers.this) so that chaining can be used.public AdaptiveFind initialize(DataModelObject dmo, java.lang.String where, java.lang.String sort, LockType lockType, DataModelObject... dmos)
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.sort - FQL order by clause.lockType - Lock type to apply to records retrieved by this query.dmos - Zero or more external buffers.this) so that chaining can be used.public AdaptiveFind initialize(DataModelObject dmo, java.lang.String where, java.lang.String sort, boolean inverseSorting, DataModelObject... dmos)
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.sort - FQL order by clause.inverseSorting - Whether this query has the inverse sorting direction.dmos - Zero or more external buffers.this) so that chaining can be used.public boolean next()
true if query could retrive the next record successfully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records are available and the query is
set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail in this case.java.lang.IllegalStateException - if no query component has been added to this query.public boolean next(LockType lockType)
lockType - Lock type to apply to records retrieved (overrides default lock type set for each query
component).true if query could retrive the next record successfully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records are available and the query is
set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail in this case.java.lang.IllegalStateException - if no query component has been added to this query.public boolean silentNext()
This operation is executed in silent mode.
true if query could retrive the next record successfully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records are available and the query is
set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail in this case.java.lang.IllegalStateException - if no query component has been added to this query.public boolean silentNext(LockType lockType)
This operation is executed in silent mode.
lockType - Lock type to apply to records retrieved (overrides default lock type set for each query
component).true if query could retrive the next record successfully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records are available and the query is
set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail in this case.java.lang.IllegalStateException - if no query component has been added to this query.public boolean first()
true if query could retrive the first record successfully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records are available and the query is
set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail in this case.java.lang.IllegalStateException - if no query component has been added to this query.public boolean first(LockType lockType)
lockType - Lock type to apply to records retrieved (overrides default lock type set for each query
component).true if query could retrive the first record successfully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records are available and the query is
set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail in this case.java.lang.IllegalStateException - if no query component has been added to this query.public boolean silentFirst()
This operation is executed in silent mode.
true if query could retrive the first record successfully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records are available and the query is
set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail in this case.java.lang.IllegalStateException - if no query component has been added to this query.public boolean silentFirst(LockType lockType)
This operation is executed in silent mode.
lockType - Lock type to apply to records retrieved (overrides default lock type set for each query
component).true if query could retrive the first record successfully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records are available and the query is
set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail in this case.java.lang.IllegalStateException - if no query component has been added to this query.private void createQuery()
query - this will apply all recorded initialization steps.private void checkQuery()
createQuery() will be initialized.