1 25 package org.objectweb.jonas_ejb.lib; 26 27 import org.objectweb.jonas_ejb.deployment.ejbql.ASTAbstractSchemaName; 28 import org.objectweb.jonas_ejb.deployment.ejbql.ASTAggregateSelectExpression; 29 import org.objectweb.jonas_ejb.deployment.ejbql.ASTArithmeticExpression; 30 import org.objectweb.jonas_ejb.deployment.ejbql.ASTArithmeticFactor; 31 import org.objectweb.jonas_ejb.deployment.ejbql.ASTArithmeticLiteral; 32 import org.objectweb.jonas_ejb.deployment.ejbql.ASTArithmeticTerm; 33 import org.objectweb.jonas_ejb.deployment.ejbql.ASTBetweenExpression; 34 import org.objectweb.jonas_ejb.deployment.ejbql.ASTBooleanExpression; 35 import org.objectweb.jonas_ejb.deployment.ejbql.ASTBooleanLiteral; 36 import org.objectweb.jonas_ejb.deployment.ejbql.ASTCmpPathExpression; 37 import org.objectweb.jonas_ejb.deployment.ejbql.ASTCollectionMemberDeclaration; 38 import org.objectweb.jonas_ejb.deployment.ejbql.ASTCollectionMemberExpression; 39 import org.objectweb.jonas_ejb.deployment.ejbql.ASTCollectionValuedPathExpression; 40 import org.objectweb.jonas_ejb.deployment.ejbql.ASTComparisonExpression; 41 import org.objectweb.jonas_ejb.deployment.ejbql.ASTConditionalExpression; 42 import org.objectweb.jonas_ejb.deployment.ejbql.ASTConditionalFactor; 43 import org.objectweb.jonas_ejb.deployment.ejbql.ASTConditionalTerm; 44 import org.objectweb.jonas_ejb.deployment.ejbql.ASTDatetimeExpression; 45 import org.objectweb.jonas_ejb.deployment.ejbql.ASTEJBQL; 46 import org.objectweb.jonas_ejb.deployment.ejbql.ASTEmptyCollectionComparisonExpression; 47 import org.objectweb.jonas_ejb.deployment.ejbql.ASTEntityBeanExpression; 48 import org.objectweb.jonas_ejb.deployment.ejbql.ASTFloatingPointLiteral; 49 import org.objectweb.jonas_ejb.deployment.ejbql.ASTFromClause; 50 import org.objectweb.jonas_ejb.deployment.ejbql.ASTFunctionsReturningNumerics; 51 import org.objectweb.jonas_ejb.deployment.ejbql.ASTFunctionsReturningStrings; 52 import org.objectweb.jonas_ejb.deployment.ejbql.ASTIdentificationVariable; 53 import org.objectweb.jonas_ejb.deployment.ejbql.ASTIdentifier; 54 import org.objectweb.jonas_ejb.deployment.ejbql.ASTInExpression; 55 import org.objectweb.jonas_ejb.deployment.ejbql.ASTInputParameter; 56 import org.objectweb.jonas_ejb.deployment.ejbql.ASTIntegerLiteral; 57 import org.objectweb.jonas_ejb.deployment.ejbql.ASTLikeExpression; 58 import org.objectweb.jonas_ejb.deployment.ejbql.ASTLimitClause; 59 import org.objectweb.jonas_ejb.deployment.ejbql.ASTLimitExpression; 60 import org.objectweb.jonas_ejb.deployment.ejbql.ASTLiteral; 61 import org.objectweb.jonas_ejb.deployment.ejbql.ASTNullComparisonExpression; 62 import org.objectweb.jonas_ejb.deployment.ejbql.ASTOrderByClause; 63 import org.objectweb.jonas_ejb.deployment.ejbql.ASTOrderByItem; 64 import org.objectweb.jonas_ejb.deployment.ejbql.ASTPath; 65 import org.objectweb.jonas_ejb.deployment.ejbql.ASTRangeVariableDeclaration; 66 import org.objectweb.jonas_ejb.deployment.ejbql.ASTSelectClause; 67 import org.objectweb.jonas_ejb.deployment.ejbql.ASTSelectExpression; 68 import org.objectweb.jonas_ejb.deployment.ejbql.ASTSingleValuedCmrPathExpression; 69 import org.objectweb.jonas_ejb.deployment.ejbql.ASTSingleValuedPathExpression; 70 import org.objectweb.jonas_ejb.deployment.ejbql.ASTStringExpression; 71 import org.objectweb.jonas_ejb.deployment.ejbql.ASTStringLiteral; 72 import org.objectweb.jonas_ejb.deployment.ejbql.ASTWhereClause; 73 import org.objectweb.jonas_ejb.deployment.ejbql.EJBQLVisitor; 74 import org.objectweb.jonas_ejb.deployment.ejbql.SimpleNode; 75 import org.objectweb.medor.query.api.QueryTree; 76 import org.objectweb.medor.query.jorm.lib.NavigatorNodeFactory; 77 78 import java.util.ArrayList ; 79 import java.util.Iterator ; 80 import java.util.Stack ; 81 import java.util.StringTokenizer ; 82 83 93 public class EjbqlAbstractVisitor implements EJBQLVisitor { 94 95 98 protected class IdValue { 99 102 private ArrayList paths = null; 103 104 107 private String [] name = null; 108 109 112 private QueryTree qt = null; 113 114 118 public IdValue(String pathName) { 119 this(); 120 name = splitPath(pathName); 121 } 122 123 126 public IdValue() { 127 paths = new ArrayList (); 128 } 129 130 133 public String [] getName() { 134 return name; 135 } 136 137 140 public void setName(String [] name) { 141 this.name = name; 142 } 143 144 148 public void addPath(String path) { 149 if (!paths.contains(path)) { 150 paths.add(path); 151 } 152 } 153 154 158 public String [] getSplitedPath(int idx) { 159 return splitPath((String ) paths.get(idx)); 160 } 161 162 166 public String getMergedPath(int idx) { 167 return (String ) paths.get(idx); 168 } 169 170 173 public int getDeclaredPathLength() { 174 return paths.size(); 175 } 176 177 180 public QueryTree getQueryTree() { 181 return qt; 182 } 183 184 187 public void setQueryTree(QueryTree qt) { 188 this.qt = qt; 189 } 190 191 194 public String toString() { 195 StringBuffer sb = new StringBuffer (); 196 sb = sb.append("(paths=["); 197 Iterator ip = paths.iterator(); 198 while (ip.hasNext()) { 199 sb = sb.append((String ) ip.next() + ","); 200 } 201 if (name == null) { 202 sb = sb.append("],name=null"); 203 } else { 204 sb = sb.append("],name="); 205 for (int i = 0; i < name.length; i++) { 206 sb = sb.append(name[i] + "."); 207 } 208 } 209 if (qt == null) { 210 sb = sb.append(",qt=null)"); 211 } else { 212 sb = sb.append(",qt!=null)"); 213 } 214 return sb.toString(); 215 } 216 } 217 218 221 protected class VisitorException extends RuntimeException { 222 223 Exception nestedException; 224 225 VisitorException(Exception nestedException) { 226 this.nestedException = nestedException; 227 } 228 229 Exception getNestedException() { 230 return nestedException; 231 } 232 } 233 234 239 protected String [] splitPath(String path) { 240 StringTokenizer st = new StringTokenizer (path, "."); 241 String [] ret = new String [st.countTokens()]; 242 for (int i = 0; i < ret.length; i++) { 243 ret[i] = st.nextToken(); 244 } 245 return ret; 246 } 247 248 254 protected String mergePath(String [] path, int begin, int length) { 255 if (length == 0) { 256 return ""; 257 } 258 StringBuffer ret = new StringBuffer (); 259 for (int i = begin; i < (begin + length); i++) { 260 ret.append(path[i]); 261 ret.append('.'); 262 } 263 ret.deleteCharAt(ret.length() - 1); 264 return ret.toString(); 265 } 266 267 271 protected String mergePath(String [] path) { 272 return (mergePath(path, 0, path.length)); 273 } 274 275 280 protected boolean endsWith(String [] path, String suffix) { 281 return (suffix.equals(path[path.length - 1])); 282 } 283 284 290 protected String [] basePath(String [] path) { 291 String [] base = new String [path.length - 1]; 292 for (int i = 0; i < path.length - 1; i++) { 293 base[i] = new String (path[i]); 294 } 295 return base; 296 } 297 298 305 public Object visit(SimpleNode node) throws Exception { 306 try { 307 return visit((SimpleNode) node, new Stack ()); 308 } catch (VisitorException e) { 309 throw e.getNestedException(); 310 } 311 } 312 313 319 public Object visit(SimpleNode node, Object data) { 320 return node.childrenAccept(this, data); 321 } 322 323 329 public Object visit(ASTEJBQL node, Object data) { 330 return null; 331 } 332 333 339 public Object visit(ASTFromClause node, Object data) { 340 return null; 341 } 342 343 349 public Object visit(ASTCollectionMemberDeclaration node, Object data) { 350 return null; 351 } 352 353 359 public Object visit(ASTRangeVariableDeclaration node, Object data) { 360 return null; 361 } 362 363 369 public Object visit(ASTSingleValuedPathExpression node, Object data) { 370 return null; 371 } 372 373 379 public Object visit(ASTCmpPathExpression node, Object data) { 380 return null; 381 } 382 383 389 public Object visit(ASTSingleValuedCmrPathExpression node, Object data) { 390 return null; 391 } 392 393 399 public Object visit(ASTCollectionValuedPathExpression node, Object data) { 400 return null; 401 } 402 403 409 public Object visit(ASTSelectClause node, Object data) { 410 return null; 411 } 412 413 419 public Object visit(ASTSelectExpression node, Object data) { 420 return null; 421 } 422 423 429 public Object visit(ASTAggregateSelectExpression node, Object data) { 430 return null; 431 } 432 433 439 public Object visit(ASTOrderByClause node, Object data) { 440 return null; 441 } 442 443 449 public Object visit(ASTOrderByItem node, Object data) { 450 return null; 451 } 452 453 459 public Object visit(ASTLimitClause node, Object data) { 460 return null; 461 } 462 463 469 public Object visit(ASTLimitExpression node, Object data) { 470 return null; 471 } 472 473 479 public Object visit(ASTWhereClause node, Object data) { 480 return null; 481 } 482 483 489 public Object visit(ASTConditionalExpression node, Object data) { 490 return null; 491 } 492 493 499 public Object visit(ASTConditionalTerm node, Object data) { 500 return null; 501 } 502 503 509 public Object visit(ASTConditionalFactor node, Object data) { 510 return null; 511 } 512 513 519 public Object visit(ASTBetweenExpression node, Object data) { 520 return null; 521 } 522 523 529 public Object visit(ASTInExpression node, Object data) { 530 return null; 531 } 532 533 539 public Object visit(ASTLikeExpression node, Object data) { 540 return null; 541 } 542 543 549 public Object visit(ASTNullComparisonExpression node, Object data) { 550 return null; 551 } 552 553 559 public Object visit(ASTEmptyCollectionComparisonExpression node, Object data) { 560 return null; 561 } 562 563 569 public Object visit(ASTCollectionMemberExpression node, Object data) { 570 return null; 571 } 572 573 579 public Object visit(ASTComparisonExpression node, Object data) { 580 return null; 581 } 582 583 589 public Object visit(ASTArithmeticExpression node, Object data) { 590 return null; 591 } 592 593 599 public Object visit(ASTIntegerLiteral node, Object data) { 600 return null; 601 } 602 603 609 public Object visit(ASTFloatingPointLiteral node, Object data) { 610 return null; 611 } 612 613 619 public Object visit(ASTArithmeticTerm node, Object data) { 620 return null; 621 } 622 623 629 public Object visit(ASTArithmeticFactor node, Object data) { 630 return null; 631 } 632 633 639 public Object visit(ASTStringExpression node, Object data) { 640 return null; 641 } 642 643 649 public Object visit(ASTDatetimeExpression node, Object data) { 650 return null; 651 } 652 653 659 public Object visit(ASTBooleanExpression node, Object data) { 660 return null; 661 } 662 663 669 public Object visit(ASTEntityBeanExpression node, Object data) { 670 return null; 671 } 672 673 679 public Object visit(ASTFunctionsReturningStrings node, Object data) { 680 return null; 681 } 682 683 689 public Object visit(ASTFunctionsReturningNumerics node, Object data) { 690 return null; 691 } 692 693 699 public Object visit(ASTAbstractSchemaName node, Object data) { 700 return null; 701 } 702 703 709 public Object visit(ASTIdentificationVariable node, Object data) { 710 return null; 711 } 712 713 719 public Object visit(ASTIdentifier node, Object data) { 720 return null; 721 } 722 723 729 public Object visit(ASTPath node, Object data) { 730 return null; 731 } 732 733 739 740 public Object visit(ASTLiteral node, Object data) { 741 return null; 742 } 743 744 750 public Object visit(ASTStringLiteral node, Object data) { 751 return null; 752 } 753 754 760 public Object visit(ASTArithmeticLiteral node, Object data) { 761 return null; 762 } 763 764 770 public Object visit(ASTBooleanLiteral node, Object data) { 771 return null; 772 } 773 774 780 public Object visit(ASTInputParameter node, Object data) { 781 return null; 782 } 783 } 784 | Popular Tags |