Class RemoteResultSetCursorImpl<T extends PersistentDomainObject<T>>
java.lang.Object
org.tentackle.dbms.trip.RemoteDbDelegateImpl<T>
org.tentackle.persist.trip.RemoteResultSetCursorImpl<T>
- Type Parameters:
T- the object type
- All Implemented Interfaces:
RemoteDbDelegate, RemoteResultSetCursor<T>, Remote
public class RemoteResultSetCursorImpl<T extends PersistentDomainObject<T>>
extends RemoteDbDelegateImpl<T>
implements RemoteResultSetCursor<T>
Remote delegate implementation for
ResultSetCursor.- Author:
- harald
-
Constructor Summary
ConstructorsConstructorDescriptionRemoteResultSetCursorImpl(RemoteDbSessionImpl session, Class<T> clazz) Creates a remote cursor delegate. -
Method Summary
Modifier and TypeMethodDescriptionintPositions the cursor after the last row.
Works even for empty cursors.voidPositions the cursor before the first row.
Works even for empty cursors.voidclose()Closes the cursor.
Closing an already closed cursor is allowed.voidconfigureDelegate(Object... args) Configures the delegate.
Invoked fromRemoteDbSessionImpl.createRemoteDelegateInstance(Class, Class, Class, Class, Object...)by reflection.fetch()Fetches the next PDOs up to the fetch size.
This method is provided to minimize the number of round trips.booleanfirst()Rewinds the cursor to the first row.get()Gets the PDO of the current row.Gets the local cursor.intGets the fetch direction.intGets the fetch size.booleanChecks whether the cursor is after the last row.intlast()Positions the cursor on the last row.booleannext()Moves the cursor to the next row.
If there are no more rows the current row remains unchanged.booleanprevious()Moves the cursor to the previous row.
If there is no previous row, the cursor is positioned before the first row.intscroll(int rows) Moves the cursor a given number of rows.voidsetCursor(ResultSetCursor<T> cursor) Sets the local cursor.voidsetFetchDirection(int direction) Sets the fetch direction.voidsetFetchSize(int rows) Sets the fetch size.
This is the number of rows the cursor will fetch from the server in one batch.intsetRow(int row) Sets the cursor to a given row.
Row numbers start at 1.toList()Returns the PDOs of this cursor as a list.
The cursor is rewound to the first row before.toString()Methods inherited from class RemoteDbDelegateImpl
getServerSession, getServicedClass, getSession, initialize
-
Constructor Details
-
RemoteResultSetCursorImpl
Creates a remote cursor delegate.- Parameters:
session- the TRIP sessionclazz- the PDO interface class
-
-
Method Details
-
toString
- Overrides:
toStringin classRemoteDbDelegateImpl<T extends PersistentDomainObject<T>>
-
configureDelegate
Configures the delegate.
Invoked fromRemoteDbSessionImpl.createRemoteDelegateInstance(Class, Class, Class, Class, Object...)by reflection.- Parameters:
args- the configuration parameters
-
setCursor
Sets the local cursor.- Parameters:
cursor- the cursor
-
getCursor
-
afterLast
public int afterLast()Description copied from interface:RemoteResultSetCursorPositions the cursor after the last row.
Works even for empty cursors.- Specified by:
afterLastin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- the current row
-
beforeFirst
public void beforeFirst()Description copied from interface:RemoteResultSetCursorPositions the cursor before the first row.
Works even for empty cursors.- Specified by:
beforeFirstin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>
-
close
public void close()Description copied from interface:RemoteResultSetCursorCloses the cursor.
Closing an already closed cursor is allowed.- Specified by:
closein interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>
-
first
public boolean first()Description copied from interface:RemoteResultSetCursorRewinds the cursor to the first row.- Specified by:
firstin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- true if rewound, false if cursor is empty
-
get
Description copied from interface:RemoteResultSetCursorGets the PDO of the current row.- Specified by:
getin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- the PDO, null if invalid row or no such PDO
-
isAfterLast
public boolean isAfterLast()Description copied from interface:RemoteResultSetCursorChecks whether the cursor is after the last row.- Specified by:
isAfterLastin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- true if after last
-
last
public int last()Description copied from interface:RemoteResultSetCursorPositions the cursor on the last row.- Specified by:
lastin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- the current row, 0 if cursor is empty
-
next
public boolean next()Description copied from interface:RemoteResultSetCursorMoves the cursor to the next row.
If there are no more rows the current row remains unchanged.- Specified by:
nextin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- true if moved, false if no more rows
-
previous
public boolean previous()Description copied from interface:RemoteResultSetCursorMoves the cursor to the previous row.
If there is no previous row, the cursor is positioned before the first row.- Specified by:
previousin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- true if moved, false if already at or before the first row
-
setRow
public int setRow(int row) Description copied from interface:RemoteResultSetCursorSets the cursor to a given row.
Row numbers start at 1.- Specified by:
setRowin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Parameters:
row- the row number (must be ≥ 0)- Returns:
- the current row number after positioning
-
scroll
public int scroll(int rows) Description copied from interface:RemoteResultSetCursorMoves the cursor a given number of rows.- Specified by:
scrollin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Parameters:
rows- the number of rows to move, negative to move backwards- Returns:
- the current row number after positioning
-
toList
Description copied from interface:RemoteResultSetCursorReturns the PDOs of this cursor as a list.
The cursor is rewound to the first row before.- Specified by:
toListin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- the list
-
setFetchSize
public void setFetchSize(int rows) Description copied from interface:RemoteResultSetCursorSets the fetch size.
This is the number of rows the cursor will fetch from the server in one batch. A fetch size of 0 means server default.- Specified by:
setFetchSizein interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Parameters:
rows- the fetch size
-
getFetchSize
public int getFetchSize()Description copied from interface:RemoteResultSetCursorGets the fetch size.- Specified by:
getFetchSizein interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- the fetch size
-
setFetchDirection
public void setFetchDirection(int direction) Description copied from interface:RemoteResultSetCursorSets the fetch direction.- Specified by:
setFetchDirectionin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Parameters:
direction- the direction, seeResultSet.setFetchDirection(int)
-
getFetchDirection
public int getFetchDirection()Description copied from interface:RemoteResultSetCursorGets the fetch direction.- Specified by:
getFetchDirectionin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- the direction
-
fetch
Description copied from interface:RemoteResultSetCursorFetches the next PDOs up to the fetch size.
This method is provided to minimize the number of round trips. The cursor is closed when its end is reached, and the returned list is marked as closed.- Specified by:
fetchin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- the list of PDOs, null if the cursor is already closed or no more PDOs found
-