Module org.tentackle.persistence
Package org.tentackle.persist.rmi
Class RemoteResultSetCursorImpl<T extends 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:
Remote,RemoteDelegate,RemoteResultSetCursor<T>
public class RemoteResultSetCursorImpl<T extends PersistentDomainObject<T>> extends RemoteDelegateImpl<T> implements RemoteResultSetCursor<T>
Remote delegate implementation forResultSetCursor.- Author:
- harald
-
-
Constructor Summary
Constructors Constructor Description RemoteResultSetCursorImpl(RemoteDbSessionImpl session, 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(Object... args)Configures the delegate.RemoteExceptioncreateException(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.List<T>toList()Returns the objects of this cursor as a list.StringtoString()-
Methods inherited from class org.tentackle.dbms.rmi.RemoteDelegateImpl
getServerSession, getServicedClass, getSession, initialize
-
-
-
-
Constructor Detail
-
RemoteResultSetCursorImpl
public RemoteResultSetCursorImpl(RemoteDbSessionImpl session, Class<T> clazz)
Creates a remote cursor delegate.- Parameters:
session- is the RMI sessionclazz- is the subclass of DbObject
-
-
Method Detail
-
toString
public String toString()
- Overrides:
toStringin classRemoteDelegateImpl<T extends PersistentDomainObject<T>>
-
configureDelegate
public void configureDelegate(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 RemoteExceptionDescription 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
- Throws:
RemoteException- if failed
-
beforeFirst
public void beforeFirst() throws RemoteExceptionDescription copied from interface:RemoteResultSetCursorPositions the cursor before the first row.
Works even for empty cursors.- Specified by:
beforeFirstin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Throws:
RemoteException- if failed
-
close
public void close() throws 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 PersistentDomainObject<T>>- Throws:
RemoteException- if failed
-
first
public boolean first() throws RemoteExceptionDescription 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
- Throws:
RemoteException- if failed
-
get
public T get() throws RemoteException
Description copied from interface:RemoteResultSetCursorGets the data object of the current row.- Specified by:
getin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- the object, null if invalid row or no such object
- Throws:
RemoteException- if failed
-
isAfterLast
public boolean isAfterLast() throws RemoteExceptionDescription 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
- Throws:
RemoteException- if failed
-
last
public int last() throws RemoteExceptionDescription copied from interface:RemoteResultSetCursorPositions the cursor on the last row.- Specified by:
lastin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- the current row
- Throws:
RemoteException- if failed
-
next
public boolean next() throws 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 PersistentDomainObject<T>>- Returns:
- true if moved, false if no more rows
- Throws:
RemoteException- if failed
-
previous
public boolean previous() throws 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 PersistentDomainObject<T>>- Returns:
- true if advanced, false if already at the beginning
- Throws:
RemoteException- if failed
-
setRow
public int setRow(int row) throws RemoteExceptionDescription 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 new row number
- Throws:
RemoteException- if failed
-
scroll
public int scroll(int rows) throws RemoteExceptionDescription 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
- Throws:
RemoteException- if failed
-
toList
public List<T> toList() throws RemoteException
Description copied from interface:RemoteResultSetCursorReturns the objects of this cursor as a list.- Specified by:
toListin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- the list
- Throws:
RemoteException- if failed
-
setFetchSize
public void setFetchSize(int rows) throws 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 PersistentDomainObject<T>>- Parameters:
rows- the fetchsize- Throws:
RemoteException- if failed
-
getFetchSize
public int getFetchSize() throws RemoteExceptionDescription copied from interface:RemoteResultSetCursorGets the fetchsize.- Specified by:
getFetchSizein interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- the fetchsize
- Throws:
RemoteException- if failed
-
setFetchDirection
public void setFetchDirection(int direction) throws RemoteExceptionDescription copied from interface:RemoteResultSetCursorSets the fetch direction.- Specified by:
setFetchDirectionin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Parameters:
direction- the direction, seeResultSet.setFetchDirection(int)- Throws:
RemoteException- if failed
-
getFetchDirection
public int getFetchDirection() throws RemoteExceptionDescription copied from interface:RemoteResultSetCursorGets the fetch direction.- Specified by:
getFetchDirectionin interfaceRemoteResultSetCursor<T extends PersistentDomainObject<T>>- Returns:
- the direction
- Throws:
RemoteException- if failed
-
fetch
public ResultSetCursor.FetchList<T> fetch() throws 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 PersistentDomainObject<T>>- Returns:
- the list of objects, null if no more objects found
- Throws:
RemoteException- if failed
-
createException
public RemoteException createException(Throwable t)
- Overrides:
createExceptionin classRemoteDelegateImpl<T extends PersistentDomainObject<T>>
-
-