0N/A/*
2362N/A * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.sql.rowset;
0N/A
0N/Aimport java.sql.*;
0N/Aimport javax.sql.*;
0N/Aimport javax.naming.*;
0N/Aimport java.io.*;
0N/Aimport java.math.*;
0N/A
0N/A/**
0N/A * The standard interface that all standard implementations of
0N/A * <code>FilteredRowSet</code> must implement. The <code>FilteredRowSetImpl</code> class
0N/A * provides the reference implementation which may be extended if required.
0N/A * Alternatively, a vendor is free to implement its own version
0N/A * by implementing this interface.
0N/A *
0N/A * <h3>1.0 Background</h3>
0N/A *
0N/A * There are occasions when a <code>RowSet</code> object has a need to provide a degree
0N/A * of filtering to its contents. One possible solution is to provide
0N/A * a query language for all standard <code>RowSet</code> implementations; however,
0N/A * this is an impractical approach for lightweight components such as disconnected
0N/A * <code>RowSet</code>
0N/A * objects. The <code>FilteredRowSet</code> interface seeks to address this need
0N/A * without supplying a heavyweight query language along with the processing that
0N/A * such a query language would require.
0N/A * <p>
0N/A * A JDBC <code>FilteredRowSet</code> standard implementation implements the
0N/A * <code>RowSet</code> interfaces and extends the
0N/A * <code>CachedRowSet</code><sup><font size=-2>TM</font></sup> class. The
0N/A * <code>CachedRowSet</code> class provides a set of protected cursor manipulation
0N/A * methods, which a <code>FilteredRowSet</code> implementation can override
0N/A * to supply filtering support.
0N/A *
0N/A * <h3>2.0 Predicate Sharing</h3>
0N/A *
0N/A * If a <code>FilteredRowSet</code> implementation is shared using the
0N/A * inherited <code>createShared</code> method in parent interfaces, the
0N/A * <code>Predicate</code> should be shared without modification by all
0N/A * <code>FilteredRowSet</code> instance clones.
0N/A *
0N/A * <h3>3.0 Usage</h3>
0N/A * <p>
0N/A * By implementing a <code>Predicate</code> (see example in <a href="Predicate.html">Predicate</a>
0N/A * class JavaDoc), a <code>FilteredRowSet</code> could then be used as described
0N/A * below.
0N/A * <P>
0N/A * <code>
0N/A * <pre>
0N/A * FilteredRowSet frs = new FilteredRowSetImpl();
0N/A * frs.populate(rs);
0N/A *
0N/A * Range name = new Range("Alpha", "Bravo", "columnName");
0N/A * frs.setFilter(name);
0N/A *
0N/A * frs.next() // only names from "Alpha" to "Bravo" will be returned
0N/A * </pre>
0N/A * </code>
0N/A * In the example above, we initialize a <code>Range</code> object which
0N/A * implements the <code>Predicate</code> interface. This object expresses
0N/A * the following constraints: All rows outputted or modified from this
0N/A * <code>FilteredRowSet</code> object must fall between the values 'Alpha' and
0N/A * 'Bravo' both values inclusive, in the column 'columnName'. If a filter is
0N/A * applied to a <code>FilteredRowSet</code> object that contains no data that
0N/A * falls within the range of the filter, no rows are returned.
0N/A * <p>
0N/A * This framework allows multiple classes implementing predicates to be
0N/A * used in combination to achieved the required filtering result with
0N/A * out the need for query language processing.
0N/A * <p>
0N/A * <h3>4.0 Updating a <code>FilteredRowSet</code> Object</h3>
0N/A * The predicate set on a <code>FilteredRowSet</code> object
0N/A * applies a criterion on all rows in a
0N/A * <code>RowSet</code> object to manage a subset of rows in a <code>RowSet</code>
0N/A * object. This criterion governs the subset of rows that are visible and also
0N/A * defines which rows can be modified, deleted or inserted.
0N/A * <p>
0N/A * Therefore, the predicate set on a <code>FilteredRowSet</code> object must be
0N/A * considered as bi-directional and the set criterion as the gating mechanism
0N/A * for all views and updates to the <code>FilteredRowSet</code> object. Any attempt
0N/A * to update the <code>FilteredRowSet</code> that violates the criterion will
0N/A * result in a <code>SQLException</code> object being thrown.
0N/A * <p>
0N/A * The <code>FilteredRowSet</code> range criterion can be modified by applying
0N/A * a new <code>Predicate</code> object to the <code>FilteredRowSet</code>
0N/A * instance at any time. This is possible if no additional references to the
0N/A * <code>FilteredRowSet</code> object are detected. A new filter has has an
0N/A * immediate effect on criterion enforcement within the
0N/A * <code>FilteredRowSet</code> object, and all subsequent views and updates will be
0N/A * subject to similar enforcement.
0N/A * <p>
0N/A * <h3>5.0 Behavior of Rows Outside the Filter</h3>
0N/A * Rows that fall outside of the filter set on a <code>FilteredRowSet</code>
0N/A * object cannot be modified until the filter is removed or a
0N/A * new filter is applied.
0N/A * <p>
0N/A * Furthermore, only rows that fall within the bounds of a filter will be
0N/A * synchronized with the data source.
0N/A *
0N/A * @author Jonathan Bruce
0N/A */
0N/A
0N/Apublic interface FilteredRowSet extends WebRowSet {
0N/A
0N/A /**
0N/A * Applies the given <code>Predicate</code> object to this
0N/A * <code>FilteredRowSet</code>
0N/A * object. The filter applies controls both to inbound and outbound views,
0N/A * constraining which rows are visible and which
0N/A * rows can be manipulated.
0N/A * <p>
0N/A * A new <code>Predicate</code> object may be set at any time. This has the
0N/A * effect of changing constraints on the <code>RowSet</code> object's data.
0N/A * In addition, modifying the filter at runtime presents issues whereby
0N/A * multiple components may be operating on one <code>FilteredRowSet</code> object.
0N/A * Application developers must take responsibility for managing multiple handles
0N/A * to <code>FilteredRowSet</code> objects when their underling <code>Predicate</code>
0N/A * objects change.
0N/A *
0N/A * @param p a <code>Predicate</code> object defining the filter for this
0N/A * <code>FilteredRowSet</code> object. Setting a <b>null</b> value
0N/A * will clear the predicate, allowing all rows to become visible.
0N/A *
0N/A * @throws SQLException if an error occurs when setting the
0N/A * <code>Predicate</code> object
0N/A */
0N/A public void setFilter(Predicate p) throws SQLException;
0N/A
0N/A /**
0N/A * Retrieves the active filter for this <code>FilteredRowSet</code> object.
0N/A *
0N/A * @return p the <code>Predicate</code> for this <code>FilteredRowSet</code>
0N/A * object; <code>null</code> if no filter has been set.
0N/A */
0N/A public Predicate getFilter() ;
0N/A}