1 16 19 package org.apache.xpath.axes; 20 21 import org.apache.xml.dtm.DTM; 22 import org.apache.xpath.Expression; 23 import org.apache.xpath.ExpressionOwner; 24 import org.apache.xpath.XPathVisitor; 25 import org.apache.xpath.objects.XNodeSet; 26 27 public class FilterExprIterator extends BasicTestIterator 28 { 29 31 private Expression m_expr; 32 33 34 transient private XNodeSet m_exprObj; 35 36 private boolean m_mustHardReset = false; 37 private boolean m_canDetachNodeset = true; 38 39 46 public FilterExprIterator() 47 { 48 super(null); 49 } 50 51 58 public FilterExprIterator(Expression expr) 59 { 60 super(null); 61 m_expr = expr; 62 } 63 64 71 public void setRoot(int context, Object environment) 72 { 73 super.setRoot(context, environment); 74 75 m_exprObj = FilterExprIteratorSimple.executeFilterExpr(context, 76 m_execContext, getPrefixResolver(), 77 getIsTopLevel(), m_stackFrame, m_expr); 78 } 79 80 81 85 protected int getNextNode() 86 { 87 if (null != m_exprObj) 88 { 89 m_lastFetched = m_exprObj.nextNode(); 90 } 91 else 92 m_lastFetched = DTM.NULL; 93 94 return m_lastFetched; 95 } 96 97 102 public void detach() 103 { 104 super.detach(); 105 m_exprObj.detach(); 106 m_exprObj = null; 107 } 108 109 119 public void fixupVariables(java.util.Vector vars, int globalsSize) 120 { 121 super.fixupVariables(vars, globalsSize); 122 m_expr.fixupVariables(vars, globalsSize); 123 } 124 125 128 public Expression getInnerExpression() 129 { 130 return m_expr; 131 } 132 133 136 public void setInnerExpression(Expression expr) 137 { 138 expr.exprSetParent(this); 139 m_expr = expr; 140 } 141 142 146 public int getAnalysisBits() 147 { 148 if (null != m_expr && m_expr instanceof PathComponent) 149 { 150 return ((PathComponent) m_expr).getAnalysisBits(); 151 } 152 return WalkerFactory.BIT_FILTER; 153 } 154 155 162 public boolean isDocOrdered() 163 { 164 return m_exprObj.isDocOrdered(); 165 } 166 167 class filterExprOwner implements ExpressionOwner 168 { 169 172 public Expression getExpression() 173 { 174 return m_expr; 175 } 176 177 180 public void setExpression(Expression exp) 181 { 182 exp.exprSetParent(FilterExprIterator.this); 183 m_expr = exp; 184 } 185 186 } 187 188 197 public void callPredicateVisitors(XPathVisitor visitor) 198 { 199 m_expr.callVisitors(new filterExprOwner(), visitor); 200 201 super.callPredicateVisitors(visitor); 202 } 203 204 207 public boolean deepEquals(Expression expr) 208 { 209 if (!super.deepEquals(expr)) 210 return false; 211 212 FilterExprIterator fet = (FilterExprIterator) expr; 213 if (!m_expr.deepEquals(fet.m_expr)) 214 return false; 215 216 return true; 217 } 218 219 } 220 | Popular Tags |