jdk/src/share/classes/com/sun/rowset/internal/BaseRow.java
author lancea
Thu, 26 Jan 2012 19:41:35 -0500
changeset 11683 5e02efd89af6
parent 5506 202f599c92aa
child 21645 1276aab8ff2f
permissions -rw-r--r--
7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl Reviewed-by: forax
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
11683
5e02efd89af6 7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
lancea
parents: 5506
diff changeset
     2
 * Copyright (c) 2003, 2012, 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.*;
11683
5e02efd89af6 7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
lancea
parents: 5506
diff changeset
    30
import java.util.Arrays;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * The abstract base class from which the classes <code>Row</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * The class <code>BaseRow</code> stores
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * a row's original values as an array of <code>Object</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * values, which can be retrieved with the method <code>getOrigRow</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * This class also provides methods for getting and setting individual
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * values in the row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * A row's original values are the values it contained before it was last
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * modified.  For example, when the <code>CachedRowSet</code>method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <code>acceptChanges</code> is called, it will reset a row's original
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * values to be the row's current values.  Then, when the row is modified,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * the values that were previously the current values will become the row's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * original values (the values the row had immediately before it was modified).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * If a row has not been modified, its original values are its initial values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * Subclasses of this class contain more specific details, such as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * the conditions under which an exception is thrown or the bounds for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * index parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
public abstract class BaseRow implements Serializable, Cloneable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * The array containing the original values for this <code>BaseRow</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    protected Object[] origVals;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * Retrieves the values that this row contained immediately
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * prior to its last modification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * @return an array of <code>Object</code> values containing this row's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * original values
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    public Object[] getOrigRow() {
11683
5e02efd89af6 7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
lancea
parents: 5506
diff changeset
    69
        Object[] origRow = this.origVals;
5e02efd89af6 7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
lancea
parents: 5506
diff changeset
    70
        return (origRow == null) ? null: Arrays.copyOf(origRow, origRow.length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * Retrieves the array element at the given index, which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * the original value of column number <i>idx</i> in this row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * @param idx the index of the element to return
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * @return the <code>Object</code> value at the given index into this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *         row's array of original values
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * @throws <code>SQLException</code> if there is an error
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public abstract Object getColumnObject(int idx) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * Sets the element at the given index into this row's array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * original values to the given value.  Implementations of the classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * <code>Row</code> and determine what happens
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * when the cursor is on the insert row and when it is on any other row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * @param idx the index of the element to be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * @param obj the <code>Object</code> to which the element at index
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 *              <code>idx</code> to be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * @throws <code>SQLException</code> if there is an error
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public abstract void setColumnObject(int idx, Object obj) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
}