1 16 19 package org.apache.xml.dtm.ref; 20 21 import org.apache.xml.dtm.DTM; 22 import org.apache.xml.dtm.DTMIterator; 23 import org.w3c.dom.Node ; 24 25 54 public class DTMNodeList extends DTMNodeListBase { 55 private DTMIterator m_iter; 56 57 private DTMNodeList() { 60 } 61 62 70 public DTMNodeList(DTMIterator dtmIterator) { 71 if (dtmIterator != null) { 72 int pos = dtmIterator.getCurrentPos(); 73 try { 74 m_iter=(DTMIterator)dtmIterator.cloneWithReset(); 75 } catch(CloneNotSupportedException cnse) { 76 m_iter = dtmIterator; 77 } 78 m_iter.setShouldCacheNodes(true); 79 m_iter.runTo(-1); 80 m_iter.setCurrentPos(pos); 81 } 82 } 83 84 89 public DTMIterator getDTMIterator() { 90 return m_iter; 91 } 92 93 96 105 public Node item(int index) 106 { 107 if (m_iter != null) { 108 int handle=m_iter.item(index); 109 if (handle == DTM.NULL) { 110 return null; 111 } 112 return m_iter.getDTM(handle).getNode(handle); 113 } else { 114 return null; 115 } 116 } 117 118 122 public int getLength() { 123 return (m_iter != null) ? m_iter.getLength() : 0; 124 } 125 } 126 | Popular Tags |