Class RemoteResultSetCursorImpl<T extends org.tentackle.pdo.PersistentDomainObject<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 for ResultSetCursor.
    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
      int afterLast()
      Positions the cursor after the last row.
      Works even for empty cursors.
      void beforeFirst()
      Positions the cursor before the first row.
      Works even for empty cursors.
      void close()
      Closes the scrollable resource.
      The scrollable resource is opened in its constructor.
      void configureDelegate​(java.lang.Object... args)
      Configures the delegate.
      java.rmi.RemoteException createException​(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.
      boolean first()
      Rewinds the cursor to the first row.
      T get()
      Gets the data object of the current row.
      ResultSetCursor<T> getCursor()
      Gets the local cursor.
      int getFetchDirection()
      Gets the fetch direction.
      int getFetchSize()
      Gets the fetchsize.
      boolean isAfterLast()
      Checks whether the cursor is after the last row.
      int last()
      Positions the cursor on the last row.
      boolean next()
      Moves the cursor to the next row.
      boolean previous()
      Moves the cursor to the previous row.
      int scroll​(int rows)
      Moves the cursor a given number of rows.
      void setCursor​(ResultSetCursor<T> cursor)
      Sets the local cursor.
      void setFetchDirection​(int direction)
      Sets the fetch direction.
      void setFetchSize​(int rows)
      Sets the fetchsize.
      This is the number of rows the cursor will fetch from the server in one batch.
      int setRow​(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.String toString()  
      • Methods inherited from class org.tentackle.dbms.rmi.RemoteDelegateImpl

        getServerSession, getServicedClass, getSession, initialize
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 session
        clazz - is the subclass of DbObject
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class org.tentackle.dbms.rmi.RemoteDelegateImpl<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • 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.RemoteException
        Description copied from interface: RemoteResultSetCursor
        Positions the cursor after the last row.
        Works even for empty cursors.
        Specified by:
        afterLast in interface RemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the current row
        Throws:
        java.rmi.RemoteException - if failed
      • beforeFirst

        public void beforeFirst()
                         throws java.rmi.RemoteException
        Description copied from interface: RemoteResultSetCursor
        Positions the cursor before the first row.
        Works even for empty cursors.
        Specified by:
        beforeFirst in interface RemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Throws:
        java.rmi.RemoteException - if failed
      • close

        public void close()
                   throws java.rmi.RemoteException
        Description copied from interface: RemoteResultSetCursor
        Closes the scrollable resource.
        The scrollable resource is opened in its constructor. Closing an already closed scrollable resource is allowed.
        Specified by:
        close in interface RemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Throws:
        java.rmi.RemoteException - if failed
      • first

        public boolean first()
                      throws java.rmi.RemoteException
        Description copied from interface: RemoteResultSetCursor
        Rewinds the cursor to the first row.
        Specified by:
        first in interface RemoteResultSetCursor<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: RemoteResultSetCursor
        Gets the data object of the current row.
        Specified by:
        get in interface RemoteResultSetCursor<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.RemoteException
        Description copied from interface: RemoteResultSetCursor
        Checks whether the cursor is after the last row.
        Specified by:
        isAfterLast in interface RemoteResultSetCursor<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.RemoteException
        Description copied from interface: RemoteResultSetCursor
        Positions the cursor on the last row.
        Specified by:
        last in interface RemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the current row
        Throws:
        java.rmi.RemoteException - if failed
      • next

        public boolean next()
                     throws java.rmi.RemoteException
        Description copied from interface: RemoteResultSetCursor
        Moves the cursor to the next row. If there are no more rows the current row remains unchanged.
        Specified by:
        next in interface RemoteResultSetCursor<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.RemoteException
        Description copied from interface: RemoteResultSetCursor
        Moves the cursor to the previous row. If we are already at the beginning, the cursor remains unchanged.
        Specified by:
        previous in interface RemoteResultSetCursor<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.RemoteException
        Description copied from interface: RemoteResultSetCursor
        Sets the cursor to a given row.
        Row numbers start at 1.
        Specified by:
        setRow in interface RemoteResultSetCursor<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.RemoteException
        Description copied from interface: RemoteResultSetCursor
        Moves the cursor a given number of rows.
        Specified by:
        scroll in interface RemoteResultSetCursor<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: RemoteResultSetCursor
        Returns the objects of this cursor as a list.
        Specified by:
        toList in interface RemoteResultSetCursor<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.RemoteException
        Description copied from interface: RemoteResultSetCursor
        Sets 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:
        setFetchSize in interface RemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Parameters:
        rows - the fetchsize
        Throws:
        java.rmi.RemoteException - if failed
      • getFetchSize

        public int getFetchSize()
                         throws java.rmi.RemoteException
        Description copied from interface: RemoteResultSetCursor
        Gets the fetchsize.
        Specified by:
        getFetchSize in interface RemoteResultSetCursor<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.RemoteException
        Description copied from interface: RemoteResultSetCursor
        Sets the fetch direction.
        Specified by:
        setFetchDirection in interface RemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Parameters:
        direction - the direction, see ResultSet.setFetchDirection(int)
        Throws:
        java.rmi.RemoteException - if failed
      • getFetchDirection

        public int getFetchDirection()
                              throws java.rmi.RemoteException
        Description copied from interface: RemoteResultSetCursor
        Gets the fetch direction.
        Specified by:
        getFetchDirection in interface RemoteResultSetCursor<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: RemoteResultSetCursor
        Fetches 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:
        fetch in interface RemoteResultSetCursor<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the list of objects, null if no more objects found
        Throws:
        java.rmi.RemoteException - if failed
      • createException

        public java.rmi.RemoteException createException​(java.lang.Throwable t)
        Overrides:
        createException in class org.tentackle.dbms.rmi.RemoteDelegateImpl<T extends org.tentackle.pdo.PersistentDomainObject<T>>