info.aduna.iteration
Class ExceptionConvertingIteration<E,X extends Exception>

java.lang.Object
  extended by info.aduna.iteration.CloseableIterationBase<E,X>
      extended by info.aduna.iteration.ExceptionConvertingIteration<E,X>
All Implemented Interfaces:
CloseableIteration<E,X>, Iteration<E,X>

public abstract class ExceptionConvertingIteration<E,X extends Exception>
extends CloseableIterationBase<E,X>

A CloseableIteration that converts an arbitrary iteration to an iteration with exceptions of type X. Subclasses need to override convert(Exception) to do the conversion.


Field Summary
 
Fields inherited from class info.aduna.iteration.CloseableIterationBase
logger
 
Constructor Summary
ExceptionConvertingIteration(Iteration<? extends E,? extends Exception> iter)
          Creates a new ExceptionConvertingIteration that operates on the supplied iteration.
 
Method Summary
protected  X convert(Exception e)
          Converts an exception from the underlying iteration to an exception of type X.
protected  X convertedException(Exception e)
          Deprecated. convert(Exception) should be used or overridden instead.
protected  void handleClose()
          Closes this Iteration as well as the wrapped Iteration if it happens to be a CloseableIteration.
 boolean hasNext()
          Checks whether the underlying Iteration contains more elements.
 E next()
          Returns the next element from the wrapped Iteration.
 void remove()
          Calls remove() on the underlying Iteration.
 
Methods inherited from class info.aduna.iteration.CloseableIterationBase
close, isClosed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExceptionConvertingIteration

public ExceptionConvertingIteration(Iteration<? extends E,? extends Exception> iter)
Creates a new ExceptionConvertingIteration that operates on the supplied iteration.

Parameters:
iter - The Iteration that this ExceptionConvertingIteration operates on, must not be null.
Method Detail

convertedException

@Deprecated
protected X convertedException(Exception e)
Deprecated. convert(Exception) should be used or overridden instead.

Converts an exception from the underlying iteration to an exception of type X. By default, this method throw a RuntimeException indicating that this method has been deprecated.


convert

protected X convert(Exception e)
Converts an exception from the underlying iteration to an exception of type X. For now, this method calls the deprecated convertedException(Exception) method for backwards compatibility.


hasNext

public boolean hasNext()
                throws X extends Exception
Checks whether the underlying Iteration contains more elements.

Returns:
true if the underlying Iteration contains more elements, false otherwise.
Throws:
X
X extends Exception

next

public E next()
       throws X extends Exception
Returns the next element from the wrapped Iteration.

Returns:
the next element in the iteration.
Throws:
X
NoSuchElementException - If all elements have been returned.
IllegalStateException - If the Iteration has been closed.
X extends Exception

remove

public void remove()
            throws X extends Exception
Calls remove() on the underlying Iteration.

Throws:
UnsupportedOperationException - If the wrapped Iteration does not support the remove operation.
IllegalStateException - If the Iteration has been closed, or if next() has not yet been called, or remove() has already been called after the last call to next().
X extends Exception

handleClose

protected void handleClose()
                    throws X extends Exception
Closes this Iteration as well as the wrapped Iteration if it happens to be a CloseableIteration.

Overrides:
handleClose in class CloseableIterationBase<E,X extends Exception>
Throws:
X
X extends Exception


Copyright © 1997-2008 Aduna. All Rights Reserved.