1 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 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 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 90 91 public String 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 toString(String prefix) { 100 return prefix + toString(); 101 } 102 103 107 108 public void dump(String 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 getImage() { 121 return image; 122 } 123 124 public void setImage(String image) { 125 this.image = image; 126 } 127 128 public Class getType(EvaluationContext ctx) 129 throws ELException { 130 throw new UnsupportedOperationException (); 131 } 132 133 public Object getValue(EvaluationContext ctx) 134 throws ELException { 135 throw new UnsupportedOperationException (); 136 } 137 138 public boolean isReadOnly(EvaluationContext ctx) 139 throws ELException { 140 return true; 141 } 142 143 public void setValue(EvaluationContext ctx, Object 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 invoke(EvaluationContext ctx, Class [] paramTypes, Object [] paramValues) throws ELException { 158 throw new UnsupportedOperationException (); 159 } 160 161 public MethodInfo getMethodInfo(EvaluationContext ctx, Class [] paramTypes) throws ELException { 162 throw new UnsupportedOperationException (); 163 } 164 } 165 | Popular Tags |