src/share/classes/javax/sql/rowset/FilteredRowSet.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  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  *
  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


  34 /**
  35  * The standard interface that all standard implementations of
  36  * <code>FilteredRowSet</code> must implement. The <code>FilteredRowSetImpl</code> class
  37  * provides the reference implementation which may be extended if required.
  38  * Alternatively, a vendor is free to implement its own version
  39  * by implementing this interface.
  40  *
  41  * <h3>1.0 Background</h3>
  42  *
  43  * There are occasions when a <code>RowSet</code> object has a need to provide a degree
  44  * of filtering to its contents. One possible solution is to provide
  45  * a query language for all standard <code>RowSet</code> implementations; however,
  46  * this is an impractical approach for lightweight components such as disconnected
  47  * <code>RowSet</code>
  48  * objects. The <code>FilteredRowSet</code> interface seeks to address this need
  49  * without supplying a heavyweight query language along with the processing that
  50  * such a query language would require.
  51  * <p>
  52  * A JDBC <code>FilteredRowSet</code> standard implementation implements the
  53  * <code>RowSet</code> interfaces and extends the
  54  * <code>CachedRowSet</code><sup><font size=-2>TM</font></sup> class. The
  55  * <code>CachedRowSet</code> class provides a set of protected cursor manipulation
  56  * methods, which a <code>FilteredRowSet</code> implementation can override
  57  * to supply filtering support.
  58  *
  59  * <h3>2.0 Predicate Sharing</h3>
  60  *
  61  * If a <code>FilteredRowSet</code> implementation is shared using the
  62  * inherited <code>createShared</code> method in parent interfaces, the
  63  * <code>Predicate</code> should be shared without modification by all
  64  * <code>FilteredRowSet</code> instance clones.
  65  *
  66  * <h3>3.0 Usage</h3>
  67  * <p>
  68  * By implementing a <code>Predicate</code> (see example in <a href="Predicate.html">Predicate</a>
  69  * class JavaDoc), a <code>FilteredRowSet</code> could then be used as described
  70  * below.
  71  * <P>
  72  * <code>
  73  * <pre>

  74  *     FilteredRowSet frs = new FilteredRowSetImpl();
  75  *     frs.populate(rs);
  76  *
  77  *     Range name = new Range("Alpha", "Bravo", "columnName");
  78  *     frs.setFilter(name);
  79  *
  80  *     frs.next() // only names from "Alpha" to "Bravo" will be returned

  81  * </pre>
  82  * </code>
  83  * In the example above, we initialize a <code>Range</code> object which
  84  * implements the <code>Predicate</code> interface. This object expresses
  85  * the following constraints: All rows outputted or modified from this
  86  * <code>FilteredRowSet</code> object must fall between the values 'Alpha' and
  87  * 'Bravo' both values inclusive, in the column 'columnName'. If a filter is
  88  * applied to a <code>FilteredRowSet</code> object that contains no data that
  89  * falls within the range of the filter, no rows are returned.
  90  * <p>
  91  * This framework allows multiple classes implementing predicates to be
  92  * used in combination to achieved the required filtering result with
  93  * out the need for query language processing.
  94  * <p>
  95  * <h3>4.0 Updating a <code>FilteredRowSet</code> Object</h3>
  96  * The predicate set on a <code>FilteredRowSet</code> object
  97  * applies a criterion on all rows in a
  98  * <code>RowSet</code> object to manage a subset of rows in a <code>RowSet</code>
  99  * object. This criterion governs the subset of rows that are visible and also
 100  * defines which rows can be modified, deleted or inserted.
 101  * <p>
 102  * Therefore, the predicate set on a <code>FilteredRowSet</code> object must be


   1 /*
   2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  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  *
  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


  34 /**
  35  * The standard interface that all standard implementations of
  36  * <code>FilteredRowSet</code> must implement. The <code>FilteredRowSetImpl</code> class
  37  * provides the reference implementation which may be extended if required.
  38  * Alternatively, a vendor is free to implement its own version
  39  * by implementing this interface.
  40  *
  41  * <h3>1.0 Background</h3>
  42  *
  43  * There are occasions when a <code>RowSet</code> object has a need to provide a degree
  44  * of filtering to its contents. One possible solution is to provide
  45  * a query language for all standard <code>RowSet</code> implementations; however,
  46  * this is an impractical approach for lightweight components such as disconnected
  47  * <code>RowSet</code>
  48  * objects. The <code>FilteredRowSet</code> interface seeks to address this need
  49  * without supplying a heavyweight query language along with the processing that
  50  * such a query language would require.
  51  * <p>
  52  * A JDBC <code>FilteredRowSet</code> standard implementation implements the
  53  * <code>RowSet</code> interfaces and extends the
  54  * <code>CachedRowSet</code>&trade; class. The
  55  * <code>CachedRowSet</code> class provides a set of protected cursor manipulation
  56  * methods, which a <code>FilteredRowSet</code> implementation can override
  57  * to supply filtering support.
  58  *
  59  * <h3>2.0 Predicate Sharing</h3>
  60  *
  61  * If a <code>FilteredRowSet</code> implementation is shared using the
  62  * inherited <code>createShared</code> method in parent interfaces, the
  63  * <code>Predicate</code> should be shared without modification by all
  64  * <code>FilteredRowSet</code> instance clones.
  65  *
  66  * <h3>3.0 Usage</h3>
  67  * <p>
  68  * By implementing a <code>Predicate</code> (see example in <a href="Predicate.html">Predicate</a>
  69  * class JavaDoc), a <code>FilteredRowSet</code> could then be used as described
  70  * below.
  71  * <P>

  72  * <pre>
  73  * {@code 
  74  *     FilteredRowSet frs = new FilteredRowSetImpl();
  75  *     frs.populate(rs);
  76  *
  77  *     Range name = new Range("Alpha", "Bravo", "columnName");
  78  *     frs.setFilter(name);
  79  *
  80  *     frs.next() // only names from "Alpha" to "Bravo" will be returned
  81  * }
  82  * </pre>

  83  * In the example above, we initialize a <code>Range</code> object which
  84  * implements the <code>Predicate</code> interface. This object expresses
  85  * the following constraints: All rows outputted or modified from this
  86  * <code>FilteredRowSet</code> object must fall between the values 'Alpha' and
  87  * 'Bravo' both values inclusive, in the column 'columnName'. If a filter is
  88  * applied to a <code>FilteredRowSet</code> object that contains no data that
  89  * falls within the range of the filter, no rows are returned.
  90  * <p>
  91  * This framework allows multiple classes implementing predicates to be
  92  * used in combination to achieved the required filtering result with
  93  * out the need for query language processing.
  94  * <p>
  95  * <h3>4.0 Updating a <code>FilteredRowSet</code> Object</h3>
  96  * The predicate set on a <code>FilteredRowSet</code> object
  97  * applies a criterion on all rows in a
  98  * <code>RowSet</code> object to manage a subset of rows in a <code>RowSet</code>
  99  * object. This criterion governs the subset of rows that are visible and also
 100  * defines which rows can be modified, deleted or inserted.
 101  * <p>
 102  * Therefore, the predicate set on a <code>FilteredRowSet</code> object must be