1 16 19 package org.apache.xpath.axes; 20 21 import org.apache.xml.dtm.DTMIterator; 22 import org.apache.xpath.XPathContext; 23 import org.apache.xpath.objects.XObject; 24 import org.apache.xpath.patterns.NodeTest; 25 26 31 public class UnionChildIterator extends ChildTestIterator 32 { 33 39 private PredicatedNodeTest[] m_nodeTests = null; 40 41 44 public UnionChildIterator() 45 { 46 super(null); 47 } 48 49 57 public void addNodeTest(PredicatedNodeTest test) 58 { 59 60 if (null == m_nodeTests) 63 { 64 m_nodeTests = new PredicatedNodeTest[1]; 65 m_nodeTests[0] = test; 66 } 67 else 68 { 69 PredicatedNodeTest[] tests = m_nodeTests; 70 int len = m_nodeTests.length; 71 72 m_nodeTests = new PredicatedNodeTest[len + 1]; 73 74 System.arraycopy(tests, 0, m_nodeTests, 0, len); 75 76 m_nodeTests[len] = test; 77 } 78 test.exprSetParent(this); 79 } 80 81 91 public void fixupVariables(java.util.Vector vars, int globalsSize) 92 { 93 super.fixupVariables(vars, globalsSize); 94 if (m_nodeTests != null) { 95 for (int i = 0; i < m_nodeTests.length; i++) { 96 m_nodeTests[i].fixupVariables(vars, globalsSize); 97 } 98 } 99 } 100 101 110 public short acceptNode(int n) 111 { 112 XPathContext xctxt = getXPathContext(); 113 try 114 { 115 xctxt.pushCurrentNode(n); 116 for (int i = 0; i < m_nodeTests.length; i++) 117 { 118 PredicatedNodeTest pnt = m_nodeTests[i]; 119 XObject score = pnt.execute(xctxt, n); 120 if (score != NodeTest.SCORE_NONE) 121 { 122 if (pnt.getPredicateCount() > 0) 124 { 125 if (pnt.executePredicates(n, xctxt)) 126 return DTMIterator.FILTER_ACCEPT; 127 } 128 else 129 return DTMIterator.FILTER_ACCEPT; 130 131 } 132 } 133 } 134 catch (javax.xml.transform.TransformerException se) 135 { 136 137 throw new RuntimeException (se.getMessage()); 139 } 140 finally 141 { 142 xctxt.popCurrentNode(); 143 } 144 return DTMIterator.FILTER_SKIP; 145 } 146 147 } 148 | Popular Tags |