1 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 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 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 70 71 public String 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 toString(String prefix) { 80 return prefix + toString(); 81 } 82 83 87 88 public void dump(String 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 getImage() { 101 return image; 102 } 103 104 public void setImage(String image) { 105 this.image = image; 106 } 107 108 public Class getType(EvaluationContext ctx) 109 throws ELException { 110 throw new UnsupportedOperationException (); 111 } 112 113 public Object getValue(EvaluationContext ctx) 114 throws ELException { 115 throw new UnsupportedOperationException (); 116 } 117 118 public boolean isReadOnly(EvaluationContext ctx) 119 throws ELException { 120 return true; 121 } 122 123 public void setValue(EvaluationContext ctx, Object value) 124 throws ELException { 125 throw new PropertyNotWritableException(MessageFactory.get("error.syntax.set")); 126 } 127 128 public void accept(NodeVisitor visitor) throws Exception { 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 invoke(EvaluationContext ctx, Class [] paramTypes, Object [] paramValues) throws ELException { 138 throw new UnsupportedOperationException (); 139 } 140 141 public MethodInfo getMethodInfo(EvaluationContext ctx, Class [] paramTypes) throws ELException { 142 throw new UnsupportedOperationException (); 143 } 144 } 145 | Popular Tags |