Path: blob/master/src/java.sql.rowset/share/classes/com/sun/rowset/internal/BaseRow.java
40948 views
/*1* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.rowset.internal;2627import java.sql.*;28import java.io.*;29import java.util.Arrays;3031/**32* The abstract base class from which the classes <code>Row</code>33* The class <code>BaseRow</code> stores34* a row's original values as an array of <code>Object</code>35* values, which can be retrieved with the method <code>getOrigRow</code>.36* This class also provides methods for getting and setting individual37* values in the row.38* <P>39* A row's original values are the values it contained before it was last40* modified. For example, when the <code>CachedRowSet</code>method41* <code>acceptChanges</code> is called, it will reset a row's original42* values to be the row's current values. Then, when the row is modified,43* the values that were previously the current values will become the row's44* original values (the values the row had immediately before it was modified).45* If a row has not been modified, its original values are its initial values.46* <P>47* Subclasses of this class contain more specific details, such as48* the conditions under which an exception is thrown or the bounds for49* index parameters.50*/51public abstract class BaseRow implements Serializable, Cloneable {5253/**54* Specify the serialVersionUID55*/56private static final long serialVersionUID = 4152013523511412238L;5758/**59* The array containing the original values for this <code>BaseRow</code>60* object.61* @serial62*/63protected Object[] origVals;6465/**66* Retrieves the values that this row contained immediately67* prior to its last modification.68*69* @return an array of <code>Object</code> values containing this row's70* original values71*/72public Object[] getOrigRow() {73Object[] origRow = this.origVals;74return (origRow == null) ? null: Arrays.copyOf(origRow, origRow.length);75}7677/**78* Retrieves the array element at the given index, which is79* the original value of column number <i>idx</i> in this row.80*81* @param idx the index of the element to return82* @return the <code>Object</code> value at the given index into this83* row's array of original values84* @throws SQLException if there is an error85*/86public abstract Object getColumnObject(int idx) throws SQLException;8788/**89* Sets the element at the given index into this row's array of90* original values to the given value. Implementations of the classes91* <code>Row</code> and determine what happens92* when the cursor is on the insert row and when it is on any other row.93*94* @param idx the index of the element to be set95* @param obj the <code>Object</code> to which the element at index96* <code>idx</code> to be set97* @throws SQLException if there is an error98*/99public abstract void setColumnObject(int idx, Object obj) throws SQLException;100}101102103