Source Code Cross Referenced for Predicate.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 Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package javax.sql.rowset;
027
028        import javax.sql.*;
029        import java.sql.*;
030
031        /**
032         * The standard interface that provides the framework for all 
033         * <code>FilteredRowSet</code> objects to describe their filters.
034         * <p>
035         * <h3>1.0 Background</h3>
036         * The <code>Predicate</code> interface is a standard interface that
037         * applications can implement to define the filter they wish to apply to a 
038         * a <code>FilteredRowSet</code> object. A <code>FilteredRowSet</code>
039         * object consumes implementations of this interface and enforces the
040         * constraints defined in the implementation of the method <code>evaluate</code>.
041         * A <code>FilteredRowSet</code> object enforces the filter constraints in a 
042         * bi-directional manner: It outputs only rows that are within
043         * the constraints of the filter; and conversely, it inserts, modifies, or updates
044         * only rows that are within the constraints of the filter.
045         * 
046         * <h3>2.0 Implementation Guidelines</h3>
047         * In order to supply a predicate for the <code>FilteredRowSet</code>.
048         * this interface must be implemented.  At this time, the JDBC RowSet 
049         * Implementations (JSR-114) does not specify any standard filters definitions. 
050         * By specifying a standard means and mechanism for a range of filters to be
051         * defined and deployed with both the reference and vendor implementations 
052         * of the <code>FilteredRowSet</code> interface, this allows for a flexible
053         * and application motivated implementations of <code>Predicate</code> to emerge.
054         * <p>
055         * A sample implementation would look something like this:
056         * <pre>
057         * <code>
058         *    public class Range implements Predicate {
059         *
060         *       private Object lo[];
061         *       private Object hi[];
062         *       private int idx[];
063         *
064         *       public Range(Object[] lo, Object[] hi, int[] idx) {
065         *          this.lo = lo;
066         *          this.hi = hi;
067         *          this.idx = idx;
068         *       }
069         *
070         *      public boolean evaluate(RowSet rs) {
071         *          CachedRowSet crs = (CachedRowSet)rs;
072         *          boolean bool1,bool2;           
073         *       
074         *          // Check the present row determine if it lies
075         *          // within the filtering criteria. 
076         *      
077         *          for (int i = 0; i < idx.length; i++) {
078         *        
079         *	        if ((rs.getObject(idx[i]) >= lo[i]) && 
080         *                  (rs.getObject(idx[i]) >= hi[i]) { 
081         *	            bool1 = true; // within filter constraints
082         *          } else {
083         *            bool2 = true; // outside of filter constraints             
084         *          } 
085         *      }
086         *      
087         *      if (bool2) {
088         *         return false;
089         *      } else {
090         *         return true;
091         *      }
092         *  }          
093         * </code>
094         * </pre>
095         * <P>
096         * The example above implements a simple range predicate. Note, that 
097         * implementations should but are not required to provider <code>String</code>
098         * and integer index based constructors to provide for JDBC RowSet Implementation
099         * applications that use both column identification conventions.
100         *
101         * @author Jonathan Bruce, Amit Handa
102         *
103         */
104
105        // <h3>3.0 FilteredRowSet Internals</h3>
106        // internalNext, Frist, Last. Discuss guidelines on how to approach this
107        // and cite examples in reference implementations.
108        public interface Predicate {
109            /**
110             * This method is typically called a <code>FilteredRowSet</code> object
111             * internal methods (not public) that control the <code>RowSet</code> object's
112             * cursor moving  from row to the next. In addition, if this internal method 
113             * moves the cursor onto a row that has been deleted, the internal method will 
114             * continue to ove the cursor until a valid row is found. 
115             *
116             * @return <code>true</code> if there are more rows in the filter; 
117             *     <code>false</code> otherwise
118             */
119            public boolean evaluate(RowSet rs);
120
121            /**
122             * This method is called by a <code>FilteredRowSet</code> object
123             * to check whether the value lies between the filtering criterion (or criteria
124             * if multiple constraints exist) set using the <code>setFilter()</code> method.
125             * <P>
126             * The <code>FilteredRowSet</code> object will use this method internally
127             * while inserting new rows to a <code>FilteredRowSet</code> instance.
128             *
129             * @param value An <code>Object</code> value which needs to be checked,
130             *        whether it can be part of this <code>FilterRowSet</code> object.
131             * @param column a <code>int</code> object that must match the
132             *        SQL index of a column in this <code>RowSet</code> object. This must 
133             *        have been passed to <code>Predicate</code> as one of the columns 
134             *        for filtering while initializing a <code>Predicate</code>
135             * @return <code>true</code> ifrow value lies within the filter; 
136             *     <code>false</code> otherwise
137             * @throws SQLException if the column is not part of filtering criteria 
138             */
139            public boolean evaluate(Object value, int column)
140                    throws SQLException;
141
142            /**
143             * This method is called by the <code>FilteredRowSet</code> object
144             * to check whether the value lies between the filtering criteria set 
145             * using the setFilter method.
146             * <P>
147             * The <code>FilteredRowSet</code> object will use this method internally
148             * while inserting new rows to a <code>FilteredRowSet</code> instance.
149             *
150             * @param value An <code>Object</code> value which needs to be checked,
151             * whether it can be part of this <code>FilterRowSet</code>.
152             *
153             * @param columnName a <code>String</code> object that must match the
154             *        SQL name of a column in this <code>RowSet</code>, ignoring case. This must 
155             *        have been passed to <code>Predicate</code> as one of the columns for filtering
156             *        while initializing a <code>Predicate</code>
157             *
158             * @return <code>true</code> if value lies within the filter; <code>false</code> otherwise
159             * 
160             * @throws SQLException if the column is not part of filtering criteria 
161             */
162            public boolean evaluate(Object value, String columnName)
163                    throws SQLException;
164
165        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.