⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csvscrollablereader.java

📁 神经网络命令行工具
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
          //Changed By Chetan
          //# line = input.readLine();
          line = (String) alRecordsArray.get(++iRecordArrayNo);

          //#} catch (IOException e) {
          //#  throw new SQLException(e.toString());
        } finally {
        }
      } else {
        fullLine = 1;
      }
    }

    String[] retVal = new String[values.size()];
    values.copyInto(retVal);

    return retVal;
  }

  /**
   * Method close.
   */
  public void close() {
    alRecordNos = null;
    alRecordsArray = null;
  }

  /**
   *Description of the Method
   *
   * @return                Description of the Returned Value
   * @exception  SQLException  Description of Exception
   * @since
   */
  public boolean next() throws SQLException {
    ++iRecordNo;

    return readData();
  }

  /**
  * Moves the cursor to the previous row in this
  * <code>ResultSet</code> object.
  *
  * @return <code>true</code> if the cursor is on a valid row;
  * <code>false</code> if it is off the result set
  * @exception SQLException if a database access error
  * occurs or the result set type is <code>TYPE_FORWARD_ONLY</code>
  */
  public boolean previous() throws SQLException {
    --iRecordNo;

    return readData();
  }

  /**
   * Retrieves whether the cursor is before the first row in
   * this <code>ResultSet</code> object.
   *
   * @return <code>true</code> if the cursor is before the first row;
   * <code>false</code> if the cursor is at any other position or the
   * result set contains no rows
   * @exception SQLException if a database access error occurs
   */
  public boolean isBeforeFirst() throws SQLException {
    return (getRecordNo() < FIRST_RECORD);
  }

  /**
   * Retrieves whether the cursor is after the last row in
   * this <code>ResultSet</code> object.
   *
   * @return <code>true</code> if the cursor is after the last row;
   * <code>false</code> if the cursor is at any other position or the
   * result set contains no rows
   * @exception SQLException if a database access error occurs
   */
  public boolean isAfterLast() throws SQLException {
    return (getRecordNo() >= alRecordNos.size());
  }

  /**
   * Retrieves whether the cursor is on the first row of
   * this <code>ResultSet</code> object.
   *
   * @return <code>true</code> if the cursor is on the first row;
   * <code>false</code> otherwise
   * @exception SQLException if a database access error occurs
   */
  public boolean isFirst() throws SQLException {
    return (getRecordNo() == FIRST_RECORD);
  }

  /**
   * Retrieves whether the cursor is on the last row of
   * this <code>ResultSet</code> object.
   * Note: Calling the method <code>isLast</code> may be expensive
   * because the JDBC driver
   * might need to fetch ahead one row in order to determine
   * whether the current row is the last row in the result set.
   *
   * @return <code>true</code> if the cursor is on the last row;
   * <code>false</code> otherwise
   * @exception SQLException if a database access error occurs
   */
  public boolean isLast() throws SQLException {
    return (getRecordNo() == (alRecordNos.size() - 1)); //as its 0 is considered
  }

  /**
   * Moves the cursor to the front of
   * this <code>ResultSet</code> object, just before the
   * first row. This method has no effect if the result set contains no rows.
   *
   * @exception SQLException if a database access error
   * occurs or the result set type is <code>TYPE_FORWARD_ONLY</code>
   */
  public void beforeFirst() throws SQLException {
    iRecordNo = FIRST_RECORD - 1;
  }

  /**
   * Moves the cursor to the end of
   * this <code>ResultSet</code> object, just after the
   * last row. This method has no effect if the result set contains no rows.
   * @exception SQLException if a database access error
   * occurs or the result set type is <code>TYPE_FORWARD_ONLY</code>
   */
  public void afterLast() throws SQLException {
    iRecordNo = alRecordNos.size();
  }

  /**
   * Moves the cursor to the first row in
   * this <code>ResultSet</code> object.
   *
   * @return <code>true</code> if the cursor is on a valid row;
   * <code>false</code> if there are no rows in the result set
   * @exception SQLException if a database access error
   * occurs or the result set type is <code>TYPE_FORWARD_ONLY</code>
   */
  public boolean first() throws SQLException {
    iRecordNo = FIRST_RECORD;

    return readData();
  }

  /**
   * Moves the cursor to the last row in
   * this <code>ResultSet</code> object.
   *
   * @return <code>true</code> if the cursor is on a valid row;
   * <code>false</code> if there are no rows in the result set
   * @exception SQLException if a database access error
   * occurs or the result set type is <code>TYPE_FORWARD_ONLY</code>
   */
  public boolean last() throws SQLException {
    iRecordNo = (alRecordNos.size() - 1);

    return readData();
  }

  /**
   * Retrieves the current row number.  The first row is number 1, the
   * second number 2, and so on.
   *
   * @return the current row number; <code>0</code> if there is no current row
   * @exception SQLException if a database access error occurs
   */
  public int getRow() throws SQLException {
    return (((getRecordNo() < FIRST_RECORD)
    || (getRecordNo() >= alRecordNos.size())) ? 0 : (getRecordNo() + 1));
  }

  /**
   * Moves the cursor to the given row number in
   * this <code>ResultSet</code> object.
   *
   * <p>If the row number is positive, the cursor moves to
   * the given row number with respect to the
   * beginning of the result set.  The first row is row 1, the second
   * is row 2, and so on.
   *
   * <p>If the given row number is negative, the cursor moves to
   * an absolute row position with respect to
   * the end of the result set.  For example, calling the method
   * <code>absolute(-1)</code> positions the
   * cursor on the last row; calling the method <code>absolute(-2)</code>
   * moves the cursor to the next-to-last row, and so on.
   *
   * <p>An attempt to position the cursor beyond the first/last row in
   * the result set leaves the cursor before the first row or after
   * the last row.
   *
   * <p><B>Note:</B> Calling <code>absolute(1)</code> is the same
   * as calling <code>first()</code>. Calling <code>absolute(-1)</code>
   * is the same as calling <code>last()</code>.
   *
   * @param row the number of the row to which the cursor should move.
   *        A positive number indicates the row number counting from the
   *        beginning of the result set; a negative number indicates the
   *        row number counting from the end of the result set
   * @return <code>true</code> if the cursor is on the result set;
   * <code>false</code> otherwise
   * @exception SQLException if a database access error
   * occurs, or the result set type is <code>TYPE_FORWARD_ONLY</code>
   */
  public boolean absolute(int row) throws SQLException {
    if (row >= 0) {
      iRecordNo = row - 1;
    } else {
      iRecordNo = alRecordNos.size() + (row); //Note row is negative here so it will be subtracted
    }

    return readData();
  }

  /**
   * Moves the cursor a relative number of rows, either positive or negative.
   * Attempting to move beyond the first/last row in the
   * result set positions the cursor before/after the
   * the first/last row. Calling <code>relative(0)</code> is valid, but does
   * not change the cursor position.
   *
   * <p>Note: Calling the method <code>relative(1)</code>
   * is identical to calling the method <code>next()</code> and
   * calling the method <code>relative(-1)</code> is identical
   * to calling the method <code>previous()</code>.
   *
   * @param rows an <code>int</code> specifying the number of rows to
   *        move from the current row; a positive number moves the cursor
   *        forward; a negative number moves the cursor backward
   * @return <code>true</code> if the cursor is on a row;
   *         <code>false</code> otherwise
   * @exception SQLException if a database access error occurs,
   *            there is no current row, or the result set type is
   *            <code>TYPE_FORWARD_ONLY</code>
   */
  public boolean relative(int rows) throws SQLException {
    iRecordNo = getRecordNo() + rows;

    return readData();
  }

  /*
   * private method to reset the data
   */
  private void emptyData() {
    columns = new String[columnNames.length];
  }

  /*
   * Utility Method to return and update the record No and takes into account AFTER LAST and BEFORE FIRST
   */
  private int getRecordNo() {
    if (iRecordNo < FIRST_RECORD) {
      iRecordNo = FIRST_RECORD - 1;
    } else if (iRecordNo >= alRecordNos.size()) {
      iRecordNo = alRecordNos.size();
    }

    return iRecordNo;
  }

  private boolean readData() throws SQLException {
    columns = new String[columnNames.length];

    String dataLine = null;

    if (
      (getRecordNo() < FIRST_RECORD) || (getRecordNo() >= alRecordNos.size())) {
      return false;
    }

    // read new line of data from input.
    iRecordArrayNo = ((Integer) alRecordNos.get(iRecordNo)).intValue();
    dataLine = (String) alRecordsArray.get(iRecordArrayNo);
    columns = parseCsvLine(dataLine);

    return true;
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -