1 package org.jacorb.notification.filter.etcl; 2 3 23 24 import java.lang.reflect.Field ; 25 26 import org.jacorb.notification.filter.EvaluationContext; 27 import org.jacorb.notification.filter.EvaluationException; 28 import org.jacorb.notification.filter.EvaluationResult; 29 30 import antlr.BaseAST; 31 import antlr.Token; 32 import antlr.collections.AST; 33 34 40 41 public abstract class AbstractTCLNode extends BaseAST implements TCLParserTokenTypes 42 { 43 private int astNodeType_; 44 45 47 private String name_; 48 49 52 public AbstractTCLNode(Token tok) 53 { 54 super(); 55 56 setType(tok.getType()); 57 } 58 59 protected AbstractTCLNode() 60 { 61 super(); 62 } 63 64 66 78 public EvaluationResult evaluate(EvaluationContext context) throws EvaluationException 79 { 80 throw new UnsupportedOperationException (); 81 } 82 83 88 public abstract void acceptInOrder(AbstractTCLVisitor visitor) throws VisitorException; 89 90 97 public abstract void acceptPreOrder(AbstractTCLVisitor visitor) throws VisitorException; 98 99 106 public abstract void acceptPostOrder(AbstractTCLVisitor visitor) throws VisitorException; 107 108 110 public final String getName() 111 { 112 return name_; 113 } 114 115 void setName(String name) 116 { 117 name_ = name; 118 } 119 120 125 public boolean hasNextSibling() 126 { 127 return (getNextSibling() != null); 128 } 129 130 public void printToStringBuffer(StringBuffer buffer) 131 { 132 if (getFirstChild() != null) 133 { 134 buffer.append(" ("); 135 } 136 137 buffer.append(" "); 138 buffer.append(toString()); 139 140 if (getFirstChild() != null) 141 { 142 buffer.append(((AbstractTCLNode) getFirstChild()).toStringList()); 143 } 144 145 if (getFirstChild() != null) 146 { 147 buffer.append(" )"); 148 } 149 } 150 151 156 public String toStringTree() 157 { 158 StringBuffer _buffer = new StringBuffer (); 159 160 printToStringBuffer(_buffer); 161 162 return _buffer.toString(); 163 } 164 165 170 public AbstractTCLNode left() 171 { 172 return (AbstractTCLNode) getFirstChild(); 173 } 174 175 180 public AbstractTCLNode right() 181 { 182 return (AbstractTCLNode) getFirstChild().getNextSibling(); 183 } 184 185 187 public boolean isStatic() 188 { 189 return false; 190 } 191 192 public boolean isNumber() 193 { 194 return false; 195 } 196 197 public boolean isString() 198 { 199 return false; 200 } 201 202 public boolean isBoolean() 203 { 204 return false; 205 } 206 207 213 public int getType() 214 { 215 return astNodeType_; 216 } 217 218 225 public void setType(int type) 226 { 227 astNodeType_ = type; 228 } 229 230 235 public static String getNameForType(int t) 236 { 237 try 238 { 239 Field [] _fields = TCLParserTokenTypes.class.getDeclaredFields(); 240 241 if (t - 6 < _fields.length) 242 { 243 return _fields[t - 6].getName(); 244 } 245 } catch (Exception e) 246 { 247 } 249 250 return "unknown type: " + t; 251 } 252 253 256 public void initialize(int t, String txt) 257 { 258 } 260 261 264 public void initialize(AST t) 265 { 266 } 268 269 272 public void initialize(Token tok) 273 { 274 } 276 } | Popular Tags |