jdk/src/share/classes/com/sun/rowset/internal/Row.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.rowset.internal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.sql.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.math.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.lang.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.lang.reflect.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * A class that keeps track of a row's values. A <code>Row</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * maintains an array of current column values and an array of original
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * column values, and it provides methods for getting and setting the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * value of a column.  It also keeps track of which columns have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * changed and whether the change was a delete, insert, or update.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * Note that column numbers for rowsets start at <code>1</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * whereas the first element of an array or bitset is <code>0</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * The argument for the method <code>getColumnUpdated</code> refers to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * the column number in the rowset (the first column is <code>1</code>);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * the argument for <code>setColumnUpdated</code> refers to the index
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * into the rowset's internal bitset (the first bit is <code>0</code>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
public class Row extends BaseRow implements Serializable, Cloneable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * An array containing the current column values for this <code>Row</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private Object[] currentVals;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * A <code>BitSet</code> object containing a flag for each column in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * this <code>Row</code> object, with each flag indicating whether or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * not the value in the column has been changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private BitSet colsChanged;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * A <code>boolean</code> indicating whether or not this <code>Row</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * object has been deleted.  <code>true</code> indicates that it has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * been deleted; <code>false</code> indicates that it has not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private boolean deleted;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * A <code>boolean</code> indicating whether or not this <code>Row</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * object has been updated.  <code>true</code> indicates that it has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * been updated; <code>false</code> indicates that it has not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private boolean updated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * A <code>boolean</code> indicating whether or not this <code>Row</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * object has been inserted.  <code>true</code> indicates that it has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * been inserted; <code>false</code> indicates that it has not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    private boolean inserted;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * The number of columns in this <code>Row</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    private int numCols;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * Creates a new <code>Row</code> object with the given number of columns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * The newly-created row includes an array of original values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * an array for storing its current values, and a <code>BitSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * object for keeping track of which column values have been changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public Row(int numCols) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        origVals = new Object[numCols];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        currentVals = new Object[numCols];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        colsChanged = new BitSet(numCols);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        this.numCols = numCols;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * Creates a new <code>Row</code> object with the given number of columns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * and with its array of original values initialized to the given array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * The new <code>Row</code> object also has an array for storing its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * current values and a <code>BitSet</code> object for keeping track
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * of which column values have been changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    public Row(int numCols, Object[] vals) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        origVals = new Object[numCols];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        for (int i=0; i < numCols; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            origVals[i] = vals[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        currentVals = new Object[numCols];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        colsChanged = new BitSet(numCols);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        this.numCols = numCols;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * This method is called internally by the <code>CachedRowSet.populate</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 * @param idx the number of the column in this <code>Row</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 *            that is to be set; the index of the first column is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 *            <code>1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * @param val the new value to be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    public void initColumnObject(int idx, Object val) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        origVals[idx - 1] = val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 * This method is called internally by the <code>CachedRowSet.updateXXX</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 * methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 * @param idx the number of the column in this <code>Row</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 *            that is to be set; the index of the first column is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 *            <code>1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
 * @param val the new value to be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    public void setColumnObject(int idx, Object val) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            currentVals[idx - 1] = val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            setColUpdated(idx - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 * Retrieves the column value stored in the designated column of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 * <code>Row</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 * @param columnIndex the index of the column value to be retrieved;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 *                    the index of the first column is <code>1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 * @return an <code>Object</code> in the Java programming language that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 *         represents the value stored in the designated column
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 * @throws SQLException if there is a database access error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    public Object getColumnObject(int columnIndex) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        if (getColUpdated(columnIndex - 1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            return(currentVals[columnIndex - 1]); // maps to array!!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            return(origVals[columnIndex - 1]); // maps to array!!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 * Indicates whether the designated column of this <code>Row</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
 * has been changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
 * @param idx the index into the <code>BitSet</code> object maintained by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
 *            this <code>Row</code> object to keep track of which column
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
 *            values have been modified; the index of the first bit is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
 *            <code>0</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
 * @return <code>true</code> if the designated column value has been changed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
 *         <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    public boolean getColUpdated(int idx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        return colsChanged.get(idx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 * Sets this <code>Row</code> object's <code>deleted</code> field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 * to <code>true</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
 * @see #getDeleted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public void setDeleted() { // %%% was public
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        deleted = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
 * Retrieves the value of this <code>Row</code> object's <code>deleted</code> field,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
 * which will be <code>true</code> if one or more of its columns has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
 * deleted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
 * @return <code>true</code> if a column value has been deleted; <code>false</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
 *         otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
 * @see #setDeleted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public boolean getDeleted() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        return(deleted);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
 * Sets the <code>deleted</code> field for this <code>Row</code> object to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
 * <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    public void clearDeleted() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        deleted = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
 * Sets the value of this <code>Row</code> object's <code>inserted</code> field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
 * to <code>true</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
 * @see #getInserted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    public void setInserted() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        inserted = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
 * Retrieves the value of this <code>Row</code> object's <code>inserted</code> field,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
 * which will be <code>true</code> if this row has been inserted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
 * @return <code>true</code> if this row has been inserted; <code>false</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
 *         otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
 * @see #setInserted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public boolean getInserted() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        return(inserted);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
 * Sets the <code>inserted</code> field for this <code>Row</code> object to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
 * <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    public void clearInserted() { // %%% was public
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        inserted = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
 * Retrieves the value of this <code>Row</code> object's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
 * <code>updated</code> field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
 * @return <code>true</code> if this <code>Row</code> object has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
 *         updated; <code>false</code> if it has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
 * @see #setUpdated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    public boolean getUpdated() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        return(updated);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
 * Sets the <code>updated</code> field for this <code>Row</code> object to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
 * <code>true</code> if one or more of its column values has been changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
 * @see #getUpdated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    public void setUpdated() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        // only mark something as updated if one or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        // more of the columns has been changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        for (int i = 0; i < numCols; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            if (getColUpdated(i) == true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                updated = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
 * Sets the bit at the given index into this <code>Row</code> object's internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
 * <code>BitSet</code> object, indicating that the corresponding column value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
 * (column <code>idx</code> + 1) has been changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
 * @param idx the index into the <code>BitSet</code> object maintained by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
 *            this <code>Row</code> object; the first bit is at index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
 *            <code>0</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    private void setColUpdated(int idx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        colsChanged.set(idx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
 * Sets the <code>updated</code> field for this <code>Row</code> object to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
 * <code>false</code>, sets all the column values in this <code>Row</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
 * object's internal array of current values to <code>null</code>, and clears
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
 * all of the bits in the <code>BitSet</code> object maintained by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
 * <code>Row</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    public void clearUpdated() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        updated = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        for (int i = 0; i < numCols; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            currentVals[i] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            colsChanged.clear(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    * Sets the column values in this <code>Row</code> object's internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    * array of original values with the values in its internal array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    * current values, sets all the values in this <code>Row</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    * object's internal array of current values to <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    * clears all the bits in this <code>Row</code> object's internal bitset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    * and sets its <code>updated</code> field to <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    * This method is called internally by the <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    * method <code>makeRowOriginal</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    public void moveCurrentToOrig() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        for (int i = 0; i < numCols; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            if (getColUpdated(i) == true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                origVals[i] = currentVals[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                currentVals[i] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                colsChanged.clear(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        updated = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    * Returns the row on which the cursor is positioned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    * @return the <code>Row</code> object on which the <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    *           implementation objects's cursor is positioned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    public BaseRow getCurrentRow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
}