src/share/classes/com/sun/rowset/CachedRowSetImpl.java

Print this page




1649      */
1650     protected BaseRow getCurrentRow() {
1651         if (onInsertRow == true) {
1652             return (BaseRow)insertRow;
1653         } else {
1654             return (BaseRow)(rvh.get(cursorPos - 1));
1655         }
1656     }
1657 
1658     /**
1659      * Removes the row on which the cursor is positioned.
1660      * <p>
1661      * This is a implementation only method and is not required as a standard
1662      * implementation of the <code>CachedRowSet</code> interface.
1663      *
1664      * @throws SQLException if the cursor is positioned on the insert
1665      *            row
1666      */
1667     protected void removeCurrentRow() {
1668         ((Row)getCurrentRow()).setDeleted();
1669         rvh.remove(cursorPos);
1670         --numRows;
1671     }
1672 
1673 
1674     /**
1675      * Retrieves the value of the designated column in the current row
1676      * of this <code>CachedRowSetImpl</code> object as a
1677      * <code>String</code> object.
1678      *
1679      * @param columnIndex the first column is <code>1</code>, the second
1680      *        is <code>2</code>, and so on; must be <code>1</code> or larger
1681      *        and equal to or less than the number of columns in the rowset
1682      * @return the column value; if the value is SQL <code>NULL</code>, the
1683      *         result is <code>null</code>
1684      * @throws SQLException if (1) the given column index is out of bounds,
1685      * (2) the cursor is not on one of this rowset's rows or its
1686      * insert row, or (3) the designated column does not store an
1687      * SQL <code>TINYINT, SMALLINT, INTEGER, BIGINT, REAL,
1688      * FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, <b>CHAR</b>, <b>VARCHAR</b></code>
1689      * or <code>LONGVARCHAR</code> value. The bold SQL type designates the


6332 
6333     }
6334 
6335     /**
6336      * Marks the current row in this rowset as being an original row.
6337      *
6338      * @throws SQLException if there is no current row
6339      * @see #getOriginalRow
6340      */
6341     public void setOriginalRow() throws SQLException {
6342         if (onInsertRow == true) {
6343             throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.invalidop").toString());
6344         }
6345 
6346         Row row = (Row)getCurrentRow();
6347         makeRowOriginal(row);
6348 
6349         // this can happen if deleted rows are being shown
6350         if (row.getDeleted() == true) {
6351             removeCurrentRow();
6352             --numRows;
6353         }
6354     }
6355 
6356     /**
6357      * Makes the given row of this rowset the original row by clearing any
6358      * settings that mark the row as having been inserted, deleted, or updated.
6359      * This method is called internally by the methods
6360      * <code>setOriginalRow</code>
6361      * and <code>setOriginal</code>.
6362      *
6363      * @param row the row to be made the original row
6364      */
6365     private void makeRowOriginal(Row row) {
6366         if (row.getInserted() == true) {
6367             row.clearInserted();
6368         }
6369 
6370         if (row.getUpdated() == true) {
6371             row.moveCurrentToOrig();
6372         }




1649      */
1650     protected BaseRow getCurrentRow() {
1651         if (onInsertRow == true) {
1652             return (BaseRow)insertRow;
1653         } else {
1654             return (BaseRow)(rvh.get(cursorPos - 1));
1655         }
1656     }
1657 
1658     /**
1659      * Removes the row on which the cursor is positioned.
1660      * <p>
1661      * This is a implementation only method and is not required as a standard
1662      * implementation of the <code>CachedRowSet</code> interface.
1663      *
1664      * @throws SQLException if the cursor is positioned on the insert
1665      *            row
1666      */
1667     protected void removeCurrentRow() {
1668         ((Row)getCurrentRow()).setDeleted();
1669         rvh.remove(cursorPos - 1);
1670         --numRows;
1671     }
1672 
1673 
1674     /**
1675      * Retrieves the value of the designated column in the current row
1676      * of this <code>CachedRowSetImpl</code> object as a
1677      * <code>String</code> object.
1678      *
1679      * @param columnIndex the first column is <code>1</code>, the second
1680      *        is <code>2</code>, and so on; must be <code>1</code> or larger
1681      *        and equal to or less than the number of columns in the rowset
1682      * @return the column value; if the value is SQL <code>NULL</code>, the
1683      *         result is <code>null</code>
1684      * @throws SQLException if (1) the given column index is out of bounds,
1685      * (2) the cursor is not on one of this rowset's rows or its
1686      * insert row, or (3) the designated column does not store an
1687      * SQL <code>TINYINT, SMALLINT, INTEGER, BIGINT, REAL,
1688      * FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, <b>CHAR</b>, <b>VARCHAR</b></code>
1689      * or <code>LONGVARCHAR</code> value. The bold SQL type designates the


6332 
6333     }
6334 
6335     /**
6336      * Marks the current row in this rowset as being an original row.
6337      *
6338      * @throws SQLException if there is no current row
6339      * @see #getOriginalRow
6340      */
6341     public void setOriginalRow() throws SQLException {
6342         if (onInsertRow == true) {
6343             throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.invalidop").toString());
6344         }
6345 
6346         Row row = (Row)getCurrentRow();
6347         makeRowOriginal(row);
6348 
6349         // this can happen if deleted rows are being shown
6350         if (row.getDeleted() == true) {
6351             removeCurrentRow();

6352         }
6353     }
6354 
6355     /**
6356      * Makes the given row of this rowset the original row by clearing any
6357      * settings that mark the row as having been inserted, deleted, or updated.
6358      * This method is called internally by the methods
6359      * <code>setOriginalRow</code>
6360      * and <code>setOriginal</code>.
6361      *
6362      * @param row the row to be made the original row
6363      */
6364     private void makeRowOriginal(Row row) {
6365         if (row.getInserted() == true) {
6366             row.clearInserted();
6367         }
6368 
6369         if (row.getUpdated() == true) {
6370             row.moveCurrentToOrig();
6371         }