Module org.tentackle.persistence
Package org.tentackle.persist.rmi
Class RemoteResultSetCursorImpl<T extends org.tentackle.pdo.PersistentDomainObject<T>>
- java.lang.Object
-
- org.tentackle.dbms.rmi.RemoteDelegateImpl<T>
-
- org.tentackle.persist.rmi.RemoteResultSetCursorImpl<T>
-
- Type Parameters:
T- the object type
- All Implemented Interfaces:
java.rmi.Remote,org.tentackle.dbms.rmi.RemoteDelegate,RemoteResultSetCursor<T>
public class RemoteResultSetCursorImpl<T extends org.tentackle.pdo.PersistentDomainObject<T>> extends org.tentackle.dbms.rmi.RemoteDelegateImpl<T> implements RemoteResultSetCursor<T>
Remote delegate implementation forResultSetCursor.- Author:
- harald
-
-
Constructor Summary
Constructors Constructor Description RemoteResultSetCursorImpl(org.tentackle.dbms.rmi.RemoteDbSessionImpl session, java.lang.Class<T> clazz)Creates a remote cursor delegate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intafterLast()Positions the cursor after the last row.
Works even for empty cursors.voidbeforeFirst()Positions the cursor before the first row.
Works even for empty cursors.voidclose()Closes the scrollable resource.
The scrollable resource is opened in its constructor.voidconfigureDelegate(java.lang.Object... args)Configures the delegate.java.rmi.RemoteExceptioncreateException(java.lang.Throwable t)ResultSetCursor.FetchList<T>fetch()Fetches the next objects up to the fetchsize.
This method is provided to minimize the number of roundtrips especially for remote cursors.booleanfirst()Rewinds the cursor to the first row.Tget()Gets the data object of the current row.ResultSetCursor<T>getCursor()Gets the local cursor.intgetFetchDirection()Gets the fetch direction.intgetFetchSize()Gets the fetchsize.booleanisAfterLast()Checks whether the cursor is after the last row.intlast()Positions the cursor on the last row.booleannext()Moves the cursor to the next row.booleanprevious()Moves the cursor to the previous 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 fetchsize.
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.java.util.List<T>toList()Returns the objects of this cursor as a list.java.lang.StringtoString()
-
-
-
Constructor Detail
-
RemoteResultSetCursorImpl
public RemoteResultSetCursorImpl(org.tentackle.dbms.rmi.RemoteDbSessionImpl session, java.lang.Class<T> clazz)Creates a remote cursor delegate.- Parameters:
session- is the RMI sessionclazz- is the subclass of DbObject
-
-
Method Detail
-
toString
public java.lang.String toString()
-
configureDelegate
public void configureDelegate(java.lang.Object... args)
Configures the delegate.Invoked from
RemoteDbSessionImpl.createRemoteDelegateInstance(java.lang.Class<T>, java.lang.Class<I>, java.lang.Class<?>, java.lang.Class<?>, java.lang.Object...)by reflection.- Parameters:
args- the configuration paramaters
-
setCursor
public void setCursor(ResultSetCursor<T> cursor)
Sets the local cursor.- Parameters:
cursor- the cursor
-
getCursor
public ResultSetCursor<T> getCursor()
Gets the local cursor.- Returns:
- the local cursor
-
afterLast
public int afterLast() throws java.rmi.RemoteExceptionDescription copied from interface:RemoteResultSetCursorPositions the cursor after the last row.
Works even for empty cursors.- Specified by:
afterLastin interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Returns:
- the current row
- Throws:
java.rmi.RemoteException- if failed
-
beforeFirst
public void beforeFirst() throws java.rmi.RemoteExceptionDescription copied from interface:RemoteResultSetCursorPositions the cursor before the first row.
Works even for empty cursors.- Specified by:
beforeFirstin interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Throws:
java.rmi.RemoteException- if failed
-
close
public void close() throws java.rmi.RemoteExceptionDescription copied from interface:RemoteResultSetCursorCloses the scrollable resource.
The scrollable resource is opened in its constructor. Closing an already closed scrollable resource is allowed.- Specified by:
closein interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Throws:
java.rmi.RemoteException- if failed
-
first
public boolean first() throws java.rmi.RemoteExceptionDescription copied from interface:RemoteResultSetCursorRewinds the cursor to the first row.- Specified by:
firstin interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Returns:
- true if rewound, false if cursor is empty
- Throws:
java.rmi.RemoteException- if failed
-
get
public T get() throws java.rmi.RemoteException
Description copied from interface:RemoteResultSetCursorGets the data object of the current row.- Specified by:
getin interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Returns:
- the object, null if invalid row or no such object
- Throws:
java.rmi.RemoteException- if failed
-
isAfterLast
public boolean isAfterLast() throws java.rmi.RemoteExceptionDescription copied from interface:RemoteResultSetCursorChecks whether the cursor is after the last row.- Specified by:
isAfterLastin interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Returns:
- true if after last
- Throws:
java.rmi.RemoteException- if failed
-
last
public int last() throws java.rmi.RemoteExceptionDescription copied from interface:RemoteResultSetCursorPositions the cursor on the last row.- Specified by:
lastin interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Returns:
- the current row
- Throws:
java.rmi.RemoteException- if failed
-
next
public boolean next() throws java.rmi.RemoteExceptionDescription 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 org.tentackle.pdo.PersistentDomainObject<T>>- Returns:
- true if moved, false if no more rows
- Throws:
java.rmi.RemoteException- if failed
-
previous
public boolean previous() throws java.rmi.RemoteExceptionDescription copied from interface:RemoteResultSetCursorMoves the cursor to the previous row. If we are already at the beginning, the cursor remains unchanged.- Specified by:
previousin interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Returns:
- true if advanced, false if already at the beginning
- Throws:
java.rmi.RemoteException- if failed
-
setRow
public int setRow(int row) throws java.rmi.RemoteExceptionDescription copied from interface:RemoteResultSetCursorSets the cursor to a given row.
Row numbers start at 1.- Specified by:
setRowin interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Parameters:
row- the row number (must be ≥ 0)- Returns:
- the new row number
- Throws:
java.rmi.RemoteException- if failed
-
scroll
public int scroll(int rows) throws java.rmi.RemoteExceptionDescription copied from interface:RemoteResultSetCursorMoves the cursor a given number of rows.- Specified by:
scrollin interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Parameters:
rows- the number of rows to move, negative to move backwards- Returns:
- the current row
- Throws:
java.rmi.RemoteException- if failed
-
toList
public java.util.List<T> toList() throws java.rmi.RemoteException
Description copied from interface:RemoteResultSetCursorReturns the objects of this cursor as a list.- Specified by:
toListin interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Returns:
- the list
- Throws:
java.rmi.RemoteException- if failed
-
setFetchSize
public void setFetchSize(int rows) throws java.rmi.RemoteExceptionDescription copied from interface:RemoteResultSetCursorSets the fetchsize.
This is the number of rows the cursor will fetch from the server in one batch. A fetchsize of 0 means server default.- Specified by:
setFetchSizein interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Parameters:
rows- the fetchsize- Throws:
java.rmi.RemoteException- if failed
-
getFetchSize
public int getFetchSize() throws java.rmi.RemoteExceptionDescription copied from interface:RemoteResultSetCursorGets the fetchsize.- Specified by:
getFetchSizein interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Returns:
- the fetchsize
- Throws:
java.rmi.RemoteException- if failed
-
setFetchDirection
public void setFetchDirection(int direction) throws java.rmi.RemoteExceptionDescription copied from interface:RemoteResultSetCursorSets the fetch direction.- Specified by:
setFetchDirectionin interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Parameters:
direction- the direction, seeResultSet.setFetchDirection(int)- Throws:
java.rmi.RemoteException- if failed
-
getFetchDirection
public int getFetchDirection() throws java.rmi.RemoteExceptionDescription copied from interface:RemoteResultSetCursorGets the fetch direction.- Specified by:
getFetchDirectionin interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Returns:
- the direction
- Throws:
java.rmi.RemoteException- if failed
-
fetch
public ResultSetCursor.FetchList<T> fetch() throws java.rmi.RemoteException
Description copied from interface:RemoteResultSetCursorFetches the next objects up to the fetchsize.
This method is provided to minimize the number of roundtrips especially for remote cursors. The cursor is closed at the end of the cursor.- Specified by:
fetchin interfaceRemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Returns:
- the list of objects, null if no more objects found
- Throws:
java.rmi.RemoteException- if failed
-
-