Index: src/main/java/javax/servlet/jsp/jstl/core/IteratedExpression.java =================================================================== --- src/main/java/javax/servlet/jsp/jstl/core/IteratedExpression.java (revision 960047) +++ src/main/java/javax/servlet/jsp/jstl/core/IteratedExpression.java (working copy) @@ -30,20 +30,38 @@ import javax.el.ELContext; import javax.el.ValueExpression; +/** + * Helper class for accessing members of a deferred expression result by index. + */ public final class IteratedExpression { protected final ValueExpression orig; protected final String delims; + private ELContext lastContext; + private Object originalListObject = null; private Iterator currentListObject = null; private int currentIndex=0; private enum TypesEnum {Undefined, ACollection, AnIterator, AnEnumeration, AMap, AString}; private TypesEnum type = TypesEnum.Undefined; - - public IteratedExpression(ValueExpression valueExpression, String stringTokenSeparator) { - orig = valueExpression; - delims = stringTokenSeparator; + + /** + * Constructor specifying the expression to access. + * If the expression evaluates to a String, then it will be split using the specified delimiters. + * @param orig the original expression to be accessed + * @param delims delimiters to be used to split a String result + */ + public IteratedExpression(ValueExpression orig, String delims) { + this.orig = orig; + this.delims = delims; } - + + /** + * Iterates the original expression and returns the value at the index. + * + * @param context against which the expression should be evaluated + * @param i the index of the value to return + * @return the value at the index + */ public Object getItem(ELContext context, int i) { if (originalListObject == null) { originalListObject = orig.getValue(context); @@ -77,7 +95,12 @@ } return currentObject; } - + + /** + * Returns the original expression. + * + * @return the original expression + */ public ValueExpression getValueExpression() { return orig; } Index: src/main/java/javax/servlet/jsp/jstl/core/IndexedValueExpression.java =================================================================== --- src/main/java/javax/servlet/jsp/jstl/core/IndexedValueExpression.java (revision 960047) +++ src/main/java/javax/servlet/jsp/jstl/core/IndexedValueExpression.java (working copy) @@ -24,25 +24,41 @@ 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() { Index: src/main/java/javax/servlet/jsp/jstl/core/IteratedValueExpression.java =================================================================== --- src/main/java/javax/servlet/jsp/jstl/core/IteratedValueExpression.java (revision 960047) +++ src/main/java/javax/servlet/jsp/jstl/core/IteratedValueExpression.java (working copy) @@ -22,26 +22,29 @@ 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 int i; + // todo: IteratedExpression is not serializable - should this be ignored? protected final IteratedExpression iteratedExpression; - protected final int i; - - public IteratedValueExpression(IteratedExpression _iteratedExpression, int _i) { - iteratedExpression = _iteratedExpression; - i = _i; + + 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() {