* and equal to or less than the number of columns in the rowset * @param cal the <code>java.util.Calendar</code> object to use in * constructing the date * @return the column value; if the value is SQL <code>NULL</code>, * the result is <code>null</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>DATE</code> or * <code>TIMESTAMP</code> value */ public java.sql.Date getDate(int columnIndex, Calendar cal) throws SQLException { Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return null; } value = convertTemporal(value, RowSetMD.getColumnType(columnIndex), java.sql.Types.DATE); // create a default calendar Calendar defaultCal = Calendar.getInstance(); // set this Calendar to the time we have defaultCal.setTime((java.util.Date)value); /* * Now we can pull the pieces of the date out * of the default calendar and put them into * the user provided calendar */ cal.set(Calendar.YEAR, defaultCal.get(Calendar.YEAR)); cal.set(Calendar.MONTH, defaultCal.get(Calendar.MONTH)); cal.set(Calendar.DAY_OF_MONTH, defaultCal.get(Calendar.DAY_OF_MONTH)); /* * This looks a little odd but it is correct - * Calendar.getTime() returns a Date... */ return new java.sql.Date(cal.getTime().getTime()); } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a <code>java.sql.Date</code> * object, using the given <code>Calendar</code> object to construct an * appropriate millisecond value for the date. * * @param columnName a <code>String</code> object that must match the * SQL name of a column in this rowset, ignoring case * @param cal the <code>java.util.Calendar</code> object to use in * constructing the date * @return the column value; if the value is SQL <code>NULL</code>, * the result is <code>null</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>DATE</code> or * <code>TIMESTAMP</code> value */ public java.sql.Date getDate(String columnName, Calendar cal) throws SQLException { return getDate(getColIdxByName(columnName), cal); } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a <code>java.sql.Time</code> * object, using the given <code>Calendar</code> object to construct an * appropriate millisecond value for the date. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @param cal the <code>java.util.Calendar</code> object to use in * constructing the date * @return the column value; if the value is SQL <code>NULL</code>, * the result is <code>null</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>TIME</code> or * <code>TIMESTAMP</code> value */ public java.sql.Time getTime(int columnIndex, Calendar cal) throws SQLException { Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return null; } value = convertTemporal(value, RowSetMD.getColumnType(columnIndex), java.sql.Types.TIME); // create a default calendar Calendar defaultCal = Calendar.getInstance(); // set the time in the default calendar defaultCal.setTime((java.util.Date)value); /* * Now we can pull the pieces of the date out * of the default calendar and put them into * the user provided calendar */ cal.set(Calendar.HOUR_OF_DAY, defaultCal.get(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, defaultCal.get(Calendar.MINUTE)); cal.set(Calendar.SECOND, defaultCal.get(Calendar.SECOND)); return new java.sql.Time(cal.getTime().getTime()); } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a <code>java.sql.Time</code> * object, using the given <code>Calendar</code> object to construct an * appropriate millisecond value for the date. * * @param columnName a <code>String</code> object that must match the * SQL name of a column in this rowset, ignoring case * @param cal the <code>java.util.Calendar</code> object to use in * constructing the date * @return the column value; if the value is SQL <code>NULL</code>, * the result is <code>null</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>TIME</code> or * <code>TIMESTAMP</code> value */ public java.sql.Time getTime(String columnName, Calendar cal) throws SQLException { return getTime(getColIdxByName(columnName), cal); } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a <code>java.sql.Timestamp</code> * object, using the given <code>Calendar</code> object to construct an * appropriate millisecond value for the date. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @param cal the <code>java.util.Calendar</code> object to use in * constructing the date * @return the column value; if the value is SQL <code>NULL</code>, * the result is <code>null</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>TIME</code> or * <code>TIMESTAMP</code> value */ public java.sql.Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return null; } value = convertTemporal(value, RowSetMD.getColumnType(columnIndex), java.sql.Types.TIMESTAMP); // create a default calendar Calendar defaultCal = Calendar.getInstance(); // set the time in the default calendar defaultCal.setTime((java.util.Date)value); /* * Now we can pull the pieces of the date out * of the default calendar and put them into * the user provided calendar */ cal.set(Calendar.YEAR, defaultCal.get(Calendar.YEAR)); cal.set(Calendar.MONTH, defaultCal.get(Calendar.MONTH)); cal.set(Calendar.DAY_OF_MONTH, defaultCal.get(Calendar.DAY_OF_MONTH)); cal.set(Calendar.HOUR_OF_DAY, defaultCal.get(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, defaultCal.get(Calendar.MINUTE)); cal.set(Calendar.SECOND, defaultCal.get(Calendar.SECOND)); return new java.sql.Timestamp(cal.getTime().getTime()); } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a * <code>java.sql.Timestamp</code> object, using the given * <code>Calendar</code> object to construct an appropriate * millisecond value for the date. * * @param columnName a <code>String</code> object that must match the * SQL name of a column in this rowset, ignoring case * @param cal the <code>java.util.Calendar</code> object to use in * constructing the date * @return the column value; if the value is SQL <code>NULL</code>, * the result is <code>null</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>DATE</code>, * <code>TIME</code>, or <code>TIMESTAMP</code> value */ public java.sql.Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException { return getTimestamp(getColIdxByName(columnName), cal); } /* * RowSetInternal Interface */ /** * Retrieves the <code>Connection</code> object passed to this * <code>CachedRowSetImpl</code> object. This connection may be * used to populate this rowset with data or to write data back * to its underlying data source. * * @return the <code>Connection</code> object passed to this rowset; * may be <code>null</code> if there is no connection * @throws SQLException if an error occurs */ public Connection getConnection() throws SQLException{ return conn; } /** * Sets the metadata for this <code>CachedRowSetImpl</code> object * with the given <code>RowSetMetaData</code> object. * * @param md a <code>RowSetMetaData</code> object instance containing * metadata about the columsn in the rowset * @throws SQLException if invalid meta data is supplied to the * rowset */ public void setMetaData(RowSetMetaData md) throws SQLException { RowSetMD =(RowSetMetaDataImpl) md; } /** * Returns a result set containing the original value of the rowset. The * original value is the state of the <code>CachedRowSetImpl</code> after the * last population or synchronization (whichever occured most recently) with * the data source. * <p> * The cursor is positioned before the first row in the result set. * Only rows contained in the result set returned by <code>getOriginal()</code> * are said to have an original value. * * @return the original result set of the rowset * @throws SQLException if an error occurs produce the * <code>ResultSet</code> object */ public ResultSet getOriginal() throws SQLException { CachedRowSetImpl crs = new CachedRowSetImpl(); crs.RowSetMD = RowSetMD; crs.numRows = numRows; crs.cursorPos = 0; // make sure we don't get someone playing with these // %%% is this now necessary ??? //crs.setReader(null); //crs.setWriter(null); int colCount = RowSetMD.getColumnCount(); Row orig; for (Iterator i = rvh.iterator(); i.hasNext();) { orig = new Row(colCount, ((Row)i.next()).getOrigRow()); crs.rvh.add(orig); } return (ResultSet)crs; } /** * Returns a result set containing the original value of the current * row only. * The original value is the state of the <code>CachedRowSetImpl</code> after * the last population or synchronization (whichever occured most recently) * with the data source. * * @return the original result set of the row * @throws SQLException if there is no current row * @see #setOriginalRow */ public ResultSet getOriginalRow() throws SQLException { CachedRowSetImpl crs = new CachedRowSetImpl(); crs.RowSetMD = RowSetMD; crs.numRows = 1; crs.cursorPos = 0; crs.setTypeMap(this.getTypeMap()); // make sure we don't get someone playing with these // %%% is this now necessary ??? //crs.setReader(null); //crs.setWriter(null); Row orig = new Row(RowSetMD.getColumnCount(), getCurrentRow().getOrigRow()); crs.rvh.add(orig); return (ResultSet)crs; } /** * Marks the current row in this rowset as being an original row. * * @throws SQLException if there is no current row * @see #getOriginalRow */ public void setOriginalRow() throws SQLException { if (onInsertRow == true) { throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.invalidop").toString()); } Row row = (Row)getCurrentRow(); makeRowOriginal(row); // this can happen if deleted rows are being shown if (row.getDeleted() == true) { removeCurrentRow(); } } /** * Makes the given row of this rowset the original row by clearing any * settings that mark the row as having been inserted, deleted, or updated. * This method is called internally by the methods * <code>setOriginalRow</code> * and <code>setOriginal</code>. * * @param row the row to be made the original row */ private void makeRowOriginal(Row row) { if (row.getInserted() == true) { row.clearInserted(); } if (row.getUpdated() == true) { row.moveCurrentToOrig(); } } /** * Marks all rows in this rowset as being original rows. Any updates * made to the rows become the original values for the rowset. * Calls to the method <code>setOriginal</code> connot be reversed. * * @throws SQLException if an error occurs */ public void setOriginal() throws SQLException { for (Iterator i = rvh.iterator(); i.hasNext();) { Row row = (Row)i.next(); makeRowOriginal(row); // remove deleted rows from the collection. if (row.getDeleted() == true) { i.remove(); --numRows; } } numDeleted = 0; // notify any listeners that the rowset has changed notifyRowSetChanged(); } /** * Returns an identifier for the object (table) that was used to create this * rowset. * * @return a <code>String</code> object that identifies the table from * which this <code>CachedRowSetImpl</code> object was derived * @throws SQLException if an error occurs */ public String getTableName() throws SQLException { return tableName; } /** * Sets the identifier for the table from which this rowset was derived * to the given table name. * * @param tabName a <code>String</code> object that identifies the * table from which this <code>CachedRowSetImpl</code> object * was derived * @throws SQLException if an error occurs */ public void setTableName(String tabName) throws SQLException { if (tabName == null) throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.tablename").toString()); else tableName = tabName; } /** * Returns the columns that make a key to uniquely identify a * row in this <code>CachedRowSetImpl</code> object. * * @return an array of column numbers that constitutes a primary * key for this rowset. This array should be empty * if no column is representitive of a primary key * @throws SQLException if the rowset is empty or no columns * are designated as primary keys * @see #setKeyColumns */ public int[] getKeyColumns() throws SQLException { return keyCols; } /** * Sets this <code>CachedRowSetImpl</code> object's * <code>keyCols</code> field with the given array of column * numbers, which forms a key for uniquely identifying a row * in this rowset. * * @param keys an array of <code>int</code> indicating the * columns that form a primary key for this * <code>CachedRowSetImpl</code> object; every * element in the array must be greater than * <code>0</code> and less than or equal to the number * of columns in this rowset * @throws SQLException if any of the numbers in the * given array is not valid for this rowset * @see #getKeyColumns */ public void setKeyColumns(int [] keys) throws SQLException { int numCols = 0; if (RowSetMD != null) { numCols = RowSetMD.getColumnCount(); if (keys.length > numCols) throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.keycols").toString()); } keyCols = new int[keys.length]; for (int i = 0; i < keys.length; i++) { if (RowSetMD != null && (keys[i] <= 0 || keys[i] > numCols)) { throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.invalidcol").toString() + keys[i]); } keyCols[i] = keys[i]; } } /** * Sets the designated column in either the current row or the insert * row of this <code>CachedRowSetImpl</code> object with the given * <code>Ref</code> value. * * This method updates a column value in either the current row or * the insert row of this rowset, but it does not update the * database. If the cursor is on a row in the rowset, the * method {@link #updateRow} must be called to update the database. * If the cursor is on the insert row, the method {@link #insertRow} * must be called, which will insert the new row into both this rowset * and the database. Both of these methods must be called before the * cursor moves to another row. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in this rowset * @param ref the new column <code>java.sql.Ref</code> value * @throws SQLException if (1) the given column index is out of bounds, * (2) the cursor is not on one of this rowset's rows or its * insert row, or (3) this rowset is * <code>ResultSet.CONCUR_READ_ONLY</code> */ public void updateRef(int columnIndex, java.sql.Ref ref) throws SQLException { // sanity check. checkIndex(columnIndex);Lines 6001–6500 of 10133. Previous lines Load more
* and equal to or less than the number of columns in the rowset * @param cal the <code>java.util.Calendar</code> object to use in * constructing the date * @return the column value; if the value is SQL <code>NULL</code>, * the result is <code>null</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>DATE</code> or * <code>TIMESTAMP</code> value */ public java.sql.Date getDate(int columnIndex, Calendar cal) throws SQLException { Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return null; } value = convertTemporal(value, RowSetMD.getColumnType(columnIndex), java.sql.Types.DATE); // create a default calendar Calendar defaultCal = Calendar.getInstance(); // set this Calendar to the time we have defaultCal.setTime((java.util.Date)value); /* * Now we can pull the pieces of the date out * of the default calendar and put them into * the user provided calendar */ cal.set(Calendar.YEAR, defaultCal.get(Calendar.YEAR)); cal.set(Calendar.MONTH, defaultCal.get(Calendar.MONTH)); cal.set(Calendar.DAY_OF_MONTH, defaultCal.get(Calendar.DAY_OF_MONTH)); /* * This looks a little odd but it is correct - * Calendar.getTime() returns a Date... */ return new java.sql.Date(cal.getTime().getTime()); } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a <code>java.sql.Date</code> * object, using the given <code>Calendar</code> object to construct an * appropriate millisecond value for the date. * * @param columnName a <code>String</code> object that must match the * SQL name of a column in this rowset, ignoring case * @param cal the <code>java.util.Calendar</code> object to use in * constructing the date * @return the column value; if the value is SQL <code>NULL</code>, * the result is <code>null</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>DATE</code> or * <code>TIMESTAMP</code> value */ public java.sql.Date getDate(String columnName, Calendar cal) throws SQLException { return getDate(getColIdxByName(columnName), cal); } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a <code>java.sql.Time</code> * object, using the given <code>Calendar</code> object to construct an * appropriate millisecond value for the date. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @param cal the <code>java.util.Calendar</code> object to use in * constructing the date * @return the column value; if the value is SQL <code>NULL</code>, * the result is <code>null</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>TIME</code> or * <code>TIMESTAMP</code> value */ public java.sql.Time getTime(int columnIndex, Calendar cal) throws SQLException { Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return null; } value = convertTemporal(value, RowSetMD.getColumnType(columnIndex), java.sql.Types.TIME); // create a default calendar Calendar defaultCal = Calendar.getInstance(); // set the time in the default calendar defaultCal.setTime((java.util.Date)value); /* * Now we can pull the pieces of the date out * of the default calendar and put them into * the user provided calendar */ cal.set(Calendar.HOUR_OF_DAY, defaultCal.get(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, defaultCal.get(Calendar.MINUTE)); cal.set(Calendar.SECOND, defaultCal.get(Calendar.SECOND)); return new java.sql.Time(cal.getTime().getTime()); } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a <code>java.sql.Time</code> * object, using the given <code>Calendar</code> object to construct an * appropriate millisecond value for the date. * * @param columnName a <code>String</code> object that must match the * SQL name of a column in this rowset, ignoring case * @param cal the <code>java.util.Calendar</code> object to use in * constructing the date * @return the column value; if the value is SQL <code>NULL</code>, * the result is <code>null</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>TIME</code> or * <code>TIMESTAMP</code> value */ public java.sql.Time getTime(String columnName, Calendar cal) throws SQLException { return getTime(getColIdxByName(columnName), cal); } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a <code>java.sql.Timestamp</code> * object, using the given <code>Calendar</code> object to construct an * appropriate millisecond value for the date. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @param cal the <code>java.util.Calendar</code> object to use in * constructing the date * @return the column value; if the value is SQL <code>NULL</code>, * the result is <code>null</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>TIME</code> or * <code>TIMESTAMP</code> value */ public java.sql.Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return null; } value = convertTemporal(value, RowSetMD.getColumnType(columnIndex), java.sql.Types.TIMESTAMP); // create a default calendar Calendar defaultCal = Calendar.getInstance(); // set the time in the default calendar defaultCal.setTime((java.util.Date)value); /* * Now we can pull the pieces of the date out * of the default calendar and put them into * the user provided calendar */ cal.set(Calendar.YEAR, defaultCal.get(Calendar.YEAR)); cal.set(Calendar.MONTH, defaultCal.get(Calendar.MONTH)); cal.set(Calendar.DAY_OF_MONTH, defaultCal.get(Calendar.DAY_OF_MONTH)); cal.set(Calendar.HOUR_OF_DAY, defaultCal.get(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, defaultCal.get(Calendar.MINUTE)); cal.set(Calendar.SECOND, defaultCal.get(Calendar.SECOND)); return new java.sql.Timestamp(cal.getTime().getTime()); } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a * <code>java.sql.Timestamp</code> object, using the given * <code>Calendar</code> object to construct an appropriate * millisecond value for the date. * * @param columnName a <code>String</code> object that must match the * SQL name of a column in this rowset, ignoring case * @param cal the <code>java.util.Calendar</code> object to use in * constructing the date * @return the column value; if the value is SQL <code>NULL</code>, * the result is <code>null</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>DATE</code>, * <code>TIME</code>, or <code>TIMESTAMP</code> value */ public java.sql.Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException { return getTimestamp(getColIdxByName(columnName), cal); } /* * RowSetInternal Interface */ /** * Retrieves the <code>Connection</code> object passed to this * <code>CachedRowSetImpl</code> object. This connection may be * used to populate this rowset with data or to write data back * to its underlying data source. * * @return the <code>Connection</code> object passed to this rowset; * may be <code>null</code> if there is no connection * @throws SQLException if an error occurs */ public Connection getConnection() throws SQLException{ return conn; } /** * Sets the metadata for this <code>CachedRowSetImpl</code> object * with the given <code>RowSetMetaData</code> object. * * @param md a <code>RowSetMetaData</code> object instance containing * metadata about the columsn in the rowset * @throws SQLException if invalid meta data is supplied to the * rowset */ public void setMetaData(RowSetMetaData md) throws SQLException { RowSetMD =(RowSetMetaDataImpl) md; } /** * Returns a result set containing the original value of the rowset. The * original value is the state of the <code>CachedRowSetImpl</code> after the * last population or synchronization (whichever occured most recently) with * the data source. * <p> * The cursor is positioned before the first row in the result set. * Only rows contained in the result set returned by <code>getOriginal()</code> * are said to have an original value. * * @return the original result set of the rowset * @throws SQLException if an error occurs produce the * <code>ResultSet</code> object */ public ResultSet getOriginal() throws SQLException { CachedRowSetImpl crs = new CachedRowSetImpl(); crs.RowSetMD = RowSetMD; crs.numRows = numRows; crs.cursorPos = 0; // make sure we don't get someone playing with these // %%% is this now necessary ??? //crs.setReader(null); //crs.setWriter(null); int colCount = RowSetMD.getColumnCount(); Row orig; for (Iterator i = rvh.iterator(); i.hasNext();) { orig = new Row(colCount, ((Row)i.next()).getOrigRow()); crs.rvh.add(orig); } return (ResultSet)crs; } /** * Returns a result set containing the original value of the current * row only. * The original value is the state of the <code>CachedRowSetImpl</code> after * the last population or synchronization (whichever occured most recently) * with the data source. * * @return the original result set of the row * @throws SQLException if there is no current row * @see #setOriginalRow */ public ResultSet getOriginalRow() throws SQLException { CachedRowSetImpl crs = new CachedRowSetImpl(); crs.RowSetMD = RowSetMD; crs.numRows = 1; crs.cursorPos = 0; crs.setTypeMap(this.getTypeMap()); // make sure we don't get someone playing with these // %%% is this now necessary ??? //crs.setReader(null); //crs.setWriter(null); Row orig = new Row(RowSetMD.getColumnCount(), getCurrentRow().getOrigRow()); crs.rvh.add(orig); return (ResultSet)crs; } /** * Marks the current row in this rowset as being an original row. * * @throws SQLException if there is no current row * @see #getOriginalRow */ public void setOriginalRow() throws SQLException { if (onInsertRow == true) { throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.invalidop").toString()); } Row row = (Row)getCurrentRow(); makeRowOriginal(row); // this can happen if deleted rows are being shown if (row.getDeleted() == true) { removeCurrentRow(); } } /** * Makes the given row of this rowset the original row by clearing any * settings that mark the row as having been inserted, deleted, or updated. * This method is called internally by the methods * <code>setOriginalRow</code> * and <code>setOriginal</code>. * * @param row the row to be made the original row */ private void makeRowOriginal(Row row) { if (row.getInserted() == true) { row.clearInserted(); } if (row.getUpdated() == true) { row.moveCurrentToOrig(); } } /** * Marks all rows in this rowset as being original rows. Any updates * made to the rows become the original values for the rowset. * Calls to the method <code>setOriginal</code> connot be reversed. * * @throws SQLException if an error occurs */ public void setOriginal() throws SQLException { for (Iterator i = rvh.iterator(); i.hasNext();) { Row row = (Row)i.next(); makeRowOriginal(row); // remove deleted rows from the collection. if (row.getDeleted() == true) { i.remove(); --numRows; } } numDeleted = 0; // notify any listeners that the rowset has changed notifyRowSetChanged(); } /** * Returns an identifier for the object (table) that was used to create this * rowset. * * @return a <code>String</code> object that identifies the table from * which this <code>CachedRowSetImpl</code> object was derived * @throws SQLException if an error occurs */ public String getTableName() throws SQLException { return tableName; } /** * Sets the identifier for the table from which this rowset was derived * to the given table name. * * @param tabName a <code>String</code> object that identifies the * table from which this <code>CachedRowSetImpl</code> object * was derived * @throws SQLException if an error occurs */ public void setTableName(String tabName) throws SQLException { if (tabName == null) throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.tablename").toString()); else tableName = tabName; } /** * Returns the columns that make a key to uniquely identify a * row in this <code>CachedRowSetImpl</code> object. * * @return an array of column numbers that constitutes a primary * key for this rowset. This array should be empty * if no column is representitive of a primary key * @throws SQLException if the rowset is empty or no columns * are designated as primary keys * @see #setKeyColumns */ public int[] getKeyColumns() throws SQLException { return keyCols; } /** * Sets this <code>CachedRowSetImpl</code> object's * <code>keyCols</code> field with the given array of column * numbers, which forms a key for uniquely identifying a row * in this rowset. * * @param keys an array of <code>int</code> indicating the * columns that form a primary key for this * <code>CachedRowSetImpl</code> object; every * element in the array must be greater than * <code>0</code> and less than or equal to the number * of columns in this rowset * @throws SQLException if any of the numbers in the * given array is not valid for this rowset * @see #getKeyColumns */ public void setKeyColumns(int [] keys) throws SQLException { int numCols = 0; if (RowSetMD != null) { numCols = RowSetMD.getColumnCount(); if (keys.length > numCols) throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.keycols").toString()); } keyCols = new int[keys.length]; for (int i = 0; i < keys.length; i++) { if (RowSetMD != null && (keys[i] <= 0 || keys[i] > numCols)) { throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.invalidcol").toString() + keys[i]); } keyCols[i] = keys[i]; } } /** * Sets the designated column in either the current row or the insert * row of this <code>CachedRowSetImpl</code> object with the given * <code>Ref</code> value. * * This method updates a column value in either the current row or * the insert row of this rowset, but it does not update the * database. If the cursor is on a row in the rowset, the * method {@link #updateRow} must be called to update the database. * If the cursor is on the insert row, the method {@link #insertRow} * must be called, which will insert the new row into both this rowset * and the database. Both of these methods must be called before the * cursor moves to another row. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in this rowset * @param ref the new column <code>java.sql.Ref</code> value * @throws SQLException if (1) the given column index is out of bounds, * (2) the cursor is not on one of this rowset's rows or its * insert row, or (3) this rowset is * <code>ResultSet.CONCUR_READ_ONLY</code> */ public void updateRef(int columnIndex, java.sql.Ref ref) throws SQLException { // sanity check. checkIndex(columnIndex);