7097386: Correct error in Predicate javadoc example
authorlancea
Tue, 17 Sep 2013 07:56:56 -0400
changeset 19868 37b6dcade23a
parent 19867 9918d2d14f78
child 19869 ee6d24d1ba22
child 20174 360791181f66
child 20196 a64aabd2fa13
7097386: Correct error in Predicate javadoc example Reviewed-by: alanb, shade
jdk/src/share/classes/javax/sql/rowset/Predicate.java
--- a/jdk/src/share/classes/javax/sql/rowset/Predicate.java	Mon Sep 16 10:28:20 2013 -0700
+++ b/jdk/src/share/classes/javax/sql/rowset/Predicate.java	Tue Sep 17 07:56:56 2013 -0400
@@ -56,44 +56,43 @@
  * <pre>{@code
  *    public class Range implements Predicate {
  *
- *       private Object lo[];
- *       private Object hi[];
- *       private int idx[];
+ *       private int[] lo;
+ *       private int[] hi;
+ *       private int[] idx;
  *
- *       public Range(Object[] lo, Object[] hi, int[] idx) {
+ *       public Range(int[] lo, int[] hi, int[] idx) {
  *          this.lo = lo;
  *          this.hi = hi;
  *          this.idx = idx;
  *       }
  *
  *      public boolean evaluate(RowSet rs) {
- *          CachedRowSet crs = (CachedRowSet)rs;
- *          boolean bool1,bool2;
  *
  *          // Check the present row determine if it lies
  *          // within the filtering criteria.
  *
  *          for (int i = 0; i < idx.length; i++) {
+ *             int value;
+ *             try {
+ *                 value = (Integer) rs.getObject(idx[i]);
+ *             } catch (SQLException ex) {
+ *                 Logger.getLogger(Range.class.getName()).log(Level.SEVERE, null, ex);
+ *                 return false;
+ *             }
  *
- *              if ((rs.getObject(idx[i]) >= lo[i]) &&
- *                  (rs.getObject(idx[i]) >= hi[i]) {
- *                  bool1 = true; // within filter constraints
- *              } else {
- *                  bool2 = true; // outside of filter constraints
- *              }
- *          }
- *
- *          if (bool2) {
- *             return false;
- *          } else {
- *             return true;
- *          }
+ *             if (value < lo[i] && value > hi[i]) {
+ *                 // outside of filter constraints
+ *                 return false;
+ *             }
+ *         }
+ *         // Within filter constraints
+ *        return true;
  *      }
- *  }
+ *   }
  * }</pre>
  * <P>
  * The example above implements a simple range predicate. Note, that
- * implementations should but are not required to provider <code>String</code>
+ * implementations should but are not required to provide <code>String</code>
  * and integer index based constructors to provide for JDBC RowSet Implementation
  * applications that use both column identification conventions.
  *