01: /* Generated By:JJTree: Do not edit this line. AstEmpty.java */
02:
03: package org.apache.el.parser;
04:
05: import java.util.Collection;
06: import java.util.Map;
07:
08: import javax.el.ELException;
09:
10: import org.apache.el.lang.EvaluationContext;
11:
12: /**
13: * @author Jacob Hookom [jacob@hookom.net]
14: * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
15: */
16: public final class AstEmpty extends SimpleNode {
17: public AstEmpty(int id) {
18: super (id);
19: }
20:
21: public Class getType(EvaluationContext ctx) throws ELException {
22: return Boolean.class;
23: }
24:
25: public Object getValue(EvaluationContext ctx) throws ELException {
26: Object obj = this .children[0].getValue(ctx);
27: if (obj == null) {
28: return Boolean.TRUE;
29: } else if (obj instanceof String) {
30: return Boolean.valueOf(((String) obj).length() == 0);
31: } else if (obj instanceof Object[]) {
32: return Boolean.valueOf(((Object[]) obj).length == 0);
33: } else if (obj instanceof Collection) {
34: return Boolean.valueOf(((Collection) obj).isEmpty());
35: } else if (obj instanceof Map) {
36: return Boolean.valueOf(((Map) obj).isEmpty());
37: }
38: return Boolean.FALSE;
39: }
40: }
|