1 16 19 package com.sun.org.apache.xpath.internal.axes; 20 21 import com.sun.org.apache.xml.internal.dtm.DTM; 22 import com.sun.org.apache.xml.internal.dtm.DTMFilter; 23 import com.sun.org.apache.xml.internal.dtm.DTMIterator; 24 import com.sun.org.apache.xml.internal.utils.PrefixResolver; 25 import com.sun.org.apache.xpath.internal.compiler.Compiler; 26 27 32 public abstract class BasicTestIterator extends LocPathIterator 33 { 34 40 protected BasicTestIterator() 41 { 42 } 43 44 45 51 protected BasicTestIterator(PrefixResolver nscontext) 52 { 53 54 super(nscontext); 55 } 56 57 69 protected BasicTestIterator(Compiler compiler, int opPos, int analysis) 70 throws javax.xml.transform.TransformerException 71 { 72 super(compiler, opPos, analysis, false); 73 74 int firstStepPos = compiler.getFirstChildPos(opPos); 75 int whatToShow = compiler.getWhatToShow(firstStepPos); 76 77 if ((0 == (whatToShow 78 & (DTMFilter.SHOW_ATTRIBUTE 79 | DTMFilter.SHOW_NAMESPACE 80 | DTMFilter.SHOW_ELEMENT 81 | DTMFilter.SHOW_PROCESSING_INSTRUCTION))) 82 || (whatToShow == DTMFilter.SHOW_ALL)) 83 initNodeTest(whatToShow); 84 else 85 { 86 initNodeTest(whatToShow, compiler.getStepNS(firstStepPos), 87 compiler.getStepLocalName(firstStepPos)); 88 } 89 initPredicateInfo(compiler, firstStepPos); 90 } 91 92 107 protected BasicTestIterator( 108 Compiler compiler, int opPos, int analysis, boolean shouldLoadWalkers) 109 throws javax.xml.transform.TransformerException 110 { 111 super(compiler, opPos, analysis, shouldLoadWalkers); 112 } 113 114 115 119 protected abstract int getNextNode(); 120 121 129 public int nextNode() 130 { 131 if(m_foundLast) 132 { 133 m_lastFetched = DTM.NULL; 134 return DTM.NULL; 135 } 136 137 if(DTM.NULL == m_lastFetched) 138 { 139 resetProximityPositions(); 140 } 141 142 int next; 143 144 com.sun.org.apache.xpath.internal.VariableStack vars; 145 int savedStart; 146 if (-1 != m_stackFrame) 147 { 148 vars = m_execContext.getVarStack(); 149 150 savedStart = vars.getStackFrame(); 152 153 vars.setStackFrame(m_stackFrame); 154 } 155 else 156 { 157 vars = null; 159 savedStart = 0; 160 } 161 162 try 163 { 164 do 165 { 166 next = getNextNode(); 167 168 if (DTM.NULL != next) 169 { 170 if(DTMIterator.FILTER_ACCEPT == acceptNode(next)) 171 break; 172 else 173 continue; 174 } 175 else 176 break; 177 } 178 while (next != DTM.NULL); 179 180 if (DTM.NULL != next) 181 { 182 m_pos++; 183 return next; 184 } 185 else 186 { 187 m_foundLast = true; 188 189 return DTM.NULL; 190 } 191 } 192 finally 193 { 194 if (-1 != m_stackFrame) 195 { 196 vars.setStackFrame(savedStart); 198 } 199 } 200 } 201 202 210 public DTMIterator cloneWithReset() throws CloneNotSupportedException 211 { 212 213 ChildTestIterator clone = (ChildTestIterator) super.cloneWithReset(); 214 215 clone.resetProximityPositions(); 216 217 return clone; 218 } 219 220 221 } 222 223 | Popular Tags |