final class ResultsAdapter extends java.lang.Object implements Results
Results
interface which delegates all work to another Results
implementation. A worker can be connected at any time using setResults(com.goldencode.p2j.persist.Results)
, or
disconnected by passing a null
parameter to this method.
Client code may expire the current delegate worker by invoking the prepareDelegateChange()
method. This will cause the adapter to replace the delegate at the
next safe opportunity. This is accomplished by requesting a new Results
object from a
ResultsProvider
which is registered at construction time.
Modifier and Type | Field and Description |
---|---|
private boolean |
delegateNeeded
State flag indicating a new delegate worker must be installed
|
private ResultsProvider |
provider
Object which provides results to this adapter upon request
|
private Results |
results
Delegate worker object
|
Constructor and Description |
---|
ResultsAdapter(ResultsProvider provider)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
private void |
checkDelegate()
Check whether a new delegate worker is needed and if so, request the
ResultsProvider
registered with this object to create a new one and to attach it to this adapter. |
void |
cleanup()
Delegate cleanup to the underlying worker.
|
boolean |
first()
Move cursor to the first result row.
|
java.lang.Object[] |
get()
Get the array of objects at the current result row.
|
java.lang.Object |
get(int column)
Get the object at the current result row, at the specified column.
|
java.lang.Long |
getID(int column)
Get the primary key ID at the current result row, at the specified column.
|
(package private) Results |
getResults()
Get the underlying
Results worker object for this adapter. |
int |
getRowNumber()
Get the row number currently under the cursor.
|
(package private) boolean |
isConnected()
Report whether this adapter currently is connected to a delegate worker.
|
boolean |
isFirst()
Is the cursor on the first row in the result set?
|
boolean |
isLast()
Is the cursor on the last row in the result set?
|
boolean |
isResultSetCached()
Indicate whether the full result set is cached in this object.
|
boolean |
last()
Move cursor to the last result row.
|
boolean |
next()
Move cursor to the next result row.
|
(package private) void |
prepareDelegateChange()
Prepare for a disconnect and for a request for new delegate results from the results
provider.
|
boolean |
previous()
Move cursor to the previous result row.
|
void |
reset()
Reset the cursor to its natural starting position, before the first result row.
|
boolean |
scroll(int rows)
Scroll the cursor ahead by the specified number of rows.
|
void |
sessionClosing()
Give the underlying worker a chance to respond to a session closing event.
|
(package private) void |
setResults(Results results)
Set the underlying
Results worker object for this adapter. |
boolean |
setRowNumber(int row)
Set the row number currently under the cursor.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addRow, deleteRow, getNumberOfLoadedRows
private final ResultsProvider provider
private Results results
private boolean delegateNeeded
ResultsAdapter(ResultsProvider provider)
provider
- Object which provides results to this adapter upon request.public boolean first()
public boolean last()
public boolean next()
public boolean previous()
public boolean isFirst()
public boolean isLast()
public java.lang.Object[] get()
public java.lang.Object get(int column)
public java.lang.Long getID(int column)
public int getRowNumber()
getRowNumber
in interface Results
-1
if the cursor is not currently
on a result.java.lang.NullPointerException
- if the adapter is not connected
.public boolean setRowNumber(int row)
setRowNumber
in interface Results
row
- Zero-based index of the row to be set as the current row.true
if there is a row at the specified row number, else false
.java.lang.NullPointerException
- if the adapter is not connected
.public boolean scroll(int rows)
public void reset()
public void sessionClosing()
sessionClosing
in interface Results
Results.sessionClosing()
public void cleanup()
public boolean isResultSetCached()
isResultSetCached
in interface Results
true
if all results are contained this object; false
if not or
if unknown (such as for a scrolling or cursored result set. This implementation
passes on the invocation to the delegate results object, if any. If none, it
returns false
.void prepareDelegateChange()
Results getResults()
Results
worker object for this adapter.void setResults(Results results)
Results
worker object for this adapter.results
- Underlying delegate worker.boolean isConnected()
true
if there is a delegate Results
object connected to this
adapter, else false
.private void checkDelegate()
ResultsProvider
registered with this object to create a new one and to attach it to this adapter.