review request 7097386: Correct error in Predicate javadoc example
Lance Andersen - Oracle
Lance.Andersen at oracle.com
Fri Sep 13 20:40:21 UTC 2013
Hi Everyone,
Looking for a reviewer for this trivial fix to correct the sample example in the Predicate javadoc for the evaluate method()
------------------
!hg
hg diff Predicate.java
diff -r 60d6f60416ca src/share/classes/javax/sql/rowset/Predicate.java
--- a/src/share/classes/javax/sql/rowset/Predicate.java Thu Sep 12 13:20:26 2013 -0400
+++ b/src/share/classes/javax/sql/rowset/Predicate.java Fri Sep 13 16:30:07 2013 -0400
@@ -56,44 +56,42 @@
* <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++) {
+ * int value = 0;
+ * try {
+ * value = (Integer) rs.getObject(idx[i]);
+ * } catch (SQLException ex) {
+ * Logger.getLogger(Range.class.getName()).log(Level.SEVERE, null, ex);
+ * }
*
- * 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.
*
-----------------
Best
Lance
Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
Oracle Java Engineering
1 Network Drive
Burlington, MA 01803
Lance.Andersen at oracle.com
More information about the core-libs-dev
mailing list