1 29 30 package com.caucho.el; 31 32 import com.caucho.vfs.WriteStream; 33 34 import javax.el.ELContext; 35 import javax.el.ELException; 36 import java.io.IOException ; 37 38 41 abstract public class AbstractBooleanExpr extends Expr { 42 43 50 @Override 51 abstract public boolean evalBoolean(ELContext env) 52 throws ELException; 53 54 61 @Override 62 public Object getValue(ELContext env) 63 throws ELException 64 { 65 return evalBoolean(env) ? Boolean.TRUE : Boolean.FALSE; 66 } 67 68 75 @Override 76 public String evalString(ELContext env) 77 throws ELException 78 { 79 return evalBoolean(env) ? "true" : "false"; 80 } 81 82 89 @Override 90 public long evalLong(ELContext env) 91 throws ELException 92 { 93 ELException e = new ELException(L.l("'{0}': boolean expressions can not be converted to long values.", this)); 94 95 error(e, env); 96 97 return 0; 98 } 99 100 103 @Override 104 public double evalDouble(ELContext env) 105 throws ELException 106 { 107 ELException e = new ELException(L.l("`{0}': boolean expressions can not be converted to double values.", this)); 108 109 error(e, env); 110 111 return 0; 112 } 113 114 120 @Override 121 public boolean print(WriteStream out, ELContext env, boolean isEscaped) 122 throws IOException , ELException 123 { 124 if (evalBoolean(env)) 125 out.print("true"); 126 else 127 out.print("false"); 128 129 return false; 130 } 131 } 132 | Popular Tags |