1 61 62 63 64 package org.jaxen.util; 65 66 import java.util.Iterator ; 67 import java.util.NoSuchElementException ; 68 69 import org.jaxen.JaxenConstants; 70 import org.jaxen.Navigator; 71 import org.jaxen.UnsupportedAxisException; 72 73 public class FollowingSiblingAxisIterator implements Iterator 74 { 75 private Object contextNode; 76 private Navigator navigator; 77 private Iterator siblingIter; 78 79 public FollowingSiblingAxisIterator(Object contextNode, 80 Navigator navigator) throws UnsupportedAxisException 81 { 82 this.contextNode = contextNode; 83 this.navigator = navigator; 84 init(); 85 } 86 87 private void init() throws UnsupportedAxisException 88 { 89 Object parent = this.navigator.getParentNode( this.contextNode ); 90 91 if ( parent != null ) 92 { 93 siblingIter = this.navigator.getChildAxisIterator( parent ); 94 95 while ( siblingIter.hasNext() ) 96 { 97 Object eachChild = siblingIter.next(); 98 if ( eachChild.equals(this.contextNode) ) break; 99 } 100 } 101 else { 102 siblingIter = JaxenConstants.EMPTY_ITERATOR; 103 } 104 105 } 106 107 public boolean hasNext() 108 { 109 return siblingIter.hasNext(); 110 } 111 112 public Object next() throws NoSuchElementException 113 { 114 return siblingIter.next(); 115 } 116 117 public void remove() throws UnsupportedOperationException 118 { 119 throw new UnsupportedOperationException (); 120 } 121 122 } 123 | Popular Tags |