/** * Checks whether the wrapped Iteration contains more elements, closing this Iteration when this is not * the case. * * @return <tt>true</tt> if the wrapped Iteration contains more elements, <tt>false</tt> otherwise. */ public boolean hasNext() throws X { if (isClosed()) { return false; } else if (Thread.currentThread().isInterrupted()) { close(); return false; } boolean result = wrappedIter.hasNext(); if (!result) { close(); } return result; }
/** * Returns the next element from the wrapped Iteration. * * @throws java.util.NoSuchElementException * If all elements have been returned or it has been closed. */ public E next() throws X { if (isClosed()) { throw new NoSuchElementException("The iteration has been closed."); } else if (Thread.currentThread().isInterrupted()) { close(); throw new NoSuchElementException("The iteration has been interrupted."); } try { return wrappedIter.next(); } catch(NoSuchElementException e) { close(); throw e; } }
/** * Returns the next element from the wrapped Iteration. * * @throws java.util.NoSuchElementException * If all elements have been returned or it has been closed. */ public E next() throws X { if (isClosed()) { throw new NoSuchElementException("The iteration has been closed."); } else if (Thread.currentThread().isInterrupted()) { close(); throw new NoSuchElementException("The iteration has been interrupted."); } try { return wrappedIter.next(); } catch(NoSuchElementException e) { close(); throw e; } }
/** * Removes the last element that has been returned from the wrapped Iteration. * * @throws UnsupportedOperationException * If the wrapped Iteration does not support the <tt>remove</tt> operation. * @throws IllegalStateException * if the Iteration has been closed, or if {@link #next} has not yet been called, or * {@link #remove} has already been called after the last call to {@link #next}. */ @Override public void remove() throws X { if (isClosed()) { throw new IllegalStateException("The iteration has been closed."); } else if (Thread.currentThread().isInterrupted()) { close(); throw new IllegalStateException("The iteration has been interrupted."); } try { wrappedIter.remove(); } catch(IllegalStateException e) { close(); throw e; } }
/** * Returns the next element from the wrapped Iteration. * * @throws java.util.NoSuchElementException * If all elements have been returned or it has been closed. */ @Override public E next() throws X { if (isClosed()) { throw new NoSuchElementException("The iteration has been closed."); } else if (Thread.currentThread().isInterrupted()) { close(); throw new NoSuchElementException("The iteration has been interrupted."); } try { return wrappedIter.next(); } catch(NoSuchElementException e) { close(); throw e; } }
/** * Checks whether the wrapped Iteration contains more elements, closing this Iteration when this is not * the case. * * @return <tt>true</tt> if the wrapped Iteration contains more elements, <tt>false</tt> otherwise. */ public boolean hasNext() throws X { if (isClosed()) { return false; } else if (Thread.currentThread().isInterrupted()) { close(); return false; } boolean result = wrappedIter.hasNext(); if (!result) { close(); } return result; }
/** * Checks whether the wrapped Iteration contains more elements, closing this Iteration when this is not * the case. * * @return <tt>true</tt> if the wrapped Iteration contains more elements, <tt>false</tt> otherwise. */ @Override public boolean hasNext() throws X { if (isClosed()) { return false; } else if (Thread.currentThread().isInterrupted()) { close(); return false; } boolean result = wrappedIter.hasNext(); if (!result) { close(); } return result; }
/** * Removes the last element that has been returned from the wrapped Iteration. * * @throws UnsupportedOperationException * If the wrapped Iteration does not support the <tt>remove</tt> operation. * @throws IllegalStateException * if the Iteration has been closed, or if {@link #next} has not yet been called, or * {@link #remove} has already been called after the last call to {@link #next}. */ public void remove() throws X { if (isClosed()) { throw new IllegalStateException("The iteration has been closed."); } else if (Thread.currentThread().isInterrupted()) { close(); throw new IllegalStateException("The iteration has been interrupted."); } try { wrappedIter.remove(); } catch(IllegalStateException e) { close(); throw e; } }
/** * Removes the last element that has been returned from the wrapped Iteration. * * @throws UnsupportedOperationException * If the wrapped Iteration does not support the <tt>remove</tt> operation. * @throws IllegalStateException * if the Iteration has been closed, or if {@link #next} has not yet been called, or * {@link #remove} has already been called after the last call to {@link #next}. */ public void remove() throws X { if (isClosed()) { throw new IllegalStateException("The iteration has been closed."); } else if (Thread.currentThread().isInterrupted()) { close(); throw new IllegalStateException("The iteration has been interrupted."); } try { wrappedIter.remove(); } catch(IllegalStateException e) { close(); throw e; } }