jdk/src/share/classes/javax/sql/rowset/Predicate.java
changeset 18156 edb590d448c5
parent 5506 202f599c92aa
child 18564 f9db68ff2cbb
equal deleted inserted replaced
18155:889970e5b728 18156:edb590d448c5
    51  * defined and deployed with both the reference and vendor implementations
    51  * defined and deployed with both the reference and vendor implementations
    52  * of the <code>FilteredRowSet</code> interface, this allows for a flexible
    52  * of the <code>FilteredRowSet</code> interface, this allows for a flexible
    53  * and application motivated implementations of <code>Predicate</code> to emerge.
    53  * and application motivated implementations of <code>Predicate</code> to emerge.
    54  * <p>
    54  * <p>
    55  * A sample implementation would look something like this:
    55  * A sample implementation would look something like this:
    56  * <pre>
    56  * <pre>{@code
    57  * <code>
       
    58  *    public class Range implements Predicate {
    57  *    public class Range implements Predicate {
    59  *
    58  *
    60  *       private Object lo[];
    59  *       private Object lo[];
    61  *       private Object hi[];
    60  *       private Object hi[];
    62  *       private int idx[];
    61  *       private int idx[];
    77  *          for (int i = 0; i < idx.length; i++) {
    76  *          for (int i = 0; i < idx.length; i++) {
    78  *
    77  *
    79  *              if ((rs.getObject(idx[i]) >= lo[i]) &&
    78  *              if ((rs.getObject(idx[i]) >= lo[i]) &&
    80  *                  (rs.getObject(idx[i]) >= hi[i]) {
    79  *                  (rs.getObject(idx[i]) >= hi[i]) {
    81  *                  bool1 = true; // within filter constraints
    80  *                  bool1 = true; // within filter constraints
       
    81  *              } else {
       
    82  *                  bool2 = true; // outside of filter constraints
       
    83  *              }
       
    84  *          }
       
    85  *
       
    86  *          if (bool2) {
       
    87  *             return false;
    82  *          } else {
    88  *          } else {
    83  *            bool2 = true; // outside of filter constraints
    89  *             return true;
    84  *          }
    90  *          }
    85  *      }
    91  *      }
    86  *
       
    87  *      if (bool2) {
       
    88  *         return false;
       
    89  *      } else {
       
    90  *         return true;
       
    91  *      }
       
    92  *  }
    92  *  }
    93  * </code>
    93  * }</pre>
    94  * </pre>
       
    95  * <P>
    94  * <P>
    96  * The example above implements a simple range predicate. Note, that
    95  * The example above implements a simple range predicate. Note, that
    97  * implementations should but are not required to provider <code>String</code>
    96  * implementations should but are not required to provider <code>String</code>
    98  * and integer index based constructors to provide for JDBC RowSet Implementation
    97  * and integer index based constructors to provide for JDBC RowSet Implementation
    99  * applications that use both column identification conventions.
    98  * applications that use both column identification conventions.