1 16 package org.apache.cocoon.forms.expression; 17 18 import org.outerj.expression.AbstractExpression; 19 import org.outerj.expression.Expression; 20 import org.outerj.expression.ExpressionContext; 21 import org.outerj.expression.ExpressionException; 22 23 29 public class IsNullFunction extends AbstractExpression { 30 31 public Object evaluate(ExpressionContext context) throws ExpressionException { 32 Object result = null; 33 try { 34 result = ((Expression)arguments.get(0)).evaluate(context); 35 } catch (ExpressionException e) { 36 if (!e.getMessage().startsWith("Unknown variable")) { 38 throw e; 39 } 40 } 41 return result == null? Boolean.TRUE: Boolean.FALSE; 42 } 43 44 public void check() throws ExpressionException { 45 if (arguments.size() != 1) { 46 throw new ExpressionException(getDescription() + " requires one argument.", getLine(), getColumn()); 47 } 48 } 49 50 public Class getResultType() { 51 return Boolean .class; 52 } 53 54 public String getDescription() { 55 return "IsNull function"; 56 } 57 } 58 | Popular Tags |