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 IdExpr extends Expr { 42 private String _id; 44 45 48 public IdExpr(String id) 49 { 50 _id = id; 51 } 52 53 56 @Override 57 public boolean isReadOnly(ELContext env) 58 { 59 return false; 60 } 61 62 67 @Override 68 public Expr createField(String field) 69 { 70 Expr arrayExpr = createField(new StringLiteral(field)); 71 72 return new PathExpr(arrayExpr, _id + '.' + field); 73 } 74 75 82 @Override 83 public Object getValue(ELContext env) 84 throws ELException 85 { 86 return env.getELResolver().getValue(env, null, _id); 87 } 88 89 96 @Override 97 public void setValue(ELContext env, Object value) 98 throws ELException 99 { 100 env.getELResolver().setValue(env, null, _id, value); 101 } 102 103 106 @Override 107 public void printCreate(WriteStream os) 108 throws IOException 109 { 110 os.print("new com.caucho.el.IdExpr(\""); 111 printEscapedString(os, _id); 112 os.print("\")"); 113 } 114 115 public boolean equals(Object o) 116 { 117 if (o == null || ! o.getClass().equals(IdExpr.class)) 118 return false; 119 120 IdExpr expr = (IdExpr) o; 121 122 return _id.equals(expr._id); 123 } 124 125 public String toString() 126 { 127 return _id; 128 } 129 } 130 | Popular Tags |