1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.el.parser;
20
21 import javax.el.ELException;
22 import javax.el.MethodInfo;
23 import javax.el.PropertyNotWritableException;
24
25 import org.apache.el.lang.ELSupport;
26 import org.apache.el.lang.EvaluationContext;
27 import org.apache.el.util.MessageFactory;
28
29
30
31
32
33
34 public abstract class SimpleNode extends ELSupport implements Node {
35 protected Node parent;
36
37 protected Node[] children;
38
39 protected int id;
40
41 protected String image;
42
43 public SimpleNode(int i) {
44 id = i;
45 }
46
47 public void jjtOpen() {
48 }
49
50 public void jjtClose() {
51 }
52
53 public void jjtSetParent(Node n) {
54 parent = n;
55 }
56
57 public Node jjtGetParent() {
58 return parent;
59 }
60
61 public void jjtAddChild(Node n, int i) {
62 if (children == null) {
63 children = new Node[i + 1];
64 } else if (i >= children.length) {
65 Node c[] = new Node[i + 1];
66 System.arraycopy(children, 0, c, 0, children.length);
67 children = c;
68 }
69 children[i] = n;
70 }
71
72 public Node jjtGetChild(int i) {
73 return children[i];
74 }
75
76 public int jjtGetNumChildren() {
77 return (children == null) ? 0 : children.length;
78 }
79
80
81
82
83
84
85
86
87 public String toString() {
88 if (this.image != null) {
89 return ELParserTreeConstants.jjtNodeName[id] + "[" + this.image
90 + "]";
91 }
92 return ELParserTreeConstants.jjtNodeName[id];
93 }
94
95 public String toString(String prefix) {
96 return prefix + toString();
97 }
98
99
100
101
102
103
104 public void dump(String prefix) {
105 System.out.println(toString(prefix));
106 if (children != null) {
107 for (int i = 0; i < children.length; ++i) {
108 SimpleNode n = (SimpleNode) children[i];
109 if (n != null) {
110 n.dump(prefix + " ");
111 }
112 }
113 }
114 }
115
116 public String getImage() {
117 return image;
118 }
119
120 public void setImage(String image) {
121 this.image = image;
122 }
123
124 public Class getType(EvaluationContext ctx)
125 throws ELException {
126 throw new UnsupportedOperationException();
127 }
128
129 public Object getValue(EvaluationContext ctx)
130 throws ELException {
131 throw new UnsupportedOperationException();
132 }
133
134 public boolean isReadOnly(EvaluationContext ctx)
135 throws ELException {
136 return true;
137 }
138
139 public void setValue(EvaluationContext ctx, Object value)
140 throws ELException {
141 throw new PropertyNotWritableException(MessageFactory.get("error.syntax.set"));
142 }
143
144 public void accept(NodeVisitor visitor) throws Exception {
145 visitor.visit(this);
146 if (this.children != null && this.children.length > 0) {
147 for (int i = 0; i < this.children.length; i++) {
148 this.children[i].accept(visitor);
149 }
150 }
151 }
152
153 public Object invoke(EvaluationContext ctx, Class[] paramTypes, Object[] paramValues) throws ELException {
154 throw new UnsupportedOperationException();
155 }
156
157 public MethodInfo getMethodInfo(EvaluationContext ctx, Class[] paramTypes) throws ELException {
158 throw new UnsupportedOperationException();
159 }
160 }