KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > el > parser > AstString


1 /* Generated By:JJTree: Do not edit this line. AstString.java */
2
3 package org.apache.el.parser;
4
5 import javax.el.ELException;
6
7 import org.apache.el.lang.EvaluationContext;
8
9
10 /**
11  * @author Jacob Hookom [jacob@hookom.net]
12  * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
13  */

14 public final class AstString extends SimpleNode {
15     public AstString(int id) {
16         super(id);
17     }
18
19     private String JavaDoc string;
20
21     public String JavaDoc 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 JavaDoc getType(EvaluationContext ctx)
29             throws ELException {
30         return String JavaDoc.class;
31     }
32
33     public Object JavaDoc getValue(EvaluationContext ctx)
34             throws ELException {
35         return this.getString();
36     }
37
38     public void setImage(String JavaDoc image) {
39         if (image.indexOf('\\') == -1) {
40             this.image = image;
41             return;
42         }
43         int size = image.length();
44         StringBuffer JavaDoc buf = new StringBuffer JavaDoc(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