Display the collection types supported by c:forEach.
if (obj == null) return "";
if (obj instanceof String) return obj.toString();
/*
if (obj instanceof Collection) {
return "FIXME";
}
if (obj instanceof Map) {
return "FIXME";
}
if (obj instanceof Iterator) {
Iterator iter = (Iterator)obj;
while (iter.hasNext()) {
iter.next();
}
return "FIXME";
}
if (obj instanceof Enumeration) {
Enumeration enum_ = (Enumeration)obj;
while (enum_.hasMoreElements()) {
enum_.nextElement();
}
return "FIXME";
}
*/
try {
StringBuffer buf = new StringBuffer();
int count = Array.getLength(obj);
for (int i=0; i<count; i++) {
buf.append(Array.get(obj, i).toString());
if (i<count-1) buf.append("<font color='red'> </font>");
}
return buf.toString();
} catch (IllegalArgumentException ex) {}
throw new JspTagException("Bad Item");