Class SailClosingIteration<T,​X extends java.lang.Exception>

  • All Implemented Interfaces:
    java.lang.AutoCloseable, CloseableIteration<T,​X>, Iteration<T,​X>

    abstract class SailClosingIteration<T,​X extends java.lang.Exception>
    extends IterationWrapper<T,​X>
    An Iteration that holds on to a SailClosable until the Iteration is closed. Upon closing, the underlying Iteration is closed before the lock is released. This iterator closes itself as soon as all elements have been read.
    • Field Detail

      • closes

        private final SailClosable[] closes
        The lock to release when the Iteration is closed.
    • Method Detail

      • hasNext

        public boolean hasNext()
                        throws X extends java.lang.Exception
        Description copied from class: IterationWrapper
        Checks whether the wrapped Iteration contains more elements, closing this Iteration when this is not the case.
        Specified by:
        hasNext in interface Iteration<T,​X extends java.lang.Exception>
        Overrides:
        hasNext in class IterationWrapper<T,​X extends java.lang.Exception>
        Returns:
        true if the wrapped Iteration contains more elements, false otherwise.
        Throws:
        X
        X extends java.lang.Exception
      • next

        public T next()
               throws X extends java.lang.Exception
        Description copied from class: IterationWrapper
        Returns the next element from the wrapped Iteration.
        Specified by:
        next in interface Iteration<T,​X extends java.lang.Exception>
        Overrides:
        next in class IterationWrapper<T,​X extends java.lang.Exception>
        Returns:
        the next element in the iteration.
        Throws:
        X extends java.lang.Exception
      • remove

        public void remove()
                    throws X extends java.lang.Exception
        Description copied from class: IterationWrapper
        Removes the last element that has been returned from the wrapped Iteration.
        Specified by:
        remove in interface Iteration<T,​X extends java.lang.Exception>
        Overrides:
        remove in class IterationWrapper<T,​X extends java.lang.Exception>
        Throws:
        X extends java.lang.Exception
      • handleClose

        protected void handleClose()
                            throws X extends java.lang.Exception
        Description copied from class: IterationWrapper
        Closes this Iteration and also closes the wrapped Iteration if it is a CloseableIteration.
        Overrides:
        handleClose in class IterationWrapper<T,​X extends java.lang.Exception>
        Throws:
        X
        X extends java.lang.Exception
      • handleSailException

        protected abstract void handleSailException​(SailException e)
                                             throws X extends java.lang.Exception
        Handler for exceptions generated by the closure of the SailClosable array given to this object.
        This method is called after all of the SailClosable objects have had close called on them.
        Parameters:
        e - The SailException to handle.
        Throws:
        X - Instances of this generic-typed exception in response to the given SailException if the handler decides to propagate the exception.
        X extends java.lang.Exception