Java Doc for FilteredRowSet.java in  » 6.0-JDK-Core » sql » javax » sql » rowset » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » sql » javax.sql.rowset 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.sql.rowset.FilteredRowSet

FilteredRowSet
public interface FilteredRowSet extends WebRowSet(Code)
The standard interface that all standard implementations of FilteredRowSet must implement. The FilteredRowSetImpl class provides the reference implementation which may be extended if required. Alternatively, a vendor is free to implement its own version by implementing this interface.

1.0 Background

There are occasions when a RowSet object has a need to provide a degree of filtering to its contents. One possible solution is to provide a query language for all standard RowSet implementations; however, this is an impractical approach for lightweight components such as disconnected RowSet objects. The FilteredRowSet interface seeks to address this need without supplying a heavyweight query language along with the processing that such a query language would require.

A JDBC FilteredRowSet standard implementation implements the RowSet interfaces and extends the CachedRowSetTM class. The CachedRowSet class provides a set of protected cursor manipulation methods, which a FilteredRowSet implementation can override to supply filtering support.

2.0 Predicate Sharing

If a FilteredRowSet implementation is shared using the inherited createShared method in parent interfaces, the Predicate should be shared without modification by all FilteredRowSet instance clones.

3.0 Usage

By implementing a Predicate (see example in Predicate class JavaDoc), a FilteredRowSet could then be used as described below.

 FilteredRowSet frs = new FilteredRowSetImpl();
 frs.populate(rs);
 Range name = new Range("Alpha", "Bravo", "columnName");
 frs.setFilter(name);
 frs.next() // only names from "Alpha" to "Bravo" will be returned
 
In the example above, we initialize a Range object which implements the Predicate interface. This object expresses the following constraints: All rows outputted or modified from this FilteredRowSet object must fall between the values 'Alpha' and 'Bravo' both values inclusive, in the column 'columnName'. If a filter is applied to a FilteredRowSet object that contains no data that falls within the range of the filter, no rows are returned.

This framework allows multiple classes implementing predicates to be used in combination to achieved the required filtering result with out the need for query language processing.

4.0 Updating a FilteredRowSet Object

The predicate set on a FilteredRowSet object applies a criterion on all rows in a RowSet object to manage a subset of rows in a RowSet object. This criterion governs the subset of rows that are visible and also defines which rows can be modified, deleted or inserted.

Therefore, the predicate set on a FilteredRowSet object must be considered as bi-directional and the set criterion as the gating mechanism for all views and updates to the FilteredRowSet object. Any attempt to update the FilteredRowSet that violates the criterion will result in a SQLException object being thrown.

The FilteredRowSet range criterion can be modified by applying a new Predicate object to the FilteredRowSet instance at any time. This is possible if no additional references to the FilteredRowSet object are detected. A new filter has has an immediate effect on criterion enforcement within the FilteredRowSet object, and all subsequent views and updates will be subject to similar enforcement.

5.0 Behavior of Rows Outside the Filter

Rows that fall outside of the filter set on a FilteredRowSet object cannot be modified until the filter is removed or a new filter is applied.

Furthermore, only rows that fall within the bounds of a filter will be synchronized with the data source.
author:
   Jonathan Bruce





Method Summary
public  PredicategetFilter()
     Retrieves the active filter for this FilteredRowSet object.
public  voidsetFilter(Predicate p)
     Applies the given Predicate object to this FilteredRowSet object.



Method Detail
getFilter
public Predicate getFilter()(Code)
Retrieves the active filter for this FilteredRowSet object. p the Predicate for this FilteredRowSetobject; null if no filter has been set.



setFilter
public void setFilter(Predicate p) throws SQLException(Code)
Applies the given Predicate object to this FilteredRowSet object. The filter applies controls both to inbound and outbound views, constraining which rows are visible and which rows can be manipulated.

A new Predicate object may be set at any time. This has the effect of changing constraints on the RowSet object's data. In addition, modifying the filter at runtime presents issues whereby multiple components may be operating on one FilteredRowSet object. Application developers must take responsibility for managing multiple handles to FilteredRowSet objects when their underling Predicate objects change.
Parameters:
  p - a Predicate object defining the filter for thisFilteredRowSet object. Setting a null value will clear the predicate, allowing all rows to become visible.
throws:
  SQLException - if an error occurs when setting the Predicate object




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.