View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
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   * @author Jacob Hookom [jacob@hookom.net]
32   * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
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       * You can override these two methods in subclasses of SimpleNode to
82       * customize the way the node appears when the tree is dumped. If your
83       * output uses more than one line you should override toString(String),
84       * otherwise overriding toString() is probably all you need to do.
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      * Override this method if you want to customize how the node dumps out its
101      * children.
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 }