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 public class LongLiteral extends Expr { 42 private long _value; 43 private Long _objValue; 44 45 48 public LongLiteral(long value) 49 { 50 _value = value; 51 _objValue = new Long (value); 52 } 53 54 57 @Override 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 _value; 89 } 90 91 98 @Override 99 public double evalDouble(ELContext env) 100 throws ELException 101 { 102 return (double) _value; 103 } 104 105 111 @Override 112 public boolean print(WriteStream out, ELContext env, boolean isEscaped) 113 throws IOException , ELException 114 { 115 out.print(_value); 116 117 return false; 118 } 119 120 125 public void printCreate(WriteStream os) 126 throws IOException 127 { 128 os.print("new com.caucho.el.LongLiteral("); 129 os.print(_value); 130 os.print("L)"); 131 } 132 133 136 public boolean equals(Object o) 137 { 138 if (! (o instanceof LongLiteral)) 139 return false; 140 141 LongLiteral literal = (LongLiteral) o; 142 143 return _value == literal._value; 144 } 145 146 149 public String toString() 150 { 151 return String.valueOf(_value); 152 } 153 } 154 | Popular Tags |