Class NioSocketAcceptor.ServerSocketChannelIterator

  • All Implemented Interfaces:
    java.util.Iterator<java.nio.channels.ServerSocketChannel>
    Enclosing class:
    NioSocketAcceptor

    private static class NioSocketAcceptor.ServerSocketChannelIterator
    extends java.lang.Object
    implements java.util.Iterator<java.nio.channels.ServerSocketChannel>
    Defines an iterator for the selected-key Set returned by the selector.selectedKeys(). It replaces the SelectionKey operator.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Iterator<java.nio.channels.SelectionKey> iterator
      The selected-key iterator
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ServerSocketChannelIterator​(java.util.Collection<java.nio.channels.SelectionKey> selectedKeys)
      Build a SocketChannel iterator which will return a SocketChannel instead of a SelectionKey.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()
      Tells if there are more SockectChannel left in the iterator
      java.nio.channels.ServerSocketChannel next()
      Get the next SocketChannel in the operator we have built from the selected-key et for this selector.
      void remove()
      Remove the current SocketChannel from the iterator
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Field Detail

      • iterator

        private final java.util.Iterator<java.nio.channels.SelectionKey> iterator
        The selected-key iterator
    • Constructor Detail

      • ServerSocketChannelIterator

        private ServerSocketChannelIterator​(java.util.Collection<java.nio.channels.SelectionKey> selectedKeys)
        Build a SocketChannel iterator which will return a SocketChannel instead of a SelectionKey.
        Parameters:
        selectedKeys - The selector selected-key set
    • Method Detail

      • hasNext

        public boolean hasNext()
        Tells if there are more SockectChannel left in the iterator
        Specified by:
        hasNext in interface java.util.Iterator<java.nio.channels.ServerSocketChannel>
        Returns:
        true if there is at least one more SockectChannel object to read
      • next

        public java.nio.channels.ServerSocketChannel next()
        Get the next SocketChannel in the operator we have built from the selected-key et for this selector.
        Specified by:
        next in interface java.util.Iterator<java.nio.channels.ServerSocketChannel>
        Returns:
        The next SocketChannel in the iterator
      • remove

        public void remove()
        Remove the current SocketChannel from the iterator
        Specified by:
        remove in interface java.util.Iterator<java.nio.channels.ServerSocketChannel>