KickJava   Java API By Example, From Geeks To Geeks.

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


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

18 public abstract class SimpleNode extends ELSupport implements Node {
19     protected Node parent;
20
21     protected Node[] children;
22
23     protected int id;
24
25     protected String JavaDoc image;
26
27     public SimpleNode(int i) {
28         id = i;
29     }
30
31     public void jjtOpen() {
32     }
33
34     public void jjtClose() {
35     }
36
37     public void jjtSetParent(Node n) {
38         parent = n;
39     }
40
41     public Node jjtGetParent() {
42         return parent;
43     }
44
45     public void jjtAddChild(Node n, int i) {
46         if (children == null) {
47             children = new Node[i + 1];
48         } else if (i >= children.length) {
49             Node c[] = new Node[i + 1];
50             System.arraycopy(children, 0, c, 0, children.length);
51             children = c;
52         }
53         children[i] = n;
54     }
55
56     public Node jjtGetChild(int i) {
57         return children[i];
58     }
59
60     public int jjtGetNumChildren() {
61         return (children == null) ? 0 : children.length;
62     }
63
64     /*
65      * You can override these two methods in subclasses of SimpleNode to
66      * customize the way the node appears when the tree is dumped. If your
67      * output uses more than one line you should override toString(String),
68      * otherwise overriding toString() is probably all you need to do.
69      */

70
71     public String JavaDoc toString() {
72         if (this.image != null) {
73             return ELParserTreeConstants.jjtNodeName[id] + "[" + this.image
74                     + "]";
75         }
76         return ELParserTreeConstants.jjtNodeName[id];
77     }
78
79     public String JavaDoc toString(String JavaDoc prefix) {
80         return prefix + toString();
81     }
82
83     /*
84      * Override this method if you want to customize how the node dumps out its
85      * children.
86      */

87
88     public void dump(String JavaDoc prefix) {
89         System.out.println(toString(prefix));
90         if (children != null) {
91             for (int i = 0; i < children.length; ++i) {
92                 SimpleNode n = (SimpleNode) children[i];
93                 if (n != null) {
94                     n.dump(prefix + " ");
95                 }
96             }
97         }
98     }
99
100     public String JavaDoc getImage() {
101         return image;
102     }
103
104     public void setImage(String JavaDoc image) {
105         this.image = image;
106     }
107
108     public Class JavaDoc getType(EvaluationContext ctx)
109             throws ELException {
110         throw new UnsupportedOperationException JavaDoc();
111     }
112
113     public Object JavaDoc getValue(EvaluationContext ctx)
114             throws ELException {
115         throw new UnsupportedOperationException JavaDoc();
116     }
117
118     public boolean isReadOnly(EvaluationContext ctx)
119             throws ELException {
120         return true;
121     }
122
123     public void setValue(EvaluationContext ctx, Object JavaDoc value)
124             throws ELException {
125         throw new PropertyNotWritableException(MessageFactory.get("error.syntax.set"));
126     }
127
128     public void accept(NodeVisitor visitor) throws Exception JavaDoc {
129         visitor.visit(this);
130         if (this.children != null && this.children.length > 0) {
131             for (int i = 0; i < this.children.length; i++) {
132                 this.children[i].accept(visitor);
133             }
134         }
135     }
136
137     public Object JavaDoc invoke(EvaluationContext ctx, Class JavaDoc[] paramTypes, Object JavaDoc[] paramValues) throws ELException {
138         throw new UnsupportedOperationException JavaDoc();
139     }
140
141     public MethodInfo getMethodInfo(EvaluationContext ctx, Class JavaDoc[] paramTypes) throws ELException {
142         throw new UnsupportedOperationException JavaDoc();
143     }
144 }
145
Popular Tags