1 21 package oracle.toplink.essentials.internal.parsing; 23 24 import oracle.toplink.essentials.expressions.*; 25 import oracle.toplink.essentials.mappings.DatabaseMapping; 26 import oracle.toplink.essentials.queryframework.ObjectLevelReadQuery; 27 28 38 public class Node { 39 private int line; 40 private int column; 41 protected Node left = null; 42 protected Node right = null; 43 private Object type; 44 public boolean shouldGenerateExpression; 45 46 49 public Node() { 50 super(); 51 } 52 53 57 public void applyToQuery(ObjectLevelReadQuery theQuery, GenerationContext context) { 58 } 59 60 65 public Expression addToExpression(Expression parentExpression, GenerationContext context) { 66 return parentExpression; 67 } 68 69 74 public String getAsString() { 75 return toString(); 76 } 77 78 82 public void validate(ParseTreeContext context) { 83 if (left != null) { 85 left.validate(context); 86 } 87 if (right != null) { 88 right.validate(context); 89 } 90 } 91 92 95 public void validateParameter(ParseTreeContext context, Object contextType) { 96 } 98 99 104 public Expression generateExpression(GenerationContext context) { 105 return null; 106 } 107 108 112 public Node getLeft() { 113 return left; 114 } 115 116 120 public Node getRight() { 121 return right; 122 } 123 124 128 public boolean hasLeft() { 129 return getLeft() != null; 130 } 131 132 136 public boolean hasRight() { 137 return getRight() != null; 138 } 139 140 144 public boolean isAggregateNode() { 145 return false; 146 } 147 148 152 public boolean isDotNode() { 153 return false; 154 } 155 156 160 public boolean isLiteralNode() { 161 return false; 162 } 163 164 168 public boolean isMultiplyNode() { 169 return false; 170 } 171 172 176 public boolean isNotNode() { 177 return false; 178 } 179 180 184 public boolean isParameterNode() { 185 return false; 186 } 187 188 192 public boolean isDivideNode() { 193 return false; 194 } 195 196 200 public boolean isPlusNode() { 201 return false; 202 } 203 204 208 public boolean isMinusNode() { 209 return false; 210 } 211 212 216 public boolean isVariableNode() { 217 return false; 218 } 219 220 224 public boolean isAttributeNode() { 225 return false; 226 } 227 228 232 public boolean isCountNode() { 233 return false; 234 } 235 236 240 public boolean isConstructorNode() { 241 return false; 242 } 243 244 248 public boolean isSubqueryNode() { 249 return false; 250 } 251 252 256 public boolean isEscape() { 257 return false; } 259 260 264 public String resolveAttribute() { 265 return ""; 266 } 267 268 272 public Class resolveClass(GenerationContext context) { 273 return null; 274 } 275 276 280 public Class resolveClass(GenerationContext context, Class ownerClass) { 281 return null; 282 } 283 284 288 public DatabaseMapping resolveMapping(GenerationContext context) { 289 return null; 290 } 291 292 297 public DatabaseMapping resolveMapping(GenerationContext context, Class ownerClass) { 298 return null; 299 } 300 301 305 public void setLeft(Node newLeft) { 306 left = newLeft; 307 } 308 309 313 public void setRight(Node newRight) { 314 right = newRight; 315 } 316 317 public int getLine() { 318 return line; 319 } 320 321 public void setLine(int line) { 322 this.line = line; 323 } 324 325 public int getColumn() { 326 return column; 327 } 328 329 public void setColumn(int column) { 330 this.column = column; 331 } 332 333 337 public Object getType() { 338 return type; 339 } 340 341 345 public void setType(Object type) { 346 this.type = type; 347 } 348 349 353 public Expression appendExpression(Expression left, Expression right) { 354 Expression expr = null; 355 if (left == null) { 356 expr = right; 357 } else if (right == null) { 358 expr = left; 359 } else { 360 expr = left.and(right); 361 } 362 return expr; 363 } 364 365 public String toString() { 366 try { 367 return toString(1); 368 } catch (Throwable t) { 369 return t.toString(); 370 } 371 } 372 373 public String toString(int indent) { 374 StringBuffer buffer = new StringBuffer (); 375 buffer.append(toStringDisplayName()); 376 buffer.append("\r\n"); 377 toStringIndent(indent, buffer); 378 if (hasLeft()) { 379 buffer.append("Left: " + getLeft().toString(indent + 1)); 380 } else { 381 buffer.append("Left: null"); 382 } 383 384 buffer.append("\r\n"); 385 toStringIndent(indent, buffer); 386 if (hasRight()) { 387 buffer.append("Right: " + getRight().toString(indent + 1)); 388 } else { 389 buffer.append("Right: null"); 390 } 391 return buffer.toString(); 392 } 393 394 public String toStringDisplayName() { 395 return getClass().toString().substring(getClass().toString().lastIndexOf('.') + 1, getClass().toString().length()); 396 } 397 398 public void toStringIndent(int indent, StringBuffer buffer) { 399 for (int i = 0; i < indent; i++) { 400 buffer.append(" "); 401 } 402 ; 403 } 404 } 405 | Popular Tags |