1 23 24 package com.sun.el.parser; 25 26 import javax.el.ELException; 27 28 import com.sun.el.lang.EvaluationContext; 29 30 34 public final class AstString extends SimpleNode { 35 public AstString(int id) { 36 super(id); 37 } 38 39 private String string; 40 41 public String getString() { 42 if (this.string == null) { 43 this.string = this.image.substring(1, this.image.length() - 1); 44 } 45 return this.string; 46 } 47 48 public Class getType(EvaluationContext ctx) 49 throws ELException { 50 return String .class; 51 } 52 53 public Object getValue(EvaluationContext ctx) 54 throws ELException { 55 return this.getString(); 56 } 57 58 public void setImage(String image) { 59 if (image.indexOf('\\') == -1) { 60 this.image = image; 61 return; 62 } 63 int size = image.length(); 64 StringBuffer buf = new StringBuffer (size); 65 for (int i = 0; i < size; i++) { 66 char c = image.charAt(i); 67 if (c == '\\' && i + 1 < size) { 68 char c1 = image.charAt(i + 1); 69 if (c1 == '\\' || c1 == '"' || c1 == '\'' || c1 == '#' 70 || c1 == '$') { 71 c = c1; 72 i++; 73 } 74 } 75 buf.append(c); 76 } 77 this.image = buf.toString(); 78 } 79 } 80 | Popular Tags |