1 2 3 package org.apache.el.parser; 4 5 import javax.el.ELException; 6 7 import org.apache.el.lang.EvaluationContext; 8 9 10 14 public final class AstString extends SimpleNode { 15 public AstString(int id) { 16 super(id); 17 } 18 19 private String string; 20 21 public String getString() { 22 if (this.string == null) { 23 this.string = this.image.substring(1, this.image.length() - 1); 24 } 25 return this.string; 26 } 27 28 public Class getType(EvaluationContext ctx) 29 throws ELException { 30 return String .class; 31 } 32 33 public Object getValue(EvaluationContext ctx) 34 throws ELException { 35 return this.getString(); 36 } 37 38 public void setImage(String image) { 39 if (image.indexOf('\\') == -1) { 40 this.image = image; 41 return; 42 } 43 int size = image.length(); 44 StringBuffer buf = new StringBuffer (size); 45 for (int i = 0; i < size; i++) { 46 char c = image.charAt(i); 47 if (c == '\\' && i + 1 < size) { 48 char c1 = image.charAt(i + 1); 49 if (c1 == '\\' || c1 == '"' || c1 == '\'' || c1 == '#' 50 || c1 == '$') { 51 c = c1; 52 i++; 53 } 54 } 55 buf.append(c); 56 } 57 this.image = buf.toString(); 58 } 59 } 60 | Popular Tags |