1 2 3 package org.apache.el.parser; 4 5 import java.util.Collection ; 6 import java.util.Map ; 7 8 import javax.el.ELException; 9 10 import org.apache.el.lang.EvaluationContext; 11 12 13 17 public final class AstEmpty extends SimpleNode { 18 public AstEmpty(int id) { 19 super(id); 20 } 21 22 public Class getType(EvaluationContext ctx) 23 throws ELException { 24 return Boolean .class; 25 } 26 27 public Object getValue(EvaluationContext ctx) 28 throws ELException { 29 Object obj = this.children[0].getValue(ctx); 30 if (obj == null) { 31 return Boolean.TRUE; 32 } else if (obj instanceof String ) { 33 return Boolean.valueOf(((String ) obj).length() == 0); 34 } else if (obj instanceof Object []) { 35 return Boolean.valueOf(((Object []) obj).length == 0); 36 } else if (obj instanceof Collection ) { 37 return Boolean.valueOf(((Collection ) obj).isEmpty()); 38 } else if (obj instanceof Map ) { 39 return Boolean.valueOf(((Map ) obj).isEmpty()); 40 } 41 return Boolean.FALSE; 42 } 43 } 44 | Popular Tags |