mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-31 05:25:25 +00:00
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:
1 parent
3abdae41f0
commit
6a65ea8113
1 file changed
+10
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user