added custom size() function.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@2697 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2007-03-26 19:37:49 +00:00
1 parent 3abdae41f0
commit 6a65ea8113
1 file changed
+10
+10
View File
@@ -12,6 +12,7 @@ import hudson.model.Action;
import org.kohsuke.stapler.Ancestor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.apache.commons.jexl.parser.ASTSizeFunction;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
@@ -366,4 +367,13 @@ public class Functions {
else
return "images/24x24/"+name;
}
/**
* Works like JSTL build-in size(x) function,
* but handle null gracefully.
*/
public static int size(Object o) throws Exception {
if(o==null) return 0;
return ASTSizeFunction.sizeOf(o);
}
}