Methods Summary |
---|
public java.lang.Object | getItem(javax.el.ELContext context, int i)Evaluates the stored ValueExpression and return the indexed item.
if (base == null) {
base = orig.getValue(context);
if (base == null) {
return null;
}
iter = toIterator(base);
index = 0;
}
if (index > i) {
// Restart from index 0
iter = toIterator(base);
index = 0;
}
while (iter.hasNext()) {
Object item = iter.next();
if (index++ == i) {
return item;
}
}
return null;
|
public javax.el.ValueExpression | getValueExpression()
return orig;
|
private java.util.Iterator | toIterator(java.lang.Object obj)
Iterator iter;
if (obj instanceof String) {
iter = toIterator(new StringTokenizer((String)obj, delims));
}
else if (obj instanceof Iterator) {
iter = (Iterator)obj;
}
else if (obj instanceof Collection) {
iter = toIterator(((Collection) obj).iterator());
}
else if (obj instanceof Enumeration) {
iter = toIterator((Enumeration)obj);
}
else if (obj instanceof Map) {
iter = ((Map)obj).entrySet().iterator();
} else {
throw new ELException("Don't know how to iterate over supplied "
+ "items in forEach");
}
return iter;
|
private java.util.Iterator | toIterator(java.util.Enumeration obj)
return new Iterator() {
public boolean hasNext() {
return obj.hasMoreElements();
}
public Object next() {
return obj.nextElement();
}
public void remove() {}
};
|