1 22 23 package org.xquark.mediator.algebra; 24 25 import java.util.ArrayList ; 26 27 import org.xquark.mediator.decomposer.GetUsedVariablesVisitor; 28 import org.xquark.mediator.decomposer.IsolateWhereVisitor; 29 import org.xquark.mediator.plan.ExecutionPlan; 30 import org.xquark.mediator.plan.OpEval; 31 import org.xquark.mediator.plan.Operator; 32 import org.xquark.mediator.runtime.MediatorException; 33 import org.xquark.xquery.parser.Variable; 34 import org.xquark.xquery.parser.XQueryException; 35 import org.xquark.xquery.parser.XQueryExpression; 36 37 42 public class AlgEval extends Algebra { 43 private static final String RCSRevision = "$Revision: 1.5 $"; 47 private static final String RCSName = "$Name: $"; 48 49 private XQueryExpression condition = null; 50 60 public AlgEval(XQueryExpression expression, Variable var, AlgebraManager depmanager, boolean islet) throws MediatorException { 61 super(expression, var, depmanager, islet) ; 62 if (var != null && var.getParentFLWRExpression().getWhereClause() != null) { 64 ArrayList tmplist = new ArrayList (1); 65 tmplist.add(var); 66 IsolateWhereVisitor isolateVisitor = new IsolateWhereVisitor(tmplist); 67 try { 68 var.getParentFLWRExpression().getWhereClause().accept(isolateVisitor); 69 } catch (XQueryException xqe) { 70 throw new MediatorException(xqe.getMessage()); 71 } 72 condition = isolateVisitor.getIsolatedExpression(); 73 if (condition != null) 74 var.getParentFLWRExpression().setWhereClause(isolateVisitor.getRemainingExpression()); 75 } 76 GetUsedVariablesVisitor guvv = new GetUsedVariablesVisitor(); 78 try { 79 expression.accept(guvv); 80 } catch (XQueryException xqe){ 81 } 82 addDependSourceVariables(guvv.getVariables()); 83 if (depmanager.getIdVars().contains(var)) this.hasIdentifier = true; 85 } 86 87 91 public void ParentHasIdentifier() { 92 hasIdentifier = true; 93 } 94 95 103 public Operator createOperator(ExecutionPlan plan) throws MediatorException { 104 Operator operator = new OpEval(plan, this, condition, hasIdentifier) ; 106 operator.isLet(islet); 107 return operator ; 108 } 109 110 114 public ArrayList getVarsThatDepend() throws MediatorException { 115 return new ArrayList () ; 116 } 117 118 public Object clone() throws CloneNotSupportedException { 119 AlgEval newobj = (AlgEval)super.clone(); 120 return newobj; 121 } 122 123 public void execute(ExecutionPlan plan) throws MediatorException { 124 } 125 126 130 } 131 | Popular Tags |