src/share/classes/javax/sql/rowset/Predicate.java
Print this page
@@ -54,48 +54,46 @@
* <p>
* A sample implementation would look something like this:
* <pre>{@code
* public class Range implements Predicate {
*
- * private Object lo[];
- * private Object hi[];
+ * 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++) {
- *
- * 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
- * }
+ * int value = 0;
+ * try {
+ * value = (Integer) rs.getObject(idx[i]);
+ * } catch (SQLException ex) {
+ * Logger.getLogger(Range.class.getName()).log(Level.SEVERE, null, ex);
* }
*
- * if (bool2) {
+ * if (value < lo[i] && value > hi[i]) {
+ * // outside of filter constraints
* return false;
- * } else {
- * return true;
* }
* }
+ * // 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.
*
* @author Jonathan Bruce, Amit Handa
*