FileDocCategorySizeDatePackage
Functions.javaAPI DocGlassfish v2 API3554Sat May 05 19:17:12 BST 2007org.apache.taglibs.standard.examples.taglib

Functions

public class Functions extends Object

Exmaples taglib Functions

author
Pierre Delisle

Fields Summary
Constructors Summary
Methods Summary
public static java.lang.Stringdisplay(java.lang.Object obj)
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");