tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r960262 - in /tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core: IndexedValueExpression.java IteratedValueExpression.java
Date Sat, 03 Jul 2010 19:40:07 GMT
Author: bayard
Date: Sat Jul  3 19:40:07 2010
New Revision: 960262

URL: http://svn.apache.org/viewvc?rev=960262&view=rev
Log:
Fixing equals method to be consistent with hashCode, and making the serialVersionUID be 1L
per the spec javadoc. Per Jeremy Boynes' #49542 report

Modified:
    tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core/IndexedValueExpression.java
    tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core/IteratedValueExpression.java

Modified: tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core/IndexedValueExpression.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core/IndexedValueExpression.java?rev=960262&r1=960261&r2=960262&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core/IndexedValueExpression.java
(original)
+++ tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core/IndexedValueExpression.java
Sat Jul  3 19:40:07 2010
@@ -24,25 +24,41 @@ import java.io.Serializable;
 import javax.el.ELContext;
 import javax.el.ValueExpression;
 
+/**
+ * ValueExpression that refers to a specific member of an indexed variable.
+ * This allows individual members of an indexed collection to be used as lvalues.
+ */
 public final class IndexedValueExpression extends ValueExpression implements Serializable
{
+    // serialVersionUID value defined by specification JavaDoc
+    private static final long serialVersionUID = 1L;
 
-    private static final long serialVersionUID = -7300711701036452952L;
+    /**
+     * The index variable.
+     */
     protected final Integer i;
+
+    /**
+     * The indexed variable.
+     */
     protected final ValueExpression orig;
-    
-    public IndexedValueExpression(ValueExpression valueExpression, int _i) {
+
+    /**
+     * Constructor specifying indexed variable and index.
+     *
+     * @param valueExpression that evaluates to the indexed variable
+     * @param i index specifying the member
+     */
+    public IndexedValueExpression(ValueExpression valueExpression, int i) {
         orig = valueExpression;
-        i=_i;
+        this.i = i;
     }
-    
-    public boolean equals(Object arg0) {
-        boolean rc=false;
-        if (arg0!=null) {
-            if (arg0.equals(orig)) {
-                rc = true;
-            }
-        }
-        return rc;
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        IndexedValueExpression that = (IndexedValueExpression) o;
+        return i.equals(that.i) && orig.equals(that.orig);
     }
 
     public Class getExpectedType() {

Modified: tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core/IteratedValueExpression.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core/IteratedValueExpression.java?rev=960262&r1=960261&r2=960262&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core/IteratedValueExpression.java
(original)
+++ tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core/IteratedValueExpression.java
Sat Jul  3 19:40:07 2010
@@ -22,26 +22,29 @@ package javax.servlet.jsp.jstl.core;
 import javax.el.ELContext;
 import javax.el.ValueExpression;
 
+/**
+ * ValueExpression that refers to a specific member of an indexed variable backed by an IteratedExpression.
+ * This allows individual members of an indexed collection to be used as lvalues.
+ */
 public final class IteratedValueExpression extends ValueExpression {
+    // serialVersionUID value defined by specification JavaDoc
+    private static final long serialVersionUID = 1L;
 
-    private static final long serialVersionUID = 2771035360633553883L;
-    //IteratedExpression is not serializable
-    protected final IteratedExpression iteratedExpression;
     protected final int i;
-    
-    public IteratedValueExpression(IteratedExpression _iteratedExpression, int _i) {
-        iteratedExpression = _iteratedExpression;
-        i = _i;
+    // TODO: IteratedExpression is not serializable - should this be ignored?
+    protected final IteratedExpression iteratedExpression;
+
+    public IteratedValueExpression(IteratedExpression _iteratedExpr, int i) {
+        iteratedExpression = _iteratedExpr;
+        this.i = i;
     }
     
-    public boolean equals(Object arg0) {
-        if (arg0==null) {
-            return false;
-        }
-        if (iteratedExpression.getValueExpression().equals(arg0)) {
-            return true;
-        }
-        return false;
+    public boolean equals(Object obj) {
+        if (this == obj) return true;
+        if (obj == null || getClass() != obj.getClass()) return false;
+
+        IteratedValueExpression that = (IteratedValueExpression) obj;
+        return i == that.i && iteratedExpression.equals(that.iteratedExpression);
     }
 
     public Class getExpectedType() {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message