001: /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
002:
003: package org.apache.el.parser;
004:
005: import javax.el.ELException;
006: import javax.el.MethodInfo;
007: import javax.el.PropertyNotWritableException;
008:
009: import org.apache.el.lang.ELSupport;
010: import org.apache.el.lang.EvaluationContext;
011: import org.apache.el.util.MessageFactory;
012:
013: /**
014: * @author Jacob Hookom [jacob@hookom.net]
015: * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
016: */
017: public abstract class SimpleNode extends ELSupport implements Node {
018: protected Node parent;
019:
020: protected Node[] children;
021:
022: protected int id;
023:
024: protected String image;
025:
026: public SimpleNode(int i) {
027: id = i;
028: }
029:
030: public void jjtOpen() {
031: }
032:
033: public void jjtClose() {
034: }
035:
036: public void jjtSetParent(Node n) {
037: parent = n;
038: }
039:
040: public Node jjtGetParent() {
041: return parent;
042: }
043:
044: public void jjtAddChild(Node n, int i) {
045: if (children == null) {
046: children = new Node[i + 1];
047: } else if (i >= children.length) {
048: Node c[] = new Node[i + 1];
049: System.arraycopy(children, 0, c, 0, children.length);
050: children = c;
051: }
052: children[i] = n;
053: }
054:
055: public Node jjtGetChild(int i) {
056: return children[i];
057: }
058:
059: public int jjtGetNumChildren() {
060: return (children == null) ? 0 : children.length;
061: }
062:
063: /*
064: * You can override these two methods in subclasses of SimpleNode to
065: * customize the way the node appears when the tree is dumped. If your
066: * output uses more than one line you should override toString(String),
067: * otherwise overriding toString() is probably all you need to do.
068: */
069:
070: public String toString() {
071: if (this .image != null) {
072: return ELParserTreeConstants.jjtNodeName[id] + "["
073: + this .image + "]";
074: }
075: return ELParserTreeConstants.jjtNodeName[id];
076: }
077:
078: public String toString(String prefix) {
079: return prefix + toString();
080: }
081:
082: /*
083: * Override this method if you want to customize how the node dumps out its
084: * children.
085: */
086:
087: public void dump(String prefix) {
088: System.out.println(toString(prefix));
089: if (children != null) {
090: for (int i = 0; i < children.length; ++i) {
091: SimpleNode n = (SimpleNode) children[i];
092: if (n != null) {
093: n.dump(prefix + " ");
094: }
095: }
096: }
097: }
098:
099: public String getImage() {
100: return image;
101: }
102:
103: public void setImage(String image) {
104: this .image = image;
105: }
106:
107: public Class getType(EvaluationContext ctx) throws ELException {
108: throw new UnsupportedOperationException();
109: }
110:
111: public Object getValue(EvaluationContext ctx) throws ELException {
112: throw new UnsupportedOperationException();
113: }
114:
115: public boolean isReadOnly(EvaluationContext ctx) throws ELException {
116: return true;
117: }
118:
119: public void setValue(EvaluationContext ctx, Object value)
120: throws ELException {
121: throw new PropertyNotWritableException(MessageFactory
122: .get("error.syntax.set"));
123: }
124:
125: public void accept(NodeVisitor visitor) throws Exception {
126: visitor.visit(this );
127: if (this .children != null && this .children.length > 0) {
128: for (int i = 0; i < this .children.length; i++) {
129: this .children[i].accept(visitor);
130: }
131: }
132: }
133:
134: public Object invoke(EvaluationContext ctx, Class[] paramTypes,
135: Object[] paramValues) throws ELException {
136: throw new UnsupportedOperationException();
137: }
138:
139: public MethodInfo getMethodInfo(EvaluationContext ctx,
140: Class[] paramTypes) throws ELException {
141: throw new UnsupportedOperationException();
142: }
143: }
|