public Iterator getPrecedingSiblingAxisIterator(Object contextNode) throws UnsupportedAxisException { return new PrecedingSiblingAxisIterator( contextNode, this ); }
/** * Create a new <code>preceding-sibling</code> axis iterator. * * @param contextNode the node to start from * @param navigator the object model specific navigator */ public PrecedingSiblingAxisIterator(Object contextNode, Navigator navigator) throws UnsupportedAxisException { this.contextNode = contextNode; this.navigator = navigator; init(); if ( siblingIter.hasNext() ) { this.nextObj = siblingIter.next(); } }
/** * Returns the next preceding sibling. * * @return the next preceding sibling * * @throws NoSuchElementException if no preceding siblings remain * * @see java.util.Iterator#next() */ public Object next() throws NoSuchElementException { if ( ! hasNext() ) { throw new NoSuchElementException(); } Object obj = this.nextObj; if ( siblingIter.hasNext() ) { this.nextObj = siblingIter.next(); } else { this.nextObj = null; } return obj; }
precedingSibling = new PrecedingSiblingAxisIterator(contextNode, navigator);
@Override public Iterator<?> getPrecedingSiblingAxisIterator(final Object contextNode) throws UnsupportedAxisException { return new PrecedingSiblingAxisIterator(contextNode, this); }