0001: /*
0002: * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
0003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0004: *
0005: * This code is free software; you can redistribute it and/or modify it
0006: * under the terms of the GNU General Public License version 2 only, as
0007: * published by the Free Software Foundation. Sun designates this
0008: * particular file as subject to the "Classpath" exception as provided
0009: * by Sun in the LICENSE file that accompanied this code.
0010: *
0011: * This code is distributed in the hope that it will be useful, but WITHOUT
0012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0014: * version 2 for more details (a copy is included in the LICENSE file that
0015: * accompanied this code).
0016: *
0017: * You should have received a copy of the GNU General Public License version
0018: * 2 along with this work; if not, write to the Free Software Foundation,
0019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0020: *
0021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0022: * CA 95054 USA or visit www.sun.com if you need additional information or
0023: * have any questions.
0024: */
0025:
0026: package com.sun.rowset;
0027:
0028: import java.io.*;
0029: import java.util.*;
0030: import java.sql.*;
0031: import javax.sql.*;
0032: import java.math.*;
0033:
0034: import javax.sql.rowset.*;
0035: import javax.sql.rowset.spi.*;
0036: import javax.sql.rowset.serial.*;
0037: import com.sun.rowset.providers.*;
0038: import com.sun.rowset.internal.*;
0039:
0040: /**
0041: * The standard implementation of the <code>FilteredRowSet</code> interface. See the interface
0042: * defintion for full behaviour and implementation requirements.
0043: *
0044: * @see javax.sql.rowset.Predicate
0045: * @author Jonathan Bruce, Amit Handa
0046: */
0047:
0048: public class FilteredRowSetImpl extends WebRowSetImpl implements
0049: Serializable, Cloneable, FilteredRowSet {
0050:
0051: private Predicate p;
0052:
0053: private boolean onInsertRow = false;
0054:
0055: /**
0056: * Construct a <code>FilteredRowSet</code>
0057: */
0058: public FilteredRowSetImpl() throws SQLException {
0059: super ();
0060: }
0061:
0062: /**
0063: * Construct a <code>FilteredRowSet</code> with a specified synchronization
0064: * provider.
0065: *
0066: * @param env a Hashtable containing a desired synchconizatation provider
0067: * name-value pair.
0068: */
0069: public FilteredRowSetImpl(Hashtable env) throws SQLException {
0070: super (env);
0071: }
0072:
0073: /**
0074: * Apply the predicate for this filter
0075: *
0076: * @param p an implementation of the predicate interface
0077: */
0078: public void setFilter(Predicate p) throws SQLException {
0079: this .p = p;
0080: }
0081:
0082: /**
0083: * Retrieve the filter active for this <code>FilteredRowSet</code>
0084: *
0085: * @return a <code>Predicate</code> object instance
0086: */
0087: public Predicate getFilter() {
0088: return this .p;
0089: }
0090:
0091: /**
0092: * Over-riding <code>internalNext()</code> implementation. This method
0093: * applies the filter on the <code>RowSet</code> each time the cursor is advanced or
0094: * manipulated. It moves the cursor to the next row according to the set
0095: * predicate and returns <code>true</code> if the cursor is still within the rowset or
0096: * <code>false</code> if the cursor position is over the last row
0097: *
0098: * @return true if over the valid row in the rowset; false if over the last
0099: * row
0100: */
0101: protected boolean internalNext() throws SQLException {
0102: // CachedRowSetImpl.next() internally calls
0103: // this(crs).internalNext() NOTE: this holds crs object
0104: // So when frs.next() is called,
0105: // internally this(frs).internalNext() will be called
0106: // which will be nothing but this method.
0107: // because this holds frs object
0108:
0109: // keep on doing super.internalNext()
0110: // rather than doing it once.
0111:
0112: // p.evaluate will help us in changing the cursor
0113: // and checking the next value by returning true or false.
0114: // to fit the filter
0115:
0116: // So while() loop will have a "random combination" of
0117: // true and false returned depending upon the records
0118: // are in or out of filter.
0119: // We need to traverse from present cursorPos till end,
0120: // whether true or false and check each row for "filter"
0121: // "till we get a "true"
0122:
0123: boolean bool = false;
0124:
0125: for (int rows = this .getRow(); rows <= this .size(); rows++) {
0126: bool = super .internalNext();
0127:
0128: if (p == null) {
0129: return bool;
0130: }
0131: if (p.evaluate(this )) {
0132: break;
0133: }
0134:
0135: }
0136:
0137: return bool;
0138: }
0139:
0140: /**
0141: * Over-riding <code>internalPrevious()</code> implementation. This method
0142: * applies the filter on the <code>RowSet</code> each time the cursor is moved backward or
0143: * manipulated. It moves the cursor to the previous row according to the set
0144: * predicate and returns <code>true</code> if the cursor is still within the rowset or
0145: * <code>false</code> if the cursor position is over the last row
0146: *
0147: * @return true if over the valid row in the rowset; false if over the last
0148: * row
0149: */
0150: protected boolean internalPrevious() throws SQLException {
0151: boolean bool = false;
0152: // with previous move backwards,
0153: // i.e. from any record towards first record
0154:
0155: for (int rows = this .getRow(); rows > 0; rows--) {
0156:
0157: bool = super .internalPrevious();
0158:
0159: if (p == null) {
0160: return bool;
0161: }
0162:
0163: if (p.evaluate(this )) {
0164: break;
0165: }
0166:
0167: }
0168:
0169: return bool;
0170: }
0171:
0172: /**
0173: * Over-riding <code>internalFirst()</code> implementation. This method
0174: * applies the filter on the <code>RowSet</code> each time the cursor is moved to first
0175: * row. It moves the cursor to the first row according to the set
0176: * predicate and returns <code>true</code> if the cursor is still within the rowset or
0177: * <code>false</code> if the cursor position is over the last row
0178: *
0179: * @return true if over the valid row in the rowset; false if over the last
0180: * row
0181: */
0182: protected boolean internalFirst() throws SQLException {
0183:
0184: // from first till present cursor position(go forward),
0185: // find the actual first which matches the filter.
0186:
0187: boolean bool = super .internalFirst();
0188:
0189: if (p == null) {
0190: return bool;
0191: }
0192:
0193: while (bool) {
0194:
0195: if (p.evaluate(this )) {
0196: break;
0197: }
0198: bool = super .internalNext();
0199: }
0200: return bool;
0201: }
0202:
0203: /**
0204: * Over-riding <code>internalLast()</code> implementation. This method
0205: * applies the filter on the <code>RowSet</code> each time the cursor is moved to
0206: * last row. It moves the cursor to the last row according to the set
0207: * predicate and returns <code>true</code> if the cursor is still within the rowset or
0208: * <code>false</code> if the cursor position is over the last row
0209: *
0210: * @return true if over the valid row in the rowset; false if over the last
0211: * row
0212: */
0213: protected boolean internalLast() throws SQLException {
0214: // from last to the present cursor position(go backward),
0215: // find the actual last which matches the filter.
0216:
0217: boolean bool = super .internalLast();
0218:
0219: if (p == null) {
0220: return bool;
0221: }
0222:
0223: while (bool) {
0224:
0225: if (p.evaluate(this )) {
0226: break;
0227: }
0228:
0229: bool = super .internalPrevious();
0230:
0231: }
0232: return bool;
0233:
0234: } // end internalLast()
0235:
0236: /**
0237: * Moves the cursor the specified number of rows from the current
0238: * position, with a positive number moving it forward and a
0239: * negative number moving it backward.
0240: * <P>
0241: * If the number is positive, the cursor moves the specified number of
0242: * rows toward the end of the rowset, starting at the current row.
0243: * For example, the following command, in which
0244: * <code>crs</code> is a <code>CachedRowSetImpl</code> object with 100 rows,
0245: * moves the cursor forward four rows from the current row. If the
0246: * current row is 50, the cursor would move to row 54.
0247: * <PRE><code>
0248: *
0249: * crs.relative(4);
0250: *
0251: * </code> </PRE>
0252: * <P>
0253: * If the number is negative, the cursor moves back toward the beginning
0254: * the specified number of rows, starting at the current row.
0255: * For example, calling the method
0256: * <code>absolute(-1)</code> positions the cursor on the last row,
0257: * <code>absolute(-2)</code> moves it on the next-to-last row, and so on.
0258: * If the <code>CachedRowSetImpl</code> object <code>crs</code> has five rows,
0259: * the following command moves the cursor to the fourth-to-last row, which
0260: * in the case of a rowset with five rows, is also the second row
0261: * from the beginning.
0262: * <PRE><code>
0263: *
0264: * crs.absolute(-4);
0265: *
0266: * </code> </PRE>
0267: *
0268: * If the number specified is larger than the number of rows, the cursor
0269: * will move to the position after the last row. If the number specified
0270: * would move the cursor one or more rows before the first row, the cursor
0271: * moves to the position before the first row. In both cases, this method
0272: * throws an <code>SQLException</code>.
0273: * <P>
0274: * Note: Calling <code>absolute(1)</code> is the same as calling the
0275: * method <code>first()</code>. Calling <code>absolute(-1)</code> is the
0276: * same as calling <code>last()</code>. Calling <code>relative(0)</code>
0277: * is valid, but it does not change the cursor position.
0278: *
0279: * @param rows an <code>int</code> indicating the number of rows to move
0280: * the cursor, starting at the current row; a positive number
0281: * moves the cursor forward; a negative number moves the cursor
0282: * backward; must not move the cursor past the valid
0283: * rows
0284: * @return <code>true</code> if the cursor is on a row in this
0285: * <code>CachedRowSetImpl</code> object; <code>false</code>
0286: * otherwise
0287: * @throws SQLException if the rowset is type <code>ResultSet.TYPE_FORWARD_ONLY</code>
0288: */
0289: public boolean relative(int rows) throws SQLException {
0290:
0291: boolean retval;
0292: boolean bool = false;
0293: boolean boolval = false;
0294:
0295: if (getType() == ResultSet.TYPE_FORWARD_ONLY) {
0296: throw new SQLException(resBundle.handleGetObject(
0297: "filteredrowsetimpl.relative").toString());
0298: }
0299:
0300: if (rows > 0) {
0301:
0302: int i = 0;
0303: while (i < (rows)) {
0304:
0305: if (isAfterLast()) {
0306: return false;
0307: }
0308: bool = internalNext();
0309: i++;
0310: }
0311:
0312: retval = bool;
0313: } else {
0314: int j = rows;
0315: while ((j) < 0) {
0316:
0317: if (isBeforeFirst()) {
0318: return false;
0319: }
0320: boolval = internalPrevious();
0321: j++;
0322: }
0323: retval = boolval;
0324: }
0325: if (rows != 0)
0326: notifyCursorMoved();
0327: return retval;
0328: }
0329:
0330: /**
0331: * Moves this <code>CachedRowSetImpl</code> object's cursor to the row number
0332: * specified.
0333: *
0334: * <p>If the number is positive, the cursor moves to an absolute row with
0335: * respect to the beginning of the rowset. The first row is row 1, the second
0336: * is row 2, and so on. For example, the following command, in which
0337: * <code>crs</code> is a <code>CachedRowSetImpl</code> object, moves the cursor
0338: * to the fourth row, starting from the beginning of the rowset.
0339: * <PRE><code>
0340: *
0341: * crs.absolute(4);
0342: *
0343: * </code> </PRE>
0344: * <P>
0345: * If the number is negative, the cursor moves to an absolute row position
0346: * with respect to the end of the rowset. For example, calling
0347: * <code>absolute(-1)</code> positions the cursor on the last row,
0348: * <code>absolute(-2)</code> moves it on the next-to-last row, and so on.
0349: * If the <code>CachedRowSetImpl</code> object <code>crs</code> has five rows,
0350: * the following command moves the cursor to the fourth-to-last row, which
0351: * in the case of a rowset with five rows, is also the second row, counting
0352: * from the beginning.
0353: * <PRE><code>
0354: *
0355: * crs.absolute(-4);
0356: *
0357: * </code> </PRE>
0358: *
0359: * If the number specified is larger than the number of rows, the cursor
0360: * will move to the position after the last row. If the number specified
0361: * would move the cursor one or more rows before the first row, the cursor
0362: * moves to the position before the first row.
0363: * <P>
0364: * Note: Calling <code>absolute(1)</code> is the same as calling the
0365: * method <code>first()</code>. Calling <code>absolute(-1)</code> is the
0366: * same as calling <code>last()</code>.
0367: *
0368: * @param rows a positive number to indicate the row, starting row numbering from
0369: * the first row, which is <code>1</code>; a negative number to indicate
0370: * the row, starting row numbering from the last row, which is
0371: * <code>-1</code>; it must not be <code>0</code>
0372: * @return <code>true</code> if the cursor is on the rowset; <code>false</code>
0373: * otherwise
0374: * @throws SQLException if the given cursor position is <code>0</code> or the
0375: * type of this rowset is <code>ResultSet.TYPE_FORWARD_ONLY</code>
0376: */
0377: public boolean absolute(int rows) throws SQLException {
0378:
0379: boolean retval;
0380: boolean bool = false;
0381:
0382: if (rows == 0 || getType() == ResultSet.TYPE_FORWARD_ONLY) {
0383: throw new SQLException(resBundle.handleGetObject(
0384: "filteredrowsetimpl.absolute").toString());
0385: }
0386:
0387: if (rows > 0) {
0388: bool = internalFirst();
0389:
0390: int i = 0;
0391: while (i < (rows - 1)) {
0392: if (isAfterLast()) {
0393: return false;
0394: }
0395: bool = internalNext();
0396: i++;
0397: }
0398: retval = bool;
0399: } else {
0400: bool = internalLast();
0401:
0402: int j = rows;
0403: while ((j + 1) < 0) {
0404: if (isBeforeFirst()) {
0405: return false;
0406: }
0407: bool = internalPrevious();
0408: j++;
0409: }
0410: retval = bool;
0411: }
0412: notifyCursorMoved();
0413: return retval;
0414: }
0415:
0416: /**
0417: * Moves the cursor for this <code>CachedRowSetImpl</code> object
0418: * to the insert row. The current row in the rowset is remembered
0419: * while the cursor is on the insert row.
0420: * <P>
0421: * The insert row is a special row associated with an updatable
0422: * rowset. It is essentially a buffer where a new row may
0423: * be constructed by calling the appropriate <code>updateXXX</code>
0424: * methods to assign a value to each column in the row. A complete
0425: * row must be constructed; that is, every column that is not nullable
0426: * must be assigned a value. In order for the new row to become part
0427: * of this rowset, the method <code>insertRow</code> must be called
0428: * before the cursor is moved back to the rowset.
0429: * <P>
0430: * Only certain methods may be invoked while the cursor is on the insert
0431: * row; many methods throw an exception if they are called while the
0432: * cursor is there. In addition to the <code>updateXXX</code>
0433: * and <code>insertRow</code> methods, only the <code>getXXX</code> methods
0434: * may be called when the cursor is on the insert row. A <code>getXXX</code>
0435: * method should be called on a column only after an <code>updateXXX</code>
0436: * method has been called on that column; otherwise, the value returned is
0437: * undetermined.
0438: *
0439: * @throws SQLException if this <code>CachedRowSetImpl</code> object is
0440: * <code>ResultSet.CONCUR_READ_ONLY</code>
0441: */
0442: public void moveToInsertRow() throws SQLException {
0443:
0444: onInsertRow = true;
0445: super .moveToInsertRow();
0446: }
0447:
0448: /**
0449: * This is explanation for the overriding of the updateXXX functions.
0450: * These functions have been overriden to ensure that only correct
0451: * values that pass the criteria for the filter are actaully inserted.
0452: * The evaluation of whether a particular value passes the criteria
0453: * of the filter is done using the evaluate function in the Predicate
0454: * interface.
0455: *
0456: * The checking can will done in the evaluate function which is implemented
0457: * in the class that implements the Predicate interface. So the checking
0458: * can vary from one implementation to another.
0459: *
0460: * Some additional points here on the following:
0461: * 1. updateBytes() - since the evaluate function takes Object as parameter
0462: * a String is constructed from the byte array and would
0463: * passed to the evaluate function.
0464: * 2. updateXXXstream() - here it would suffice to pass the stream handle
0465: * to the evaluate function and the implementation
0466: * of the evaluate function can do the comparision
0467: * based on the stream and also type of data.
0468: */
0469:
0470: /**
0471: * Sets the designated column in either the current row or the insert
0472: * row of this <code>CachedRowSetImpl</code> object with the given
0473: * <code>int</code> value.
0474: * <P>
0475: * This method updates a column value in the current row or the insert
0476: * row of this rowset, but it does not update the database.
0477: * If the cursor is on a row in the rowset, the
0478: * method {@link #updateRow} must be called to update the database.
0479: * If the cursor is on the insert row, the method {@link #insertRow}
0480: * must be called, which will insert the new row into both this rowset
0481: * and the database. Both of these methods must be called before the
0482: * cursor moves to another row.
0483: *
0484: * @param columnIndex the first column is <code>1</code>, the second
0485: * is <code>2</code>, and so on; must be <code>1</code> or larger
0486: * and equal to or less than the number of columns in this rowset
0487: * @param x the new column value
0488: * @throws SQLException if (1) the given column index is out of bounds,
0489: * (2) the cursor is not on one of this rowset's rows or its
0490: * insert row, or (3) this rowset is
0491: * <code>ResultSet.CONCUR_READ_ONLY</code>
0492: */
0493: public void updateInt(int columnIndex, int x) throws SQLException {
0494:
0495: boolean bool;
0496:
0497: if (onInsertRow) {
0498: if (p != null) {
0499: bool = p.evaluate(new Integer(x), columnIndex);
0500:
0501: if (!bool) {
0502: throw new SQLException(resBundle.handleGetObject(
0503: "filteredrowsetimpl.notallowed").toString());
0504: }
0505: }
0506: }
0507:
0508: super .updateInt(columnIndex, x);
0509: }
0510:
0511: /**
0512: * Sets the designated column in either the current row or the insert
0513: * row of this <code>CachedRowSetImpl</code> object with the given
0514: * <code>int</code> value.
0515: * <P>
0516: * This method updates a column value in the current row or the insert
0517: * row of this rowset, but it does not update the database.
0518: * If the cursor is on a row in the rowset, the
0519: * method {@link #updateRow} must be called to update the database.
0520: * If the cursor is on the insert row, the method {@link #insertRow}
0521: * must be called, which will insert the new row into both this rowset
0522: * and the database. Both of these methods must be called before the
0523: * cursor moves to another row.
0524: *
0525: * @param columnName a <code>String</code> object that must match the
0526: * SQL name of a column in this rowset, ignoring case
0527: * @param x the new column value
0528: * @throws SQLException if (1) the given column name does not match the
0529: * name of a column in this rowset, (2) the cursor is not on
0530: * one of this rowset's rows or its insert row, or (3) this
0531: * rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
0532: */
0533: public void updateInt(String columnName, int x) throws SQLException {
0534:
0535: this .updateInt(findColumn(columnName), x);
0536: }
0537:
0538: /**
0539: * Sets the designated column in either the current row or the insert
0540: * row of this <code>CachedRowSetImpl</code> object with the given
0541: * <code>boolean</code> value.
0542: * <P>
0543: * This method updates a column value in the current row or the insert
0544: * row of this rowset, but it does not update the database.
0545: * If the cursor is on a row in the rowset, the
0546: * method {@link #updateRow} must be called to update the database.
0547: * If the cursor is on the insert row, the method {@link #insertRow}
0548: * must be called, which will insert the new row into both this rowset
0549: * and the database. Both of these methods must be called before the
0550: * cursor moves to another row.
0551: *
0552: * @param columnIndex the first column is <code>1</code>, the second
0553: * is <code>2</code>, and so on; must be <code>1</code> or larger
0554: * and equal to or less than the number of columns in this rowset
0555: * @param x the new column value
0556: * @throws SQLException if (1) the given column index is out of bounds,
0557: * (2) the cursor is not on one of this rowset's rows or its
0558: * insert row, or (3) this rowset is
0559: * <code>ResultSet.CONCUR_READ_ONLY</code>
0560: */
0561: public void updateBoolean(int columnIndex, boolean x)
0562: throws SQLException {
0563:
0564: boolean bool;
0565:
0566: if (onInsertRow) {
0567: if (p != null) {
0568: bool = p.evaluate(new Boolean(x), columnIndex);
0569:
0570: if (!bool) {
0571: throw new SQLException(resBundle.handleGetObject(
0572: "filteredrowsetimpl.notallowed").toString());
0573: }
0574: }
0575: }
0576:
0577: super .updateBoolean(columnIndex, x);
0578: }
0579:
0580: /**
0581: * Sets the designated column in either the current row or the insert
0582: * row of this <code>CachedRowSetImpl</code> object with the given
0583: * <code>boolean</code> value.
0584: * <P>
0585: * This method updates a column value in the current row or the insert
0586: * row of this rowset, but it does not update the database.
0587: * If the cursor is on a row in the rowset, the
0588: * method {@link #updateRow} must be called to update the database.
0589: * If the cursor is on the insert row, the method {@link #insertRow}
0590: * must be called, which will insert the new row into both this rowset
0591: * and the database. Both of these methods must be called before the
0592: * cursor moves to another row.
0593: *
0594: * @param columnName a <code>String</code> object that must match the
0595: * SQL name of a column in this rowset, ignoring case
0596: * @param x the new column value
0597: * @throws SQLException if (1) the given column name does not match the
0598: * name of a column in this rowset, (2) the cursor is not on
0599: * one of this rowset's rows or its insert row, or (3) this
0600: * rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
0601: */
0602: public void updateBoolean(String columnName, boolean x)
0603: throws SQLException {
0604:
0605: this .updateBoolean(findColumn(columnName), x);
0606: }
0607:
0608: /**
0609: * Sets the designated column in either the current row or the insert
0610: * row of this <code>CachedRowSetImpl</code> object with the given
0611: * <code>byte</code> value.
0612: * <P>
0613: * This method updates a column value in the current row or the insert
0614: * row of this rowset, but it does not update the database.
0615: * If the cursor is on a row in the rowset, the
0616: * method {@link #updateRow} must be called to update the database.
0617: * If the cursor is on the insert row, the method {@link #insertRow}
0618: * must be called, which will insert the new row into both this rowset
0619: * and the database. Both of these methods must be called before the
0620: * cursor moves to another row.
0621: *
0622: * @param columnIndex the first column is <code>1</code>, the second
0623: * is <code>2</code>, and so on; must be <code>1</code> or larger
0624: * and equal to or less than the number of columns in this rowset
0625: * @param x the new column value
0626: * @throws SQLException if (1) the given column index is out of bounds,
0627: * (2) the cursor is not on one of this rowset's rows or its
0628: * insert row, or (3) this rowset is
0629: * <code>ResultSet.CONCUR_READ_ONLY</code>
0630: */
0631: public void updateByte(int columnIndex, byte x) throws SQLException {
0632: boolean bool;
0633:
0634: if (onInsertRow) {
0635: if (p != null) {
0636: bool = p.evaluate(new Byte(x), columnIndex);
0637:
0638: if (!bool) {
0639: throw new SQLException(resBundle.handleGetObject(
0640: "filteredrowsetimpl.notallowed").toString());
0641: }
0642: }
0643: }
0644:
0645: super .updateByte(columnIndex, x);
0646: }
0647:
0648: /**
0649: * Sets the designated column in either the current row or the insert
0650: * row of this <code>CachedRowSetImpl</code> object with the given
0651: * <code>byte</code> value.
0652: * <P>
0653: * This method updates a column value in the current row or the insert
0654: * row of this rowset, but it does not update the database.
0655: * If the cursor is on a row in the rowset, the
0656: * method {@link #updateRow} must be called to update the database.
0657: * If the cursor is on the insert row, the method {@link #insertRow}
0658: * must be called, which will insert the new row into both this rowset
0659: * and the database. Both of these methods must be called before the
0660: * cursor moves to another row.
0661: *
0662: * @param columnName a <code>String</code> object that must match the
0663: * SQL name of a column in this rowset, ignoring case
0664: * @param x the new column value
0665: * @throws SQLException if (1) the given column name does not match the
0666: * name of a column in this rowset, (2) the cursor is not on
0667: * one of this rowset's rows or its insert row, or (3) this
0668: * rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
0669: */
0670: public void updateByte(String columnName, byte x)
0671: throws SQLException {
0672:
0673: this .updateByte(findColumn(columnName), x);
0674: }
0675:
0676: /**
0677: * Sets the designated column in either the current row or the insert
0678: * row of this <code>CachedRowSetImpl</code> object with the given
0679: * <code>short</code> value.
0680: * <P>
0681: * This method updates a column value in the current row or the insert
0682: * row of this rowset, but it does not update the database.
0683: * If the cursor is on a row in the rowset, the
0684: * method {@link #updateRow} must be called to update the database.
0685: * If the cursor is on the insert row, the method {@link #insertRow}
0686: * must be called, which will insert the new row into both this rowset
0687: * and the database. Both of these methods must be called before the
0688: * cursor moves to another row.
0689: *
0690: * @param columnIndex the first column is <code>1</code>, the second
0691: * is <code>2</code>, and so on; must be <code>1</code> or larger
0692: * and equal to or less than the number of columns in this rowset
0693: * @param x the new column value
0694: * @throws SQLException if (1) the given column index is out of bounds,
0695: * (2) the cursor is not on one of this rowset's rows or its
0696: * insert row, or (3) this rowset is
0697: * <code>ResultSet.CONCUR_READ_ONLY</code>
0698: */
0699: public void updateShort(int columnIndex, short x)
0700: throws SQLException {
0701:
0702: boolean bool;
0703:
0704: if (onInsertRow) {
0705: if (p != null) {
0706: bool = p.evaluate(new Short(x), columnIndex);
0707:
0708: if (!bool) {
0709: throw new SQLException(resBundle.handleGetObject(
0710: "filteredrowsetimpl.notallowed").toString());
0711: }
0712: }
0713: }
0714:
0715: super .updateShort(columnIndex, x);
0716: }
0717:
0718: /**
0719: * Sets the designated column in either the current row or the insert
0720: * row of this <code>CachedRowSetImpl</code> object with the given
0721: * <code>short</code> value.
0722: * <P>
0723: * This method updates a column value in the current row or the insert
0724: * row of this rowset, but it does not update the database.
0725: * If the cursor is on a row in the rowset, the
0726: * method {@link #updateRow} must be called to update the database.
0727: * If the cursor is on the insert row, the method {@link #insertRow}
0728: * must be called, which will insert the new row into both this rowset
0729: * and the database. Both of these methods must be called before the
0730: * cursor moves to another row.
0731: *
0732: * @param columnName a <code>String</code> object that must match the
0733: * SQL name of a column in this rowset, ignoring case
0734: * @param x the new column value
0735: * @throws SQLException if (1) the given column name does not match the
0736: * name of a column in this rowset, (2) the cursor is not on
0737: * one of this rowset's rows or its insert row, or (3) this
0738: * rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
0739: */
0740: public void updateShort(String columnName, short x)
0741: throws SQLException {
0742:
0743: this .updateShort(findColumn(columnName), x);
0744: }
0745:
0746: /**
0747: * Sets the designated column in either the current row or the insert
0748: * row of this <code>CachedRowSetImpl</code> object with the given
0749: * <code>long</code> value.
0750: * <P>
0751: * This method updates a column value in the current row or the insert
0752: * row of this rowset, but it does not update the database.
0753: * If the cursor is on a row in the rowset, the
0754: * method {@link #updateRow} must be called to update the database.
0755: * If the cursor is on the insert row, the method {@link #insertRow}
0756: * must be called, which will insert the new row into both this rowset
0757: * and the database. Both of these methods must be called before the
0758: * cursor moves to another row.
0759: *
0760: * @param columnIndex the first column is <code>1</code>, the second
0761: * is <code>2</code>, and so on; must be <code>1</code> or larger
0762: * and equal to or less than the number of columns in this rowset
0763: * @param x the new column value
0764: * @throws SQLException if (1) the given column index is out of bounds,
0765: * (2) the cursor is not on one of this rowset's rows or its
0766: * insert row, or (3) this rowset is
0767: * <code>ResultSet.CONCUR_READ_ONLY</code>
0768: */
0769: public void updateLong(int columnIndex, long x) throws SQLException {
0770:
0771: boolean bool;
0772:
0773: if (onInsertRow) {
0774: if (p != null) {
0775: bool = p.evaluate(new Long(x), columnIndex);
0776:
0777: if (!bool) {
0778: throw new SQLException(resBundle.handleGetObject(
0779: "filteredrowsetimpl.notallowed").toString());
0780: }
0781: }
0782: }
0783:
0784: super .updateLong(columnIndex, x);
0785: }
0786:
0787: /**
0788: * Sets the designated column in either the current row or the insert
0789: * row of this <code>CachedRowSetImpl</code> object with the given
0790: * <code>long</code> value.
0791: * <P>
0792: * This method updates a column value in the current row or the insert
0793: * row of this rowset, but it does not update the database.
0794: * If the cursor is on a row in the rowset, the
0795: * method {@link #updateRow} must be called to update the database.
0796: * If the cursor is on the insert row, the method {@link #insertRow}
0797: * must be called, which will insert the new row into both this rowset
0798: * and the database. Both of these methods must be called before the
0799: * cursor moves to another row.
0800: *
0801: * @param columnName a <code>String</code> object that must match the
0802: * SQL name of a column in this rowset, ignoring case
0803: * @param x the new column value
0804: * @throws SQLException if (1) the given column name does not match the
0805: * name of a column in this rowset, (2) the cursor is not on
0806: * one of this rowset's rows or its insert row, or (3) this
0807: * rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
0808: */
0809: public void updateLong(String columnName, long x)
0810: throws SQLException {
0811:
0812: this .updateLong(findColumn(columnName), x);
0813: }
0814:
0815: /**
0816: * Sets the designated column in either the current row or the insert
0817: * row of this <code>CachedRowSetImpl</code> object with the given
0818: * <code>float</code> value.
0819: * <P>
0820: * This method updates a column value in the current row or the insert
0821: * row of this rowset, but it does not update the database.
0822: * If the cursor is on a row in the rowset, the
0823: * method {@link #updateRow} must be called to update the database.
0824: * If the cursor is on the insert row, the method {@link #insertRow}
0825: * must be called, which will insert the new row into both this rowset
0826: * and the database. Both of these methods must be called before the
0827: * cursor moves to another row.
0828: *
0829: * @param columnIndex the first column is <code>1</code>, the second
0830: * is <code>2</code>, and so on; must be <code>1</code> or larger
0831: * and equal to or less than the number of columns in this rowset
0832: * @param x the new column value
0833: * @throws SQLException if (1) the given column index is out of bounds,
0834: * (2) the cursor is not on one of this rowset's rows or its
0835: * insert row, or (3) this rowset is
0836: * <code>ResultSet.CONCUR_READ_ONLY</code>
0837: */
0838: public void updateFloat(int columnIndex, float x)
0839: throws SQLException {
0840:
0841: boolean bool;
0842:
0843: if (onInsertRow) {
0844: if (p != null) {
0845: bool = p.evaluate(new Float(x), columnIndex);
0846:
0847: if (!bool) {
0848: throw new SQLException(resBundle.handleGetObject(
0849: "filteredrowsetimpl.notallowed").toString());
0850: }
0851: }
0852: }
0853:
0854: super .updateFloat(columnIndex, x);
0855: }
0856:
0857: /**
0858: * Sets the designated column in either the current row or the insert
0859: * row of this <code>CachedRowSetImpl</code> object with the given
0860: * <code>float</code> value.
0861: * <P>
0862: * This method updates a column value in the current row or the insert
0863: * row of this rowset, but it does not update the database.
0864: * If the cursor is on a row in the rowset, the
0865: * method {@link #updateRow} must be called to update the database.
0866: * If the cursor is on the insert row, the method {@link #insertRow}
0867: * must be called, which will insert the new row into both this rowset
0868: * and the database. Both of these methods must be called before the
0869: * cursor moves to another row.
0870: *
0871: * @param columnName a <code>String</code> object that must match the
0872: * SQL name of a column in this rowset, ignoring case
0873: * @param x the new column value
0874: * @throws SQLException if (1) the given column name does not match the
0875: * name of a column in this rowset, (2) the cursor is not on
0876: * one of this rowset's rows or its insert row, or (3) this
0877: * rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
0878: */
0879: public void updateFloat(String columnName, float x)
0880: throws SQLException {
0881:
0882: this .updateFloat(findColumn(columnName), x);
0883: }
0884:
0885: /**
0886: * Sets the designated column in either the current row or the insert
0887: * row of this <code>CachedRowSetImpl</code> object with the given
0888: * <code>double</code> value.
0889: *
0890: * This method updates a column value in either the current row or
0891: * the insert row of this rowset, but it does not update the
0892: * database. If the cursor is on a row in the rowset, the
0893: * method {@link #updateRow} must be called to update the database.
0894: * If the cursor is on the insert row, the method {@link #insertRow}
0895: * must be called, which will insert the new row into both this rowset
0896: * and the database. Both of these methods must be called before the
0897: * cursor moves to another row.
0898: *
0899: * @param columnIndex the first column is <code>1</code>, the second
0900: * is <code>2</code>, and so on; must be <code>1</code> or larger
0901: * and equal to or less than the number of columns in this rowset
0902: * @param x the new column value
0903: * @throws SQLException if (1) the given column index is out of bounds,
0904: * (2) the cursor is not on one of this rowset's rows or its
0905: * insert row, or (3) this rowset is
0906: * <code>ResultSet.CONCUR_READ_ONLY</code>
0907: */
0908: public void updateDouble(int columnIndex, double x)
0909: throws SQLException {
0910:
0911: boolean bool;
0912:
0913: if (onInsertRow) {
0914: if (p != null) {
0915: bool = p.evaluate(new Double(x), columnIndex);
0916:
0917: if (!bool) {
0918: throw new SQLException(resBundle.handleGetObject(
0919: "filteredrowsetimpl.notallowed").toString());
0920: }
0921: }
0922: }
0923:
0924: super .updateDouble(columnIndex, x);
0925: }
0926:
0927: /**
0928: * Sets the designated column in either the current row or the insert
0929: * row of this <code>CachedRowSetImpl</code> object with the given
0930: * <code>double</code> value.
0931: *
0932: * This method updates a column value in either the current row or
0933: * the insert row of this rowset, but it does not update the
0934: * database. If the cursor is on a row in the rowset, the
0935: * method {@link #updateRow} must be called to update the database.
0936: * If the cursor is on the insert row, the method {@link #insertRow}
0937: * must be called, which will insert the new row into both this rowset
0938: * and the database. Both of these methods must be called before the
0939: * cursor moves to another row.
0940: *
0941: * @param columnName a <code>String</code> object that must match the
0942: * SQL name of a column in this rowset, ignoring case
0943: * @param x the new column value
0944: * @throws SQLException if (1) the given column name does not match the
0945: * name of a column in this rowset, (2) the cursor is not on
0946: * one of this rowset's rows or its insert row, or (3) this
0947: * rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
0948: */
0949: public void updateDouble(String columnName, double x)
0950: throws SQLException {
0951:
0952: this .updateDouble(findColumn(columnName), x);
0953: }
0954:
0955: /**
0956: * Sets the designated column in either the current row or the insert
0957: * row of this <code>CachedRowSetImpl</code> object with the given
0958: * <code>java.math.BigDecimal</code> object.
0959: * <P>
0960: * This method updates a column value in the current row or the insert
0961: * row of this rowset, but it does not update the database.
0962: * If the cursor is on a row in the rowset, the
0963: * method {@link #updateRow} must be called to update the database.
0964: * If the cursor is on the insert row, the method {@link #insertRow}
0965: * must be called, which will insert the new row into both this rowset
0966: * and the database. Both of these methods must be called before the
0967: * cursor moves to another row.
0968: *
0969: * @param columnIndex the first column is <code>1</code>, the second
0970: * is <code>2</code>, and so on; must be <code>1</code> or larger
0971: * and equal to or less than the number of columns in this rowset
0972: * @param x the new column value
0973: * @throws SQLException if (1) the given column index is out of bounds,
0974: * (2) the cursor is not on one of this rowset's rows or its
0975: * insert row, or (3) this rowset is
0976: * <code>ResultSet.CONCUR_READ_ONLY</code>
0977: */
0978: public void updateBigDecimal(int columnIndex, BigDecimal x)
0979: throws SQLException {
0980:
0981: boolean bool;
0982:
0983: if (onInsertRow) {
0984: if (p != null) {
0985: bool = p.evaluate(x, columnIndex);
0986:
0987: if (!bool) {
0988: throw new SQLException(resBundle.handleGetObject(
0989: "filteredrowsetimpl.notallowed").toString());
0990: }
0991: }
0992: }
0993:
0994: super .updateBigDecimal(columnIndex, x);
0995: }
0996:
0997: /**
0998: * Sets the designated column in either the current row or the insert
0999: * row of this <code>CachedRowSetImpl</code> object with the given
1000: * <code>java.math.BigDecimal</code> object.
1001: * <P>
1002: * This method updates a column value in the current row or the insert
1003: * row of this rowset, but it does not update the database.
1004: * If the cursor is on a row in the rowset, the
1005: * method {@link #updateRow} must be called to update the database.
1006: * If the cursor is on the insert row, the method {@link #insertRow}
1007: * must be called, which will insert the new row into both this rowset
1008: * and the database. Both of these methods must be called before the
1009: * cursor moves to another row.
1010: *
1011: * @param columnName a <code>String</code> object that must match the
1012: * SQL name of a column in this rowset, ignoring case
1013: * @param x the new column value
1014: * @throws SQLException if (1) the given column name does not match the
1015: * name of a column in this rowset, (2) the cursor is not on
1016: * one of this rowset's rows or its insert row, or (3) this
1017: * rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
1018: */
1019: public void updateBigDecimal(String columnName, BigDecimal x)
1020: throws SQLException {
1021:
1022: this .updateBigDecimal(findColumn(columnName), x);
1023: }
1024:
1025: /**
1026: * Sets the designated column in either the current row or the insert
1027: * row of this <code>CachedRowSetImpl</code> object with the given
1028: * <code>String</code> object.
1029: * <P>
1030: * This method updates a column value in either the current row or
1031: * the insert row of this rowset, but it does not update the
1032: * database. If the cursor is on a row in the rowset, the
1033: * method {@link #updateRow} must be called to mark the row as updated.
1034: * If the cursor is on the insert row, the method {@link #insertRow}
1035: * must be called to insert the new row into this rowset and mark it
1036: * as inserted. Both of these methods must be called before the
1037: * cursor moves to another row.
1038: * <P>
1039: * The method <code>acceptChanges</code> must be called if the
1040: * updated values are to be written back to the underlying database.
1041: *
1042: * @param columnIndex the first column is <code>1</code>, the second
1043: * is <code>2</code>, and so on; must be <code>1</code> or larger
1044: * and equal to or less than the number of columns in this rowset
1045: * @param x the new column value
1046: * @throws SQLException if (1) the given column index is out of bounds,
1047: * (2) the cursor is not on one of this rowset's rows or its
1048: * insert row, or (3) this rowset is
1049: * <code>ResultSet.CONCUR_READ_ONLY</code>
1050: */
1051: public void updateString(int columnIndex, String x)
1052: throws SQLException {
1053:
1054: boolean bool;
1055:
1056: if (onInsertRow) {
1057: if (p != null) {
1058: bool = p.evaluate(x, columnIndex);
1059:
1060: if (!bool) {
1061: throw new SQLException(resBundle.handleGetObject(
1062: "filteredrowsetimpl.notallowed").toString());
1063: }
1064: }
1065: }
1066:
1067: super .updateString(columnIndex, x);
1068: }
1069:
1070: /**
1071: * Sets the designated column in either the current row or the insert
1072: * row of this <code>CachedRowSetImpl</code> object with the given
1073: * <code>String</code> object.
1074: *
1075: * This method updates a column value in either the current row or
1076: * the insert row of this rowset, but it does not update the
1077: * database. If the cursor is on a row in the rowset, the
1078: * method {@link #updateRow} must be called to update the database.
1079: * If the cursor is on the insert row, the method {@link #insertRow}
1080: * must be called, which will insert the new row into both this rowset
1081: * and the database. Both of these methods must be called before the
1082: * cursor moves to another row.
1083: *
1084: * @param columnName a <code>String</code> object that must match the
1085: * SQL name of a column in this rowset, ignoring case
1086: * @param x the new column value
1087: * @throws SQLException if (1) the given column name does not match the
1088: * name of a column in this rowset, (2) the cursor is not on
1089: * one of this rowset's rows or its insert row, or (3) this
1090: * rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
1091: */
1092: public void updateString(String columnName, String x)
1093: throws SQLException {
1094:
1095: this .updateString(findColumn(columnName), x);
1096: }
1097:
1098: /**
1099: * Sets the designated column in either the current row or the insert
1100: * row of this <code>CachedRowSetImpl</code> object with the given
1101: * <code>byte</code> array.
1102: *
1103: * This method updates a column value in either the current row or
1104: * the insert row of this rowset, but it does not update the
1105: * database. If the cursor is on a row in the rowset, the
1106: * method {@link #updateRow} must be called to update the database.
1107: * If the cursor is on the insert row, the method {@link #insertRow}
1108: * must be called, which will insert the new row into both this rowset
1109: * and the database. Both of these methods must be called before the
1110: * cursor moves to another row.
1111: *
1112: * @param columnIndex the first column is <code>1</code>, the second
1113: * is <code>2</code>, and so on; must be <code>1</code> or larger
1114: * and equal to or less than the number of columns in this rowset
1115: * @param x the new column value
1116: * @throws SQLException if (1) the given column index is out of bounds,
1117: * (2) the cursor is not on one of this rowset's rows or its
1118: * insert row, or (3) this rowset is
1119: * <code>ResultSet.CONCUR_READ_ONLY</code>
1120: */
1121: public void updateBytes(int columnIndex, byte[] x)
1122: throws SQLException {
1123:
1124: boolean bool;
1125: String val = new String();
1126:
1127: Byte[] obj_arr = new Byte[x.length];
1128:
1129: for (int i = 0; i < x.length; i++) {
1130: obj_arr[i] = new Byte(x[i]);
1131: val = val.concat(obj_arr[i].toString());
1132: }
1133:
1134: if (onInsertRow) {
1135: if (p != null) {
1136: bool = p.evaluate(val, columnIndex);
1137:
1138: if (!bool) {
1139: throw new SQLException(resBundle.handleGetObject(
1140: "filteredrowsetimpl.notallowed").toString());
1141: }
1142: }
1143: }
1144:
1145: super .updateBytes(columnIndex, x);
1146: }
1147:
1148: /**
1149: * Sets the designated column in either the current row or the insert
1150: * row of this <code>CachedRowSetImpl</code> object with the given
1151: * <code>byte</code> array.
1152: *
1153: * This method updates a column value in either the current row or
1154: * the insert row of this rowset, but it does not update the
1155: * database. If the cursor is on a row in the rowset, the
1156: * method {@link #updateRow} must be called to update the database.
1157: * If the cursor is on the insert row, the method {@link #insertRow}
1158: * must be called, which will insert the new row into both this rowset
1159: * and the database. Both of these methods must be called before the
1160: * cursor moves to another row.
1161: *
1162: * @param columnName a <code>String</code> object that must match the
1163: * SQL name of a column in this rowset, ignoring case
1164: * @param x the new column value
1165: * @throws SQLException if (1) the given column name does not match the
1166: * name of a column in this rowset, (2) the cursor is not on
1167: * one of this rowset's rows or its insert row, or (3) this
1168: * rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
1169: */
1170: public void updateBytes(String columnName, byte[] x)
1171: throws SQLException {
1172:
1173: this .updateBytes(findColumn(columnName), x);
1174: }
1175:
1176: /**
1177: * Sets the designated column in either the current row or the insert
1178: * row of this <code>CachedRowSetImpl</code> object with the given
1179: * <code>Date</code> object.
1180: *
1181: * This method updates a column value in either the current row or
1182: * the insert row of this rowset, but it does not update the
1183: * database. If the cursor is on a row in the rowset, the
1184: * method {@link #updateRow} must be called to update the database.
1185: * If the cursor is on the insert row, the method {@link #insertRow}
1186: * must be called, which will insert the new row into both this rowset
1187: * and the database. Both of these methods must be called before the
1188: * cursor moves to another row.
1189: *
1190: * @param columnIndex the first column is <code>1</code>, the second
1191: * is <code>2</code>, and so on; must be <code>1</code> or larger
1192: * and equal to or less than the number of columns in this rowset
1193: * @param x the new column value
1194: * @throws SQLException if (1) the given column index is out of bounds,
1195: * (2) the cursor is not on one of this rowset's rows or its
1196: * insert row, (3) the type of the designated column is not
1197: * an SQL <code>DATE</code> or <code>TIMESTAMP</code>, or
1198: * (4) this rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
1199: */
1200: public void updateDate(int columnIndex, java.sql.Date x)
1201: throws SQLException {
1202:
1203: boolean bool;
1204:
1205: if (onInsertRow) {
1206: if (p != null) {
1207: bool = p.evaluate(x, columnIndex);
1208:
1209: if (!bool) {
1210: throw new SQLException(resBundle.handleGetObject(
1211: "filteredrowsetimpl.notallowed").toString());
1212: }
1213: }
1214: }
1215:
1216: super .updateDate(columnIndex, x);
1217: }
1218:
1219: /**
1220: * Sets the designated column in either the current row or the insert
1221: * row of this <code>CachedRowSetImpl</code> object with the given
1222: * <code>Date</code> object.
1223: *
1224: * This method updates a column value in either the current row or
1225: * the insert row of this rowset, but it does not update the
1226: * database. If the cursor is on a row in the rowset, the
1227: * method {@link #updateRow} must be called to update the database.
1228: * If the cursor is on the insert row, the method {@link #insertRow}
1229: * must be called, which will insert the new row into both this rowset
1230: * and the database. Both of these methods must be called before the
1231: * cursor moves to another row.
1232: *
1233: * @param columnName a <code>String</code> object that must match the
1234: * SQL name of a column in this rowset, ignoring case
1235: * @param x the new column value
1236: * @throws SQLException if (1) the given column name does not match the
1237: * name of a column in this rowset, (2) the cursor is not on
1238: * one of this rowset's rows or its insert row, (3) the type
1239: * of the designated column is not an SQL <code>DATE</code> or
1240: * <code>TIMESTAMP</code>, or (4) this rowset is
1241: * <code>ResultSet.CONCUR_READ_ONLY</code>
1242: */
1243: public void updateDate(String columnName, java.sql.Date x)
1244: throws SQLException {
1245:
1246: this .updateDate(findColumn(columnName), x);
1247: }
1248:
1249: /**
1250: * Sets the designated column in either the current row or the insert
1251: * row of this <code>CachedRowSetImpl</code> object with the given
1252: * <code>Time</code> object.
1253: *
1254: * This method updates a column value in either the current row or
1255: * the insert row of this rowset, but it does not update the
1256: * database. If the cursor is on a row in the rowset, the
1257: * method {@link #updateRow} must be called to update the database.
1258: * If the cursor is on the insert row, the method {@link #insertRow}
1259: * must be called, which will insert the new row into both this rowset
1260: * and the database. Both of these methods must be called before the
1261: * cursor moves to another row.
1262: *
1263: * @param columnIndex the first column is <code>1</code>, the second
1264: * is <code>2</code>, and so on; must be <code>1</code> or larger
1265: * and equal to or less than the number of columns in this rowset
1266: * @param x the new column value
1267: * @throws SQLException if (1) the given column index is out of bounds,
1268: * (2) the cursor is not on one of this rowset's rows or its
1269: * insert row, (3) the type of the designated column is not
1270: * an SQL <code>TIME</code> or <code>TIMESTAMP</code>, or
1271: * (4) this rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
1272: */
1273: public void updateTime(int columnIndex, Time x) throws SQLException {
1274:
1275: boolean bool;
1276:
1277: if (onInsertRow) {
1278: if (p != null) {
1279: bool = p.evaluate(x, columnIndex);
1280:
1281: if (!bool) {
1282: throw new SQLException(resBundle.handleGetObject(
1283: "filteredrowsetimpl.notallowed").toString());
1284: }
1285: }
1286: }
1287:
1288: super .updateTime(columnIndex, x);
1289: }
1290:
1291: /**
1292: * Sets the designated column in either the current row or the insert
1293: * row of this <code>CachedRowSetImpl</code> object with the given
1294: * <code>Time</code> object.
1295: *
1296: * This method updates a column value in either the current row or
1297: * the insert row of this rowset, but it does not update the
1298: * database. If the cursor is on a row in the rowset, the
1299: * method {@link #updateRow} must be called to update the database.
1300: * If the cursor is on the insert row, the method {@link #insertRow}
1301: * must be called, which will insert the new row into both this rowset
1302: * and the database. Both of these methods must be called before the
1303: * cursor moves to another row.
1304: *
1305: * @param columnName a <code>String</code> object that must match the
1306: * SQL name of a column in this rowset, ignoring case
1307: * @param x the new column value
1308: * @throws SQLException if (1) the given column name does not match the
1309: * name of a column in this rowset, (2) the cursor is not on
1310: * one of this rowset's rows or its insert row, (3) the type
1311: * of the designated column is not an SQL <code>TIME</code> or
1312: * <code>TIMESTAMP</code>, or (4) this rowset is
1313: * <code>ResultSet.CONCUR_READ_ONLY</code>
1314: */
1315: public void updateTime(String columnName, Time x)
1316: throws SQLException {
1317:
1318: this .updateTime(findColumn(columnName), x);
1319: }
1320:
1321: /**
1322: * Sets the designated column in either the current row or the insert
1323: * row of this <code>CachedRowSetImpl</code> object with the given
1324: * <code>Timestamp</code> object.
1325: *
1326: * This method updates a column value in either the current row or
1327: * the insert row of this rowset, but it does not update the
1328: * database. If the cursor is on a row in the rowset, the
1329: * method {@link #updateRow} must be called to update the database.
1330: * If the cursor is on the insert row, the method {@link #insertRow}
1331: * must be called, which will insert the new row into both this rowset
1332: * and the database. Both of these methods must be called before the
1333: * cursor moves to another row.
1334: *
1335: * @param columnIndex the first column is <code>1</code>, the second
1336: * is <code>2</code>, and so on; must be <code>1</code> or larger
1337: * and equal to or less than the number of columns in this rowset
1338: * @param x the new column value
1339: * @throws SQLException if (1) the given column index is out of bounds,
1340: * (2) the cursor is not on one of this rowset's rows or its
1341: * insert row, (3) the type of the designated column is not
1342: * an SQL <code>DATE</code>, <code>TIME</code>, or
1343: * <code>TIMESTAMP</code>, or (4) this rowset is
1344: * <code>ResultSet.CONCUR_READ_ONLY</code>
1345: */
1346: public void updateTimestamp(int columnIndex, Timestamp x)
1347: throws SQLException {
1348:
1349: boolean bool;
1350:
1351: if (onInsertRow) {
1352: if (p != null) {
1353: bool = p.evaluate(x, columnIndex);
1354:
1355: if (!bool) {
1356: throw new SQLException(resBundle.handleGetObject(
1357: "filteredrowsetimpl.notallowed").toString());
1358: }
1359: }
1360: }
1361:
1362: super .updateTimestamp(columnIndex, x);
1363: }
1364:
1365: /**
1366: * Sets the designated column in either the current row or the insert
1367: * row of this <code>CachedRowSetImpl</code> object with the given
1368: * <code>Timestamp</code> object.
1369: *
1370: * This method updates a column value in either the current row or
1371: * the insert row of this rowset, but it does not update the
1372: * database. If the cursor is on a row in the rowset, the
1373: * method {@link #updateRow} must be called to update the database.
1374: * If the cursor is on the insert row, the method {@link #insertRow}
1375: * must be called, which will insert the new row into both this rowset
1376: * and the database. Both of these methods must be called before the
1377: * cursor moves to another row.
1378: *
1379: * @param columnName a <code>String</code> object that must match the
1380: * SQL name of a column in this rowset, ignoring case
1381: * @param x the new column value
1382: * @throws SQLException if the given column index is out of bounds or
1383: * the cursor is not on one of this rowset's rows or its
1384: * insert row
1385: * @throws SQLException if (1) the given column name does not match the
1386: * name of a column in this rowset, (2) the cursor is not on
1387: * one of this rowset's rows or its insert row, (3) the type
1388: * of the designated column is not an SQL <code>DATE</code>,
1389: * <code>TIME</code>, or <code>TIMESTAMP</code>, or (4) this
1390: * rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
1391: */
1392: public void updateTimestamp(String columnName, Timestamp x)
1393: throws SQLException {
1394:
1395: this .updateTimestamp(findColumn(columnName), x);
1396: }
1397:
1398: /**
1399: * Sets the designated column in either the current row or the insert
1400: * row of this <code>CachedRowSetImpl</code> object with the given
1401: * ASCII stream value.
1402: * <P>
1403: * This method updates a column value in either the current row or
1404: * the insert row of this rowset, but it does not update the
1405: * database. If the cursor is on a row in the rowset, the
1406: * method {@link #updateRow} must be called to update the database.
1407: * If the cursor is on the insert row, the method {@link #insertRow}
1408: * must be called, which will insert the new row into both this rowset
1409: * and the database. Both of these methods must be called before the
1410: * cursor moves to another row.
1411: *
1412: * @param columnIndex the first column is <code>1</code>, the second
1413: * is <code>2</code>, and so on; must be <code>1</code> or larger
1414: * and equal to or less than the number of columns in this rowset
1415: * @param x the new column value
1416: * @param length the number of one-byte ASCII characters in the stream
1417: * @throws SQLException if this method is invoked
1418: */
1419: public void updateAsciiStream(int columnIndex,
1420: java.io.InputStream x, int length) throws SQLException {
1421:
1422: boolean bool;
1423:
1424: if (onInsertRow) {
1425: if (p != null) {
1426: bool = p.evaluate(x, columnIndex);
1427:
1428: if (!bool) {
1429: throw new SQLException(resBundle.handleGetObject(
1430: "filteredrowsetimpl.notallowed").toString());
1431: }
1432: }
1433: }
1434:
1435: super .updateAsciiStream(columnIndex, x, length);
1436: }
1437:
1438: /**
1439: * Sets the designated column in either the current row or the insert
1440: * row of this <code>CachedRowSetImpl</code> object with the given
1441: * ASCII stream value.
1442: * <P>
1443: * This method updates a column value in either the current row or
1444: * the insert row of this rowset, but it does not update the
1445: * database. If the cursor is on a row in the rowset, the
1446: * method {@link #updateRow} must be called to update the database.
1447: * If the cursor is on the insert row, the method {@link #insertRow}
1448: * must be called, which will insert the new row into both this rowset
1449: * and the database. Both of these methods must be called before the
1450: * cursor moves to another row.
1451: *
1452: * @param columnName a <code>String</code> object that must match the
1453: * SQL name of a column in this rowset, ignoring case
1454: * @param x the new column value
1455: * @param length the number of one-byte ASCII characters in the stream
1456: */
1457: public void updateAsciiStream(String columnName,
1458: java.io.InputStream x, int length) throws SQLException {
1459:
1460: this .updateAsciiStream(findColumn(columnName), x, length);
1461: }
1462:
1463: /**
1464: * Sets the designated column in either the current row or the insert
1465: * row of this <code>CachedRowSetImpl</code> object with the given
1466: * <code>java.io.Reader</code> object.
1467: * <P>
1468: * This method updates a column value in either the current row or
1469: * the insert row of this rowset, but it does not update the
1470: * database. If the cursor is on a row in the rowset, the
1471: * method {@link #updateRow} must be called to update the database.
1472: * If the cursor is on the insert row, the method {@link #insertRow}
1473: * must be called, which will insert the new row into both this rowset
1474: * and the database. Both of these methods must be called before the
1475: * cursor moves to another row.
1476: *
1477: * @param columnIndex the first column is <code>1</code>, the second
1478: * is <code>2</code>, and so on; must be <code>1</code> or larger
1479: * and equal to or less than the number of columns in this rowset
1480: * @param x the new column value; must be a <code>java.io.Reader</code>
1481: * containing <code>BINARY</code>, <code>VARBINARY</code>,
1482: * <code>LONGVARBINARY</code>, <code>CHAR</code>, <code>VARCHAR</code>,
1483: * or <code>LONGVARCHAR</code> data
1484: * @param length the length of the stream in characters
1485: * @throws SQLException if (1) the given column index is out of bounds,
1486: * (2) the cursor is not on one of this rowset's rows or its
1487: * insert row, (3) the data in the stream is not a binary or
1488: * character type, or (4) this rowset is
1489: * <code>ResultSet.CONCUR_READ_ONLY</code>
1490: */
1491: public void updateCharacterStream(int columnIndex,
1492: java.io.Reader x, int length) throws SQLException {
1493:
1494: boolean bool;
1495:
1496: if (onInsertRow) {
1497: if (p != null) {
1498: bool = p.evaluate(x, columnIndex);
1499:
1500: if (!bool) {
1501: throw new SQLException(resBundle.handleGetObject(
1502: "filteredrowsetimpl.notallowed").toString());
1503: }
1504: }
1505: }
1506:
1507: super .updateCharacterStream(columnIndex, x, length);
1508: }
1509:
1510: /**
1511: * Sets the designated column in either the current row or the insert
1512: * row of this <code>CachedRowSetImpl</code> object with the given
1513: * <code>java.io.Reader</code> object.
1514: * <P>
1515: * This method updates a column value in either the current row or
1516: * the insert row of this rowset, but it does not update the
1517: * database. If the cursor is on a row in the rowset, the
1518: * method {@link #updateRow} must be called to update the database.
1519: * If the cursor is on the insert row, the method {@link #insertRow}
1520: * must be called, which will insert the new row into both this rowset
1521: * and the database. Both of these methods must be called before the
1522: * cursor moves to another row.
1523: *
1524: * @param columnName a <code>String</code> object that must match the
1525: * SQL name of a column in this rowset, ignoring case
1526: * @param reader the new column value; must be a
1527: * <code>java.io.Reader</code> containing <code>BINARY</code>,
1528: * <code>VARBINARY</code>, <code>LONGVARBINARY</code>, <code>CHAR</code>,
1529: * <code>VARCHAR</code>, or <code>LONGVARCHAR</code> data
1530: * @param length the length of the stream in characters
1531: * @throws SQLException if (1) the given column name does not match the
1532: * name of a column in this rowset, (2) the cursor is not on
1533: * one of this rowset's rows or its insert row, (3) the data
1534: * in the stream is not a binary or character type, or (4) this
1535: * rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
1536: */
1537: public void updateCharacterStream(String columnName,
1538: java.io.Reader reader, int length) throws SQLException {
1539: this .updateCharacterStream(findColumn(columnName), reader,
1540: length);
1541: }
1542:
1543: /**
1544: * Sets the designated column in either the current row or the insert
1545: * row of this <code>CachedRowSetImpl</code> object with the given
1546: * <code>java.io.InputStream</code> object.
1547: * <P>
1548: * This method updates a column value in either the current row or
1549: * the insert row of this rowset, but it does not update the
1550: * database. If the cursor is on a row in the rowset, the
1551: * method {@link #updateRow} must be called to update the database.
1552: * If the cursor is on the insert row, the method {@link #insertRow}
1553: * must be called, which will insert the new row into both this rowset
1554: * and the database. Both of these methods must be called before the
1555: * cursor moves to another row.
1556: *
1557: * @param columnIndex the first column is <code>1</code>, the second
1558: * is <code>2</code>, and so on; must be <code>1</code> or larger
1559: * and equal to or less than the number of columns in this rowset
1560: * @param x the new column value; must be a <code>java.io.InputStream</code>
1561: * containing <code>BINARY</code>, <code>VARBINARY</code>, or
1562: * <code>LONGVARBINARY</code> data
1563: * @param length the length of the stream in bytes
1564: * @throws SQLException if (1) the given column index is out of bounds,
1565: * (2) the cursor is not on one of this rowset's rows or its
1566: * insert row, (3) the data in the stream is not binary, or
1567: * (4) this rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
1568: */
1569: public void updateBinaryStream(int columnIndex,
1570: java.io.InputStream x, int length) throws SQLException {
1571:
1572: boolean bool;
1573:
1574: if (onInsertRow) {
1575: if (p != null) {
1576: bool = p.evaluate(x, columnIndex);
1577:
1578: if (!bool) {
1579: throw new SQLException(resBundle.handleGetObject(
1580: "filteredrowsetimpl.notallowed").toString());
1581: }
1582: }
1583: }
1584:
1585: super .updateBinaryStream(columnIndex, x, length);
1586: }
1587:
1588: /**
1589: * Sets the designated column in either the current row or the insert
1590: * row of this <code>CachedRowSetImpl</code> object with the given
1591: * <code>java.io.InputStream</code> object.
1592: * <P>
1593: * This method updates a column value in either the current row or
1594: * the insert row of this rowset, but it does not update the
1595: * database. If the cursor is on a row in the rowset, the
1596: * method {@link #updateRow} must be called to update the database.
1597: * If the cursor is on the insert row, the method {@link #insertRow}
1598: * must be called, which will insert the new row into both this rowset
1599: * and the database. Both of these methods must be called before the
1600: * cursor moves to another row.
1601: *
1602: * @param columnName a <code>String</code> object that must match the
1603: * SQL name of a column in this rowset, ignoring case
1604: * @param x the new column value; must be a <code>java.io.InputStream</code>
1605: * containing <code>BINARY</code>, <code>VARBINARY</code>, or
1606: * <code>LONGVARBINARY</code> data
1607: * @param length the length of the stream in bytes
1608: * @throws SQLException if (1) the given column name does not match the
1609: * name of a column in this rowset, (2) the cursor is not on
1610: * one of this rowset's rows or its insert row, (3) the data
1611: * in the stream is not binary, or (4) this rowset is
1612: * <code>ResultSet.CONCUR_READ_ONLY</code>
1613: */
1614: public void updateBinaryStream(String columnName,
1615: java.io.InputStream x, int length) throws SQLException {
1616:
1617: this .updateBinaryStream(findColumn(columnName), x, length);
1618: }
1619:
1620: /**
1621: * Sets the designated column in either the current row or the insert
1622: * row of this <code>CachedRowSetImpl</code> object with the given
1623: * <code>Object</code> value.
1624: * <P>
1625: * This method updates a column value in either the current row or
1626: * the insert row of this rowset, but it does not update the
1627: * database. If the cursor is on a row in the rowset, the
1628: * method {@link #updateRow} must be called to update the database.
1629: * If the cursor is on the insert row, the method {@link #insertRow}
1630: * must be called, which will insert the new row into both this rowset
1631: * and the database. Both of these methods must be called before the
1632: * cursor moves to another row.
1633: *
1634: * @param columnIndex the first column is <code>1</code>, the second
1635: * is <code>2</code>, and so on; must be <code>1</code> or larger
1636: * and equal to or less than the number of columns in this rowset
1637: * @param x the new column value
1638: * @throws SQLException if (1) the given column index is out of bounds,
1639: * (2) the cursor is not on one of this rowset's rows or its
1640: * insert row, or (3) this rowset is
1641: * <code>ResultSet.CONCUR_READ_ONLY</code>
1642: */
1643: public void updateObject(int columnIndex, Object x)
1644: throws SQLException {
1645:
1646: boolean bool;
1647:
1648: if (onInsertRow) {
1649: if (p != null) {
1650: bool = p.evaluate(x, columnIndex);
1651:
1652: if (!bool) {
1653: throw new SQLException(resBundle.handleGetObject(
1654: "filteredrowsetimpl.notallowed").toString());
1655: }
1656: }
1657: }
1658:
1659: super .updateObject(columnIndex, x);
1660: }
1661:
1662: /**
1663: * Sets the designated column in either the current row or the insert
1664: * row of this <code>CachedRowSetImpl</code> object with the given
1665: * <code>Object</code> value.
1666: * <P>
1667: * This method updates a column value in either the current row or
1668: * the insert row of this rowset, but it does not update the
1669: * database. If the cursor is on a row in the rowset, the
1670: * method {@link #updateRow} must be called to update the database.
1671: * If the cursor is on the insert row, the method {@link #insertRow}
1672: * must be called, which will insert the new row into both this rowset
1673: * and the database. Both of these methods must be called before the
1674: * cursor moves to another row.
1675: *
1676: * @param columnName a <code>String</code> object that must match the
1677: * SQL name of a column in this rowset, ignoring case
1678: * @param x the new column value
1679: * @throws SQLException if (1) the given column name does not match the
1680: * name of a column in this rowset, (2) the cursor is not on
1681: * one of this rowset's rows or its insert row, or (3) this
1682: * rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
1683: */
1684: public void updateObject(String columnName, Object x)
1685: throws SQLException {
1686:
1687: this .updateObject(findColumn(columnName), x);
1688: }
1689:
1690: /**
1691: * Sets the designated column in either the current row or the insert
1692: * row of this <code>CachedRowSetImpl</code> object with the given
1693: * <code>Object</code> value. The <code>scale</code> parameter indicates
1694: * the number of digits to the right of the decimal point and is ignored
1695: * if the new column value is not a type that will be mapped to an SQL
1696: * <code>DECIMAL</code> or <code>NUMERIC</code> value.
1697: * <P>
1698: * This method updates a column value in either the current row or
1699: * the insert row of this rowset, but it does not update the
1700: * database. If the cursor is on a row in the rowset, the
1701: * method {@link #updateRow} must be called to update the database.
1702: * If the cursor is on the insert row, the method {@link #insertRow}
1703: * must be called, which will insert the new row into both this rowset
1704: * and the database. Both of these methods must be called before the
1705: * cursor moves to another row.
1706: *
1707: * @param columnIndex the first column is <code>1</code>, the second
1708: * is <code>2</code>, and so on; must be <code>1</code> or larger
1709: * and equal to or less than the number of columns in this rowset
1710: * @param x the new column value
1711: * @param scale the number of digits to the right of the decimal point (for
1712: * <code>DECIMAL</code> and <code>NUMERIC</code> types only)
1713: * @throws SQLException if (1) the given column index is out of bounds,
1714: * (2) the cursor is not on one of this rowset's rows or its
1715: * insert row, or (3) this rowset is
1716: * <code>ResultSet.CONCUR_READ_ONLY</code>
1717: */
1718: public void updateObject(int columnIndex, Object x, int scale)
1719: throws SQLException {
1720:
1721: boolean bool;
1722:
1723: if (onInsertRow) {
1724: if (p != null) {
1725: bool = p.evaluate(x, columnIndex);
1726:
1727: if (!bool) {
1728: throw new SQLException(resBundle.handleGetObject(
1729: "filteredrowsetimpl.notallowed").toString());
1730: }
1731: }
1732: }
1733:
1734: super .updateObject(columnIndex, x, scale);
1735: }
1736:
1737: /**
1738: * Sets the designated column in either the current row or the insert
1739: * row of this <code>CachedRowSetImpl</code> object with the given
1740: * <code>Object</code> value. The <code>scale</code> parameter
1741: * indicates the number of digits to the right of the decimal point
1742: * and is ignored if the new column value is not a type that will be
1743: * mapped to an SQL <code>DECIMAL</code> or <code>NUMERIC</code> value.
1744: * <P>
1745: * This method updates a column value in either the current row or
1746: * the insert row of this rowset, but it does not update the
1747: * database. If the cursor is on a row in the rowset, the
1748: * method {@link #updateRow} must be called to update the database.
1749: * If the cursor is on the insert row, the method {@link #insertRow}
1750: * must be called, which will insert the new row into both this rowset
1751: * and the database. Both of these methods must be called before the
1752: * cursor moves to another row.
1753: *
1754: * @param columnName a <code>String</code> object that must match the
1755: * SQL name of a column in this rowset, ignoring case
1756: * @param x the new column value
1757: * @param scale the number of digits to the right of the decimal point (for
1758: * <code>DECIMAL</code> and <code>NUMERIC</code> types only)
1759: * @throws SQLException if (1) the given column name does not match the
1760: * name of a column in this rowset, (2) the cursor is not on
1761: * one of this rowset's rows or its insert row, or (3) this
1762: * rowset is <code>ResultSet.CONCUR_READ_ONLY</code>
1763: */
1764: public void updateObject(String columnName, Object x, int scale)
1765: throws SQLException {
1766:
1767: this .updateObject(findColumn(columnName), x, scale);
1768: }
1769:
1770: /**
1771: * Inserts the contents of this <code>CachedRowSetImpl</code> object's insert
1772: * row into this rowset immediately following the current row.
1773: * If the current row is the
1774: * position after the last row or before the first row, the new row will
1775: * be inserted at the end of the rowset. This method also notifies
1776: * listeners registered with this rowset that the row has changed.
1777: * <P>
1778: * The cursor must be on the insert row when this method is called.
1779: *
1780: * @throws SQLException if (1) the cursor is not on the insert row,
1781: * (2) one or more of the non-nullable columns in the insert
1782: * row has not been given a value, or (3) this rowset is
1783: * <code>ResultSet.CONCUR_READ_ONLY</code>
1784: */
1785: public void insertRow() throws SQLException {
1786:
1787: onInsertRow = false;
1788: super .insertRow();
1789: }
1790:
1791: static final long serialVersionUID = 6178454588413509360L;
1792: } // end FilteredRowSetImpl class
|