KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > el > parser > SimpleNode


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  *
21  * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
22  */
/* Generated By:JJTree: Do not edit this line. SimpleNode.java */
23
24 package com.sun.el.parser;
25
26 import javax.el.ELException;
27 import javax.el.MethodInfo;
28 import javax.el.PropertyNotWritableException;
29
30 import com.sun.el.lang.ELSupport;
31 import com.sun.el.lang.EvaluationContext;
32 import com.sun.el.util.MessageFactory;
33
34 /**
35  * @author Jacob Hookom [jacob@hookom.net]
36  * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: kchung $
37  */

38 public abstract class SimpleNode extends ELSupport implements Node {
39     protected Node parent;
40
41     protected Node[] children;
42
43     protected int id;
44
45     protected String JavaDoc image;
46
47     public SimpleNode(int i) {
48         id = i;
49     }
50
51     public void jjtOpen() {
52     }
53
54     public void jjtClose() {
55     }
56
57     public void jjtSetParent(Node n) {
58         parent = n;
59     }
60
61     public Node jjtGetParent() {
62         return parent;
63     }
64
65     public void jjtAddChild(Node n, int i) {
66         if (children == null) {
67             children = new Node[i + 1];
68         } else if (i >= children.length) {
69             Node c[] = new Node[i + 1];
70             System.arraycopy(children, 0, c, 0, children.length);
71             children = c;
72         }
73         children[i] = n;
74     }
75
76     public Node jjtGetChild(int i) {
77         return children[i];
78     }
79
80     public int jjtGetNumChildren() {
81         return (children == null) ? 0 : children.length;
82     }
83
84     /*
85      * You can override these two methods in subclasses of SimpleNode to
86      * customize the way the node appears when the tree is dumped. If your
87      * output uses more than one line you should override toString(String),
88      * otherwise overriding toString() is probably all you need to do.
89      */

90
91     public String JavaDoc toString() {
92         if (this.image != null) {
93             return ELParserTreeConstants.jjtNodeName[id] + "[" + this.image
94                     + "]";
95         }
96         return ELParserTreeConstants.jjtNodeName[id];
97     }
98
99     public String JavaDoc toString(String JavaDoc prefix) {
100         return prefix + toString();
101     }
102
103     /*
104      * Override this method if you want to customize how the node dumps out its
105      * children.
106      */

107
108     public void dump(String JavaDoc prefix) {
109         System.out.println(toString(prefix));
110         if (children != null) {
111             for (int i = 0; i < children.length; ++i) {
112                 SimpleNode n = (SimpleNode) children[i];
113                 if (n != null) {
114                     n.dump(prefix + " ");
115                 }
116             }
117         }
118     }
119
120     public String JavaDoc getImage() {
121         return image;
122     }
123
124     public void setImage(String JavaDoc image) {
125         this.image = image;
126     }
127
128     public Class JavaDoc getType(EvaluationContext ctx)
129             throws ELException {
130         throw new UnsupportedOperationException JavaDoc();
131     }
132
133     public Object JavaDoc getValue(EvaluationContext ctx)
134             throws ELException {
135         throw new UnsupportedOperationException JavaDoc();
136     }
137
138     public boolean isReadOnly(EvaluationContext ctx)
139             throws ELException {
140         return true;
141     }
142
143     public void setValue(EvaluationContext ctx, Object JavaDoc value)
144             throws ELException {
145         throw new PropertyNotWritableException(MessageFactory.get("error.syntax.set"));
146     }
147
148     public void accept(NodeVisitor visitor) throws ELException {
149         visitor.visit(this);
150         if (this.children != null && this.children.length > 0) {
151             for (int i = 0; i < this.children.length; i++) {
152                 this.children[i].accept(visitor);
153             }
154         }
155     }
156
157     public Object JavaDoc invoke(EvaluationContext ctx, Class JavaDoc[] paramTypes, Object JavaDoc[] paramValues) throws ELException {
158         throw new UnsupportedOperationException JavaDoc();
159     }
160
161     public MethodInfo getMethodInfo(EvaluationContext ctx, Class JavaDoc[] paramTypes) throws ELException {
162         throw new UnsupportedOperationException JavaDoc();
163     }
164 }
165
Popular Tags