src/java.sql.rowset/share/classes/com/sun/rowset/internal/Row.java
author kvn
Fri, 30 Mar 2018 07:47:20 -0700
changeset 49654 16f53c9c7493
parent 47216 71c04702a3d5
permissions -rw-r--r--
8200461: MeetIncompatibleInterfaceArrays test fails with -Xcomp Summary: Add requires to run test only in Xmixed mode. Reviewed-by: simonis
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
11129
f9ad1aadf3fa 7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents: 5506
diff changeset
     2
 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
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.lang.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * A class that keeps track of a row's values. A <code>Row</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * maintains an array of current column values and an array of original
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * column values, and it provides methods for getting and setting the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * value of a column.  It also keeps track of which columns have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * changed and whether the change was a delete, insert, or update.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Note that column numbers for rowsets start at <code>1</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * whereas the first element of an array or bitset is <code>0</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * The argument for the method <code>getColumnUpdated</code> refers to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * the column number in the rowset (the first column is <code>1</code>);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * the argument for <code>setColumnUpdated</code> refers to the index
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * into the rowset's internal bitset (the first bit is <code>0</code>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
public class Row extends BaseRow implements Serializable, Cloneable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
11129
f9ad1aadf3fa 7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents: 5506
diff changeset
    49
static final long serialVersionUID = 5047859032611314762L;
f9ad1aadf3fa 7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents: 5506
diff changeset
    50
2
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];
11129
f9ad1aadf3fa 7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents: 5506
diff changeset
   118
        System.arraycopy(vals, 0, origVals, 0, numCols);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        currentVals = new Object[numCols];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        colsChanged = new BitSet(numCols);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        this.numCols = numCols;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * This method is called internally by the <code>CachedRowSet.populate</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 * methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * @param idx the number of the column in this <code>Row</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 *            that is to be set; the index of the first column is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 *            <code>1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 * @param val the new value to be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    public void initColumnObject(int idx, Object val) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        origVals[idx - 1] = val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
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
 * This method is called internally by the <code>CachedRowSet.updateXXX</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 * methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 * @param idx the number of the column in this <code>Row</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 *            that is to be set; the index of the first column is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 *            <code>1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 * @param val the new value to be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    public void setColumnObject(int idx, Object val) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            currentVals[idx - 1] = val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            setColUpdated(idx - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 * Retrieves the column value stored in the designated column of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 * <code>Row</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 * @param columnIndex the index of the column value to be retrieved;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 *                    the index of the first column is <code>1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 * @return an <code>Object</code> in the Java programming language that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 *         represents the value stored in the designated column
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 * @throws SQLException if there is a database access error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    public Object getColumnObject(int columnIndex) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        if (getColUpdated(columnIndex - 1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            return(currentVals[columnIndex - 1]); // maps to array!!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            return(origVals[columnIndex - 1]); // maps to array!!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 * Indicates whether the designated column of this <code>Row</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
 * has been changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 * @param idx the index into the <code>BitSet</code> object maintained by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
 *            this <code>Row</code> object to keep track of which column
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
 *            values have been modified; the index of the first bit is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
 *            <code>0</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
 * @return <code>true</code> if the designated column value has been changed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
 *         <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    public boolean getColUpdated(int idx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        return colsChanged.get(idx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
 * Sets this <code>Row</code> object's <code>deleted</code> field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 * to <code>true</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 * @see #getDeleted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public void setDeleted() { // %%% was public
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        deleted = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
 * Retrieves the value of this <code>Row</code> object's <code>deleted</code> field,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
 * which will be <code>true</code> if one or more of its columns has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
 * deleted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
 * @return <code>true</code> if a column value has been deleted; <code>false</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
 *         otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
 * @see #setDeleted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    public boolean getDeleted() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        return(deleted);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
 * Sets the <code>deleted</code> field for this <code>Row</code> object to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
 * <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    public void clearDeleted() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        deleted = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
 * Sets the value of this <code>Row</code> object's <code>inserted</code> field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
 * to <code>true</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
 * @see #getInserted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    public void setInserted() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        inserted = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
 * Retrieves the value of this <code>Row</code> object's <code>inserted</code> field,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
 * which will be <code>true</code> if this row has been inserted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
 * @return <code>true</code> if this row has been inserted; <code>false</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
 *         otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
 * @see #setInserted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    public boolean getInserted() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        return(inserted);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
 * Sets the <code>inserted</code> field for this <code>Row</code> object to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
 * <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    public void clearInserted() { // %%% was public
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        inserted = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
 * Retrieves the value of this <code>Row</code> object's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
 * <code>updated</code> field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
 * @return <code>true</code> if this <code>Row</code> object has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
 *         updated; <code>false</code> if it has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
 * @see #setUpdated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    public boolean getUpdated() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        return(updated);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
 * Sets the <code>updated</code> field for this <code>Row</code> object to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
 * <code>true</code> if one or more of its column values has been changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
 * @see #getUpdated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    public void setUpdated() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        // only mark something as updated if one or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        // more of the columns has been changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        for (int i = 0; i < numCols; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            if (getColUpdated(i) == true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                updated = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        }
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
 * Sets the bit at the given index into this <code>Row</code> object's internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
 * <code>BitSet</code> object, indicating that the corresponding column value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
 * (column <code>idx</code> + 1) has been changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
 * @param idx the index into the <code>BitSet</code> object maintained by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
 *            this <code>Row</code> object; the first bit is at index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
 *            <code>0</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    private void setColUpdated(int idx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        colsChanged.set(idx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
 * Sets the <code>updated</code> field for this <code>Row</code> object to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
 * <code>false</code>, sets all the column values in this <code>Row</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
 * object's internal array of current values to <code>null</code>, and clears
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
 * all of the bits in the <code>BitSet</code> object maintained by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
 * <code>Row</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    public void clearUpdated() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        updated = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        for (int i = 0; i < numCols; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            currentVals[i] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            colsChanged.clear(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    * Sets the column values in this <code>Row</code> object's internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    * array of original values with the values in its internal array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    * current values, sets all the values in this <code>Row</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    * object's internal array of current values to <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    * clears all the bits in this <code>Row</code> object's internal bitset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    * and sets its <code>updated</code> field to <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    * This method is called internally by the <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    * method <code>makeRowOriginal</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    public void moveCurrentToOrig() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        for (int i = 0; i < numCols; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            if (getColUpdated(i) == true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                origVals[i] = currentVals[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                currentVals[i] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                colsChanged.clear(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        updated = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    * Returns the row on which the cursor is positioned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    * @return the <code>Row</code> object on which the <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    *           implementation objects's cursor is positioned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    public BaseRow getCurrentRow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
}