1 23 24 package org.xquark.mediator.decomposer; 25 26 import java.util.ArrayList ; 27 import java.util.HashMap ; 28 29 import org.xquark.mediator.runtime.MediatorException; 30 import org.xquark.xquery.parser.Variable; 31 import org.xquark.xquery.parser.XQueryException; 32 import org.xquark.xquery.parser.XQueryExpression; 33 34 public class VariableDependencies { 35 private static final String RCSRevision = "$Revision: 1.5 $"; 39 private static final String RCSName = "$Name: $"; 40 private HashMap varSimpleConditionsMap = null; 46 private HashMap varJoinConditionsMap = null; 48 private HashMap varComplexConditionsMap = null; 50 private HashMap varAllConditionsMap = null; 52 private HashMap varAssociatedVariablesMap = null; private HashMap condAssociatedVariablesMap = null; private ArrayList allSimpleConditionsList = null; 58 private ArrayList allJoinConditionsList = null; 60 private ArrayList allComplexConditionsList = null; 62 private ArrayList allConditionsList = null; 64 private ArrayList allNoVariablesConditionsList = null; 66 AtomizeWhereVisitor awvisitor = new AtomizeWhereVisitor(); 68 72 public VariableDependencies(XQueryExpression expr) throws MediatorException { 73 try { 74 expr.accept(awvisitor); 75 } catch (XQueryException e) { 76 throw new MediatorException("Could not atomize where clause : " + expr, e); 77 } 78 varSimpleConditionsMap = awvisitor.getVarSimpleConditionsMap(); 79 varJoinConditionsMap = awvisitor.getVarJoinConditionsMap(); 80 varComplexConditionsMap = awvisitor.getVarComplexConditionsMap(); 81 varAllConditionsMap = awvisitor.getVarAllConditionsMap(); 82 varAssociatedVariablesMap = awvisitor.getVarAssociatedVariablesMap(); 83 condAssociatedVariablesMap = awvisitor.getCondAssociatedVariablesMap(); 84 allNoVariablesConditionsList = awvisitor.getAllNoVariablesConditionsList(); 85 allSimpleConditionsList = awvisitor.getAllSimpleConditionsList(); 86 allJoinConditionsList = awvisitor.getAllJoinConditionsList(); 87 allComplexConditionsList = awvisitor.getAllComplexConditionsList(); 88 allConditionsList = awvisitor.getAllConditionsList(); 89 } 90 91 public ArrayList getAllAssociatedVariables (Variable var) { 93 return (ArrayList )varAssociatedVariablesMap.get(var); 94 } 95 public HashMap getJoinMap(Variable var) { 96 return (HashMap )varJoinConditionsMap.get(var); 97 } 98 public boolean hasJoins() { 99 if (allJoinConditionsList.isEmpty()) return false; 100 return true; 101 } 102 public HashMap getJoinsMap() { 103 return varJoinConditionsMap; 104 } 105 public ArrayList getAllComplexConditionsWithVar(Variable var) { 109 return (ArrayList )varComplexConditionsMap.get(var); 110 } 111 public ArrayList getVarsOfCond(XQueryExpression expr) { 112 return (ArrayList )condAssociatedVariablesMap.get(expr); 113 } 114 public String toString() { 116 StringBuffer sb = new StringBuffer (); 117 sb.append("varSimpleConditionsMap : "); 118 sb.append(varSimpleConditionsMap); 119 sb.append("\nvarJoinConditionsMap : "); 120 sb.append(varJoinConditionsMap); 121 sb.append("\nvarComplexConditionsMap : "); 122 sb.append(varComplexConditionsMap); 123 sb.append("\nvarAllConditionsMap : "); 124 sb.append(varAllConditionsMap); 125 sb.append("\nvarAssociatedVariablesMap : "); 126 sb.append(varAssociatedVariablesMap); 127 sb.append("\ncondAssociatedVariablesMap : "); 128 sb.append(condAssociatedVariablesMap); 129 sb.append("\nallNoVariablesConditionsList : "); 130 sb.append(allNoVariablesConditionsList); 131 sb.append("\nallSimpleConditionsList : "); 132 sb.append(allSimpleConditionsList); 133 sb.append("\nallJoinConditionsList : "); 134 sb.append(allJoinConditionsList); 135 sb.append("\nallComplexConditionsList : "); 136 sb.append(allComplexConditionsList); 137 sb.append("\nallConditionsList : "); 138 sb.append(allConditionsList); 139 return sb.toString(); 140 } 141 142 } 143 | Popular Tags |