/*
* @(#)Joinable.java 1.6 05/11/17
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package javax.sql.rowset;
import java.sql.SQLException;
/**
* <h3>1.0 Background</h3>
* The <code>Joinable</code> interface provides the methods for getting and
* setting a match column, which is the basis for forming the SQL <code>JOIN</code>
* formed by adding <code>RowSet</code> objects to a <code>JoinRowSet</code>
* object.
* <P>
* Any standard <code>RowSet</code> implementation <b>may</b> implement
* the <code>Joinable</code> interface in order to be
* added to a <code>JoinRowSet</code> object. Implementing this interface gives
* a <code>RowSet</code> object the ability to use <code>Joinable</code> methods,
* which set, retrieve, and get information about match columns. An
* application may add a
* <code>RowSet</code> object that has not implemented the <code>Joinable</code>
* interface to a <code>JoinRowSet</code> object, but to do so it must use one
* of the <code>JoinRowSet.addRowSet</code> methods that takes both a
* <code>RowSet</code> object and a match column or an array of <code>RowSet</code>
* objects and an array of match columns.
* <P>
* To get access to the methods in the <code>Joinable</code> interface, a
* <code>RowSet</code> object implements at least one of the
* five standard <code>RowSet</code> interfaces and also implements the
* <code>Joinable</code> interface. In addition, most <code>RowSet</code>
* objects extend the <code>BaseRowSet</code> class. For example:
* <pre>
* class MyRowSetImpl extends BaseRowSet implements CachedRowSet, Joinable {
* :
* :
* }
* </pre>
* <P>
* <h3>2.0 Usage Guidelines</h3>
* <P>
* The methods in the <code>Joinable</code> interface allow a <code>RowSet</code> object
* to set a match column, retrieve a match column, or unset a match column, which is
* the column upon which an SQL <code>JOIN</code> can be based.
* An instance of a class that implements these methods can be added to a
* <code>JoinRowSet</code> object to allow an SQL <code>JOIN</code> relationship to
* be established.
* <p>
* <pre>
* CachedRowSet crs = new MyRowSetImpl();
* crs.populate((ResultSet)rs);
* (Joinable)crs.setMatchColumnIndex(1);
*
* JoinRowSet jrs = new JoinRowSetImpl();
* jrs.addRowSet(crs);
* </pre>
* In the previous example, <i>crs</i> is a <code>CachedRowSet</code> object that
* has emplemented the <code>Joinable</code> interface. In the following example,
* <i>crs2</i> has not, so it must supply the match column as an argument to the
* <code>addRowSet</code> method. This example assumes that column 1 is the match
* column.
* <PRE>
* CachedRowSet crs2 = new MyRowSetImpl();
* crs2.populate((ResultSet)rs);
*
* JoinRowSet jrs2 = new JoinRowSetImpl();
* jrs2.addRowSet(crs2, 1);
* </PRE>
* <p>
* The <code>JoinRowSet</code> interface makes it possible to get data from one or
* more <code>RowSet</code> objects consolidated into one table without having to incur
* the expense of creating a connection to a database. It is therefore ideally suited
* for use by disconnected <code>RowSet</code> objects. Nevertheless, any
* <code>RowSet</code> object <b>may</b> implement this interface
* regardless of whether it is connected or disconnected. Note that a
* <code>JdbcRowSet</code> object, being always connected to its data source, can
* become part of an SQL <code>JOIN</code> directly without having to become part
* of a <code>JoinRowSet</code> object.
* <P>
* <h3>3.0 Managing Multiple Match Columns</h3>
* The index array passed into the <code>setMatchColumn</code> methods indicates
* how many match columns are being set (the length of the array) in addition to
* which columns will be used for the match. For example:
* <pre>
* int[] i = {1, 2, 4, 7}; // indicates four match columns, with column
* // indexes 1, 2, 4, 7 participating in the JOIN.
* Joinable.setMatchColumn(i);
* </pre>
* Subsequent match columns may be added as follows to a different <code>Joinable</code>
* object (a <code>RowSet</code> object that has implemented the <code>Joinable</code>
* interface).
* <pre>
* int[] w = {3, 2, 5, 3};
* Joinable2.setMatchColumn(w);
* </pre>
* When an application adds two or more <code>RowSet</code> objects to a
* <code>JoinRowSet</code> object, the order of the indexes in the array is
=1= |