View Javadoc
1 /* 2 * $Header: /cvsroot/ebxmlrr/ebxmlrr/src/share/com/sun/ebxml/registry/query/filter/BranchProcessor.java,v 1.5 2002/03/25 04:06:45 nstojano Exp $ 3 */ 4 5 package com.sun.ebxml.registry.query.filter; 6 7 import com.sun.ebxml.registry.*; 8 9 import org.oasis.ebxml.registry.bindings.query.*; 10 import org.oasis.ebxml.registry.bindings.rs.*; 11 12 /*** 13 * Class Declaration for BranchProcessor 14 * @see 15 * @author Nikola Stojanovic 16 */ 17 public abstract class BranchProcessor implements SQLConverter { 18 19 abstract protected void setNativeBranch(Object branch); 20 abstract protected String getName(); 21 abstract protected void buildFilterClauses() throws RegistryException; 22 abstract protected void buildQueryClauses() throws RegistryException; 23 abstract protected void buildBranchClauses() throws RegistryException; 24 25 FilterProcessor filterProcessor = new FilterProcessor(); 26 protected String sqlQuery = null; 27 protected String whereClause = null; 28 29 /* There is no inheritance tree for Branches so nativeBranch's role is to polymorphicaly represent any branch */ 30 protected Object nativeBranch = null; 31 private String selectColumn = null; 32 private ClauseHandler clauseHandler = new ClauseHandler(); 33 private ClauseType sqlClause = new ClauseType(); 34 35 36 public void setParentJoinColumn(String parJoinColumn) { 37 38 sqlClause.parentJoinColumn = parJoinColumn; 39 } 40 41 42 public void setSelectColumn(String selColumn) { 43 44 selectColumn = selColumn; 45 } 46 47 48 /*** 49 * Convert the specified Object obj to an equivalent SQL query string. 50 */ 51 public String convertToSQL(Object obj) throws RegistryException { 52 53 setNativeBranch(obj); 54 setMainSelect(); 55 buildWhereClause(); 56 57 if (whereClause != null) { 58 sqlQuery = sqlQuery + " WHERE " + whereClause; 59 } 60 61 return sqlQuery; 62 } 63 64 65 public String addWhereClause(String whereClause, Object branch) throws RegistryException { 66 67 sqlClause.isReverseSelectNeeded = false; 68 sqlClause.isSubSelectNeeded = true; 69 /* order of next two calls important because of side effcts in the first one -> refactor 70 for now use logic of "SOME", not "ALL/NONE" -> isReverseSelectNeeded not active */ 71 sqlClause.clause = convertToSQL(branch); 72 // sqlClause.isReverseSelectNeeded = filterProcessor.isReverseSelectNeeded(); 73 return clauseHandler.addWhereClause(whereClause, sqlClause); 74 } 75 76 77 private void setMainSelect() { 78 79 sqlQuery = "SELECT " + selectColumn + " FROM " + getName(); 80 } 81 82 83 private void buildWhereClause() throws RegistryException { 84 85 buildFilterClauses(); 86 buildQueryClauses(); 87 buildBranchClauses(); 88 } 89 }

This page was automatically generated by Maven