author | lancea |
Thu, 26 Jan 2012 19:41:35 -0500 | |
changeset 11683 | 5e02efd89af6 |
parent 5506 | 202f599c92aa |
child 21645 | 1276aab8ff2f |
permissions | -rw-r--r-- |
2 | 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 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package com.sun.rowset.internal; |
|
27 |
||
28 |
import java.sql.*; |
|
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 | 31 |
|
32 |
/** |
|
33 |
* The abstract base class from which the classes <code>Row</code> |
|
34 |
* The class <code>BaseRow</code> stores |
|
35 |
* a row's original values as an array of <code>Object</code> |
|
36 |
* values, which can be retrieved with the method <code>getOrigRow</code>. |
|
37 |
* This class also provides methods for getting and setting individual |
|
38 |
* values in the row. |
|
39 |
* <P> |
|
40 |
* A row's original values are the values it contained before it was last |
|
41 |
* modified. For example, when the <code>CachedRowSet</code>method |
|
42 |
* <code>acceptChanges</code> is called, it will reset a row's original |
|
43 |
* values to be the row's current values. Then, when the row is modified, |
|
44 |
* the values that were previously the current values will become the row's |
|
45 |
* original values (the values the row had immediately before it was modified). |
|
46 |
* If a row has not been modified, its original values are its initial values. |
|
47 |
* <P> |
|
48 |
* Subclasses of this class contain more specific details, such as |
|
49 |
* the conditions under which an exception is thrown or the bounds for |
|
50 |
* index parameters. |
|
51 |
*/ |
|
52 |
public abstract class BaseRow implements Serializable, Cloneable { |
|
53 |
||
54 |
/** |
|
55 |
* The array containing the original values for this <code>BaseRow</code> |
|
56 |
* object. |
|
57 |
* @serial |
|
58 |
*/ |
|
59 |
protected Object[] origVals; |
|
60 |
||
61 |
/** |
|
62 |
* Retrieves the values that this row contained immediately |
|
63 |
* prior to its last modification. |
|
64 |
* |
|
65 |
* @return an array of <code>Object</code> values containing this row's |
|
66 |
* original values |
|
67 |
*/ |
|
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 | 71 |
} |
72 |
||
73 |
/** |
|
74 |
* Retrieves the array element at the given index, which is |
|
75 |
* the original value of column number <i>idx</i> in this row. |
|
76 |
* |
|
77 |
* @param idx the index of the element to return |
|
78 |
* @return the <code>Object</code> value at the given index into this |
|
79 |
* row's array of original values |
|
80 |
* @throws <code>SQLException</code> if there is an error |
|
81 |
*/ |
|
82 |
public abstract Object getColumnObject(int idx) throws SQLException; |
|
83 |
||
84 |
/** |
|
85 |
* Sets the element at the given index into this row's array of |
|
86 |
* original values to the given value. Implementations of the classes |
|
87 |
* <code>Row</code> and determine what happens |
|
88 |
* when the cursor is on the insert row and when it is on any other row. |
|
89 |
* |
|
90 |
* @param idx the index of the element to be set |
|
91 |
* @param obj the <code>Object</code> to which the element at index |
|
92 |
* <code>idx</code> to be set |
|
93 |
* @throws <code>SQLException</code> if there is an error |
|
94 |
*/ |
|
95 |
public abstract void setColumnObject(int idx, Object obj) throws SQLException; |
|
96 |
} |