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 javax.servlet.jsp.JspWriter ; 37 import java.io.IOException ; 38 39 42 public class DoubleLiteral extends Expr { 43 private double _value; 44 private Double _objValue; 45 46 49 public DoubleLiteral(double value) 50 { 51 _value = value; 52 _objValue = new Double (value); 53 } 54 55 58 public boolean isConstant() 59 { 60 return true; 61 } 62 63 70 @Override 71 public Object getValue(ELContext env) 72 throws ELException 73 { 74 return _objValue; 75 } 76 77 84 @Override 85 public long evalLong(ELContext env) 86 throws ELException 87 { 88 return (long) _value; 89 } 90 91 98 @Override 99 public double evalDouble(ELContext env) 100 throws ELException 101 { 102 return _value; 103 } 104 105 115 @Override 116 public boolean print(JspWriter out, 117 ELContext env, 118 boolean escapeXml) 119 throws IOException , ELException 120 { 121 out.print(_value); 122 123 return false; 124 } 125 126 131 @Override 132 public void printCreate(WriteStream os) 133 throws IOException 134 { 135 os.print("new com.caucho.el.DoubleLiteral("); 136 os.print(_value); 137 os.print(")"); 138 } 139 140 143 public boolean equals(Object o) 144 { 145 if (! (o instanceof DoubleLiteral)) 146 return false; 147 148 DoubleLiteral literal = (DoubleLiteral) o; 149 150 return _value == literal._value; 151 } 152 153 156 public String toString() 157 { 158 return String.valueOf(_value); 159 } 160 } 161 | Popular Tags |