1 22 23 package org.xquark.mediator.plan; 24 25 import java.util.ArrayList ; 26 27 import org.apache.commons.logging.Log; 28 import org.apache.commons.logging.LogFactory; 29 import org.xquark.mediator.decomposer.Utils; 30 import org.xquark.mediator.runtime.MediatorException; 31 import org.xquark.xml.xdbc.XMLResultSet; 32 import org.xquark.xml.xqueryevaluator.eval.EvalFilter; 33 import org.xquark.xquery.parser.FLWRExpression; 34 import org.xquark.xquery.parser.XQueryExpression; 35 36 public class OpSourceEval extends ZeroOp { 37 private static final String RCSRevision = "$Revision: 1.11 $"; 41 private static final String RCSName = "$Name: $"; 42 43 49 55 public OpSourceEval(ExecutionPlan plan, XQueryExpression expression, ArrayList origpaths, boolean hasIdentifier) throws MediatorException { 56 super(plan, expression); 57 58 try { 59 for (int i = 0; i < origpaths.size(); i++) { 60 addPath((XQueryExpression) ((XQueryExpression) origpaths.get(i)).clone()); 61 } 62 } catch (CloneNotSupportedException cnse) { 63 } 64 this.size = this.getPaths().size(); 66 if (hasIdentifier) 67 this.idsize = 1; 68 } 69 70 74 public void accept(OperatorVisitor visitor) throws MediatorException { 75 visitor.visit(this); 76 } 77 78 84 protected ResultSet getResultSet(DynamicContext context) throws MediatorException { 85 return new SourceEvalResultSet(this, context); 86 } 87 88 94 public ArrayList getSources() { 95 return null; 96 } 97 98 public String toCompleteString(int indent) { 99 StringBuffer buf = new StringBuffer (); 100 buf.append(Utils.makeIndent(indent) + "<" + getClass().getName() + " size=" + size + " id size=" + idsize + " isLet=\"" + islet + "\" valueDepends=\"" + valueDepends + "\" whereDepends=\"" + whereDepends + "\">\n"); 101 buf.append(Utils.makeIndent(indent + 1) + "<Expression>\n"); 102 buf.append(Utils.makeIndent(indent + 2) + expression + "\n"); 103 buf.append(Utils.makeIndent(indent + 1) + "</Expression>\n"); 104 if (paths != null) { 113 buf.append(Utils.makeIndent(indent + 1) + "<Paths>\n"); 114 for (int i = 0; i < paths.size(); i++) { 115 buf.append(Utils.makeIndent(indent + 2) + "<Path>" + paths.get(i) + "</Path>\n"); 116 } 117 buf.append(Utils.makeIndent(indent + 1) + "</Paths>\n"); 118 } 119 buf.append(Utils.makeIndent(indent) + "</" + getClass().getName() + ">\n"); 120 return buf.toString(); 121 } 122 123 } 124 125 class SourceEvalResultSet extends ZeroResultSet { 126 private static final String RCSRevision = "$Revision: 1.11 $"; 130 private static final String RCSName = "$Name: $"; 131 132 private static Log log = LogFactory.getLog(SourceEvalResultSet.class); 133 134 private XMLResultSet resultset = null; 138 private EvalFilter evalFilter; 139 140 146 public SourceEvalResultSet(OpSourceEval operator, DynamicContext context) throws MediatorException { 147 super(operator, context); 148 if (log.isDebugEnabled()) 149 log.debug("MEMORY EXECUTING \n" + expression.getStringValue()); 150 evalFilter = new EvalFilter(this.buftuples, context, this.paths, (FLWRExpression) this.expression); 151 } 152 153 161 protected void evaluate(boolean non_blocking) throws MediatorException { 163 boolean isDone = false; 164 isDone = evalFilter.evaluate(); 165 if (isDone) 166 setFinishedWhenEmpty(); 167 } 168 169 } 170 | Popular Tags |