1 package org.jaxen.util; 2 3 63 64 import java.util.Iterator ; 65 import java.util.NoSuchElementException ; 66 67 import org.jaxen.Navigator; 68 import org.jaxen.UnsupportedAxisException; 69 import org.jaxen.JaxenRuntimeException; 70 71 public class AncestorOrSelfAxisIterator implements Iterator 72 { 73 private Object contextNode; 74 private Navigator navigator; 75 76 public AncestorOrSelfAxisIterator(Object contextNode, 77 Navigator navigator) 78 { 79 this.contextNode = contextNode; 81 this.navigator = navigator; 82 } 83 84 public boolean hasNext() 85 { 86 return contextNode != null; 87 } 88 89 public Object next() 90 { 91 try 92 { 93 if (hasNext()) { 94 Object result = contextNode; 95 contextNode = navigator.getParentNode(contextNode); 96 return result; 97 } 98 throw new NoSuchElementException (); } 100 catch (UnsupportedAxisException e) 101 { 102 throw new JaxenRuntimeException(e); 103 } 104 } 105 106 public void remove() 107 { 108 throw new UnsupportedOperationException (); 109 } 110 } 111 | Popular Tags |