View | Details | Raw Unified | Return to bug 49542
Collapse All | Expand All

(-)src/main/java/javax/servlet/jsp/jstl/core/IteratedExpression.java (-6 / +27 lines)
Lines 30-35 Link Here
30
import javax.el.ELContext;
30
import javax.el.ELContext;
31
import javax.el.ValueExpression;
31
import javax.el.ValueExpression;
32
32
33
/**
34
 * Helper class for accessing members of a deferred expression result by index.
35
 */
33
public final class IteratedExpression {
36
public final class IteratedExpression {
34
    protected final ValueExpression orig;
37
    protected final ValueExpression orig;
35
    protected final String delims;
38
    protected final String delims;
Lines 38-49 Link Here
38
    private int currentIndex=0;
41
    private int currentIndex=0;
39
    private enum TypesEnum {Undefined, ACollection, AnIterator, AnEnumeration, AMap, AString};
42
    private enum TypesEnum {Undefined, ACollection, AnIterator, AnEnumeration, AMap, AString};
40
    private TypesEnum type = TypesEnum.Undefined;
43
    private TypesEnum type = TypesEnum.Undefined;
41
    
44
42
    public IteratedExpression(ValueExpression valueExpression, String stringTokenSeparator) {
45
    /**
43
        orig = valueExpression;
46
     * Constructor specifying the expression to access.
44
        delims = stringTokenSeparator;
47
     * If the expression evaluates to a String, then it will be split using the specified delimiters.
48
     * @param orig the original expression to be accessed
49
     * @param delims delimiters to be used to split a String result
50
     */
51
    public IteratedExpression(ValueExpression orig, String delims) {
52
        this.orig = orig;
53
        this.delims = delims;
45
    }
54
    }
46
    
55
56
    /**
57
     * Iterates the original expression and returns the value at the index.
58
     *
59
     * @param context against which the expression should be evaluated
60
     * @param i the index of the value to return
61
     * @return the value at the index
62
     */
47
    public Object getItem(ELContext context, int i) {
63
    public Object getItem(ELContext context, int i) {
48
        if (originalListObject == null) {
64
        if (originalListObject == null) {
49
            originalListObject = orig.getValue(context);
65
            originalListObject = orig.getValue(context);
Lines 77-83 Link Here
77
        }
93
        }
78
        return currentObject;
94
        return currentObject;
79
    }
95
    }
80
    
96
97
    /**
98
     * Returns the original expression.
99
     *
100
     * @return the original expression
101
     */
81
    public ValueExpression getValueExpression() {
102
    public ValueExpression getValueExpression() {
82
        return orig;
103
        return orig;
83
    }
104
    }
(-)src/main/java/javax/servlet/jsp/jstl/core/IndexedValueExpression.java (-13 / +29 lines)
Lines 24-48 Link Here
24
import javax.el.ELContext;
24
import javax.el.ELContext;
25
import javax.el.ValueExpression;
25
import javax.el.ValueExpression;
26
26
27
/**
28
 * ValueExpression that refers to a specific member of an indexed variable.
29
 * This allows individual members of an indexed collection to be used as lvalues.
30
 */
27
public final class IndexedValueExpression extends ValueExpression implements Serializable {
31
public final class IndexedValueExpression extends ValueExpression implements Serializable {
32
    // serialVersionUID value defined by specification JavaDoc
33
    private static final long serialVersionUID = 1L;
28
34
29
    private static final long serialVersionUID = -7300711701036452952L;
35
    /**
36
     * The index variable.
37
     */
30
    protected final Integer i;
38
    protected final Integer i;
39
40
    /**
41
     * The indexed variable.
42
     */
31
    protected final ValueExpression orig;
43
    protected final ValueExpression orig;
32
    
44
33
    public IndexedValueExpression(ValueExpression valueExpression, int _i) {
45
    /**
46
     * Constructor specifying indexed variable and index.
47
     *
48
     * @param valueExpression that evaluates to the indexed variable
49
     * @param i index specifying the member
50
     */
51
    public IndexedValueExpression(ValueExpression valueExpression, int i) {
34
        orig = valueExpression;
52
        orig = valueExpression;
35
        i=_i;
53
        this.i = i;
36
    }
54
    }
37
    
55
38
    public boolean equals(Object arg0) {
56
    public boolean equals(Object o) {
39
        boolean rc=false;
57
        if (this == o) return true;
40
        if (arg0!=null) {
58
        if (o == null || getClass() != o.getClass()) return false;
41
            if (arg0.equals(orig)) {
59
42
                rc = true;
60
        IndexedValueExpression that = (IndexedValueExpression) o;
43
            }
61
        return i.equals(that.i) && orig.equals(that.orig);
44
        }
45
        return rc;
46
    }
62
    }
47
63
48
    public Class getExpectedType() {
64
    public Class getExpectedType() {
(-)src/main/java/javax/servlet/jsp/jstl/core/IteratedValueExpression.java (-15 / +18 lines)
Lines 22-47 Link Here
22
import javax.el.ELContext;
22
import javax.el.ELContext;
23
import javax.el.ValueExpression;
23
import javax.el.ValueExpression;
24
24
25
/**
26
 * ValueExpression that refers to a specific member of an indexed variable backed by an IteratedExpression.
27
 * This allows individual members of an indexed collection to be used as lvalues.
28
 */
25
public final class IteratedValueExpression extends ValueExpression {
29
public final class IteratedValueExpression extends ValueExpression {
30
    // serialVersionUID value defined by specification JavaDoc
31
    private static final long serialVersionUID = 1L;
26
32
27
    private static final long serialVersionUID = 2771035360633553883L;
33
    protected final int i;
28
    //IteratedExpression is not serializable
34
    // todo: IteratedExpression is not serializable - should this be ignored?
29
    protected final IteratedExpression iteratedExpression;
35
    protected final IteratedExpression iteratedExpression;
30
    protected final int i;
36
31
    
37
    public IteratedValueExpression(IteratedExpression _iteratedExpr, int i) {
32
    public IteratedValueExpression(IteratedExpression _iteratedExpression, int _i) {
38
        iteratedExpression = _iteratedExpr;
33
        iteratedExpression = _iteratedExpression;
39
        this.i = i;
34
        i = _i;
35
    }
40
    }
36
    
41
    
37
    public boolean equals(Object arg0) {
42
    public boolean equals(Object obj) {
38
        if (arg0==null) {
43
        if (this == obj) return true;
39
            return false;
44
        if (obj == null || getClass() != obj.getClass()) return false;
40
        }
45
41
        if (iteratedExpression.getValueExpression().equals(arg0)) {
46
        IteratedValueExpression that = (IteratedValueExpression) obj;
42
            return true;
47
        return i == that.i && iteratedExpression.equals(that.iteratedExpression);
43
        }
44
        return false;
45
    }
48
    }
46
49
47
    public Class getExpectedType() {
50
    public Class getExpectedType() {

Return to bug 49542