1 23 24 package com.sun.el.parser; 25 26 import java.util.Collection ; 27 import java.util.Map ; 28 29 import javax.el.ELException; 30 31 import com.sun.el.lang.EvaluationContext; 32 33 37 public final class AstEmpty extends SimpleNode { 38 public AstEmpty(int id) { 39 super(id); 40 } 41 42 public Class getType(EvaluationContext ctx) 43 throws ELException { 44 return Boolean .class; 45 } 46 47 public Object getValue(EvaluationContext ctx) 48 throws ELException { 49 Object obj = this.children[0].getValue(ctx); 50 if (obj == null) { 51 return Boolean.TRUE; 52 } else if (obj instanceof String ) { 53 return Boolean.valueOf(((String ) obj).length() == 0); 54 } else if (obj instanceof Object []) { 55 return Boolean.valueOf(((Object []) obj).length == 0); 56 } else if (obj instanceof Collection ) { 57 return Boolean.valueOf(((Collection ) obj).isEmpty()); 58 } else if (obj instanceof Map ) { 59 return Boolean.valueOf(((Map ) obj).isEmpty()); 60 } 61 return Boolean.FALSE; 62 } 63 } 64 | Popular Tags |