1 22 23 package org.xquark.mediator.algebra; 24 25 import java.util.ArrayList ; 26 27 import org.xquark.mediator.decomposer.VariableDependencies; 28 import org.xquark.mediator.plan.*; 29 import org.xquark.mediator.runtime.MediatorException; 30 import org.xquark.xquery.parser.*; 31 32 public class AlgLocated extends Algebra { 33 private static final String RCSRevision = "$Revision: 1.6 $"; 37 private static final String RCSName = "$Name: $"; 38 39 43 47 54 public AlgLocated(LocatedExpression expression, Variable addvar, Variable var, AlgebraManager depmanager, boolean islet) { 55 super(expression, var, depmanager, islet); 56 this.addDependSourceVariable(addvar); 57 58 } 59 60 64 public void ParentHasIdentifier() { 65 hasIdentifier = true; 66 } 67 68 72 77 public Operator createOperator(ExecutionPlan plan) throws MediatorException { 78 Variable var = (Variable) variables.get(0); 79 Operator algebra = new OpNotSource(plan, this); 81 82 if (parent != null && parent instanceof AlgFLWR) { 83 AlgFLWR parentdep = (AlgFLWR)parent; 84 VariableDependencies vardepend = parentdep.getVarDependencies(); 85 ArrayList tmplist = null; 86 if (vardepend != null) { 87 ArrayList conds = vardepend.getAllComplexConditionsWithVar(var); 89 if (conds != null) 90 for (int i=0;i<conds.size();i++) { 91 ArrayList vars = vardepend.getVarsOfCond((XQueryExpression)conds.get(i)); 92 if (algManager.getScopeVariables().containsAll(vars)) { 93 if (tmplist == null) 94 tmplist = new ArrayList (); 95 tmplist.add(conds.get(i)); 96 } 97 } 98 } 99 if (tmplist != null) { 100 XQueryExpression tmpexpr = null; 101 if (tmplist.size() == 1) { 102 tmpexpr = (XQueryExpression)tmplist.get(0); 103 } 104 else { 105 try { 106 tmpexpr = new BinOpANDExpression((XQueryExpression) tmplist.get(0), (XQueryExpression) tmplist.get(1), expression.getParentModule()); 107 for (int i = 2; i < tmplist.size(); i++) 108 tmpexpr = new BinOpANDExpression(tmpexpr, (XQueryExpression) tmplist.get(i), expression.getParentModule()); 109 } catch (XQueryException e) { 110 throw new MediatorException("Could not build where clause", e); 111 } 112 } 113 algebra = new OpRestrict(plan,tmpexpr,algebra); 114 } 115 } 116 return algebra; 117 118 119 } 123 124 public Object clone() throws CloneNotSupportedException { 125 AlgLocated newobj = (AlgLocated) super.clone(); 126 127 return newobj; 128 } 129 130 public void execute(ExecutionPlan plan) throws MediatorException {} 131 132 136 } 137 | Popular Tags |