1 16 19 package org.apache.xml.dtm.ref; 20 21 import org.apache.xml.dtm.DTM; 22 import org.apache.xml.dtm.DTMDOMException; 23 import org.apache.xml.dtm.DTMIterator; 24 25 import org.w3c.dom.DOMException ; 26 import org.w3c.dom.Node ; 27 import org.w3c.dom.traversal.NodeFilter; 28 29 57 public class DTMNodeIterator implements org.w3c.dom.traversal.NodeIterator 58 { 59 private DTMIterator dtm_iter; 60 private boolean valid=true; 61 62 65 68 public DTMNodeIterator(DTMIterator dtmIterator) 69 { 70 try 71 { 72 dtm_iter=(DTMIterator)dtmIterator.clone(); 73 } 74 catch(CloneNotSupportedException cnse) 75 { 76 throw new org.apache.xml.utils.WrappedRuntimeException(cnse); 77 } 78 } 79 80 83 public DTMIterator getDTMIterator() 84 { 85 return dtm_iter; 86 } 87 88 89 92 96 public void detach() 97 { 98 valid=false; 102 } 103 104 109 public boolean getExpandEntityReferences() 110 { 111 return false; 112 } 113 114 126 public NodeFilter getFilter() 127 { 128 throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); 129 } 130 131 132 135 public Node getRoot() 136 { 137 int handle=dtm_iter.getRoot(); 138 return dtm_iter.getDTM(handle).getNode(handle); 139 } 140 141 142 145 public int getWhatToShow() 146 { 147 return dtm_iter.getWhatToShow(); 148 } 149 150 156 public Node nextNode() throws DOMException 157 { 158 if(!valid) 159 throw new DTMDOMException(DOMException.INVALID_STATE_ERR); 160 161 int handle=dtm_iter.nextNode(); 162 if (handle==DTM.NULL) 163 return null; 164 return dtm_iter.getDTM(handle).getNode(handle); 165 } 166 167 168 174 public Node previousNode() 175 { 176 if(!valid) 177 throw new DTMDOMException(DOMException.INVALID_STATE_ERR); 178 179 int handle=dtm_iter.previousNode(); 180 if (handle==DTM.NULL) 181 return null; 182 return dtm_iter.getDTM(handle).getNode(handle); 183 } 184 } 185 | Popular Tags |