KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > el > parser > AstEmpty


1 /* Generated By:JJTree: Do not edit this line. AstEmpty.java */
2
3 package org.apache.el.parser;
4
5 import java.util.Collection JavaDoc;
6 import java.util.Map JavaDoc;
7
8 import javax.el.ELException;
9
10 import org.apache.el.lang.EvaluationContext;
11
12
13 /**
14  * @author Jacob Hookom [jacob@hookom.net]
15  * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
16  */

17 public final class AstEmpty extends SimpleNode {
18     public AstEmpty(int id) {
19         super(id);
20     }
21
22     public Class JavaDoc getType(EvaluationContext ctx)
23             throws ELException {
24         return Boolean JavaDoc.class;
25     }
26
27     public Object JavaDoc getValue(EvaluationContext ctx)
28             throws ELException {
29         Object JavaDoc obj = this.children[0].getValue(ctx);
30         if (obj == null) {
31             return Boolean.TRUE;
32         } else if (obj instanceof String JavaDoc) {
33             return Boolean.valueOf(((String JavaDoc) obj).length() == 0);
34         } else if (obj instanceof Object JavaDoc[]) {
35             return Boolean.valueOf(((Object JavaDoc[]) obj).length == 0);
36         } else if (obj instanceof Collection JavaDoc) {
37             return Boolean.valueOf(((Collection JavaDoc) obj).isEmpty());
38         } else if (obj instanceof Map JavaDoc) {
39             return Boolean.valueOf(((Map JavaDoc) obj).isEmpty());
40         }
41         return Boolean.FALSE;
42     }
43 }
44
Popular Tags