home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / prosrc.bin / Cursor.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  1.8 KB  |  79 lines

  1. /*
  2.  * @(#)Cursor.java
  3.  *
  4.  * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
  5.  *
  6.  */
  7.  /**
  8.  * <P> Keeps track of the current position in the Expandable Set
  9.  * and sets and returns its value.
  10.  */
  11.  
  12. package symantec.itools.db.beans.binding;
  13.  
  14.  
  15.    class Cursor
  16. {
  17.     String          m_Name;
  18.     int             m_Position;
  19.     Object          m_FocusObject;
  20.     ExpandableSet   m_ExpandableSet;
  21.  
  22.     //Constructors
  23.     /**
  24.     * Constructor. Creates a cursor from a name and an expandable set
  25.     *
  26.     * @param       name.           Name.
  27.     * @param       set.            The result set coming from the data base
  28.     */
  29.  
  30.     Cursor (String name, ExpandableSet set) {
  31.         m_Name = name;
  32.         m_Position = -1;
  33.         m_ExpandableSet = set;
  34.     }
  35.  
  36.     /**
  37.      * Gets the position of the current row
  38.      * @return   int.    The position of the current row.
  39.      */
  40.     int getPosition() {
  41.         return m_Position;
  42.     }
  43.  
  44.     /**
  45.      * Sets the position of the current row
  46.      * @param   int.    The position of the current row.
  47.      */
  48.     void setPosition(int position) throws PositionOutOfRangeException {
  49.         if (position >= 0) {
  50.             try {
  51.                 m_FocusObject = m_ExpandableSet.getElementAt(position);
  52.                 m_Position = position;
  53.             }
  54.             catch (PositionOutOfRangeException e) {
  55.                 throw e;
  56.             }
  57.         }
  58.         else {
  59.             m_Position = position;
  60.         }
  61.     }
  62.  
  63.  
  64.     /**
  65.      * Gets  the current row
  66.      * @return   Object.    The current row.
  67.      */
  68.     public Object getFocusObject() {
  69.         return m_FocusObject;
  70.     }
  71.  
  72.     /**
  73.      * Sets  the current row
  74.      * @param   Object.    The current row.
  75.      */
  76.     void setFocusObject(Object focus) {
  77.         m_FocusObject = focus;
  78.     }
  79. }