Class SelectionKeyUtils


  • public final class SelectionKeyUtils
    extends java.lang.Object
    • Method Summary

      Modifier and Type Method Description
      static boolean isWriteInterested​(java.nio.channels.SelectionKey selectionKey)
      Checks for an interest in writes for this selection key.
      static void removeConnectInterested​(java.nio.channels.SelectionKey selectionKey)
      Removes an interest in connects for this selection key while maintaining other interests.
      static void removeWriteInterested​(java.nio.channels.SelectionKey selectionKey)
      Removes an interest in writes for this selection key while maintaining other interests.
      static void setAcceptInterested​(java.nio.channels.SelectionKey selectionKey)
      Adds an interest in accepts for this selection key while maintaining other interests.
      static void setConnectAndReadInterested​(java.nio.channels.SelectionKey selectionKey)
      Removes an interest in connects and reads for this selection key while maintaining other interests.
      static void setConnectReadAndWriteInterested​(java.nio.channels.SelectionKey selectionKey)
      Removes an interest in connects, reads, and writes for this selection key while maintaining other interests.
      static void setWriteInterested​(java.nio.channels.SelectionKey selectionKey)
      Adds an interest in writes for this selection key while maintaining other interests.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setWriteInterested

        public static void setWriteInterested​(java.nio.channels.SelectionKey selectionKey)
                                       throws java.nio.channels.CancelledKeyException
        Adds an interest in writes for this selection key while maintaining other interests.
        Parameters:
        selectionKey - the selection key
        Throws:
        java.nio.channels.CancelledKeyException - if the key was already cancelled
      • removeWriteInterested

        public static void removeWriteInterested​(java.nio.channels.SelectionKey selectionKey)
                                          throws java.nio.channels.CancelledKeyException
        Removes an interest in writes for this selection key while maintaining other interests.
        Parameters:
        selectionKey - the selection key
        Throws:
        java.nio.channels.CancelledKeyException - if the key was already cancelled
      • setConnectAndReadInterested

        public static void setConnectAndReadInterested​(java.nio.channels.SelectionKey selectionKey)
                                                throws java.nio.channels.CancelledKeyException
        Removes an interest in connects and reads for this selection key while maintaining other interests.
        Parameters:
        selectionKey - the selection key
        Throws:
        java.nio.channels.CancelledKeyException - if the key was already cancelled
      • setConnectReadAndWriteInterested

        public static void setConnectReadAndWriteInterested​(java.nio.channels.SelectionKey selectionKey)
                                                     throws java.nio.channels.CancelledKeyException
        Removes an interest in connects, reads, and writes for this selection key while maintaining other interests.
        Parameters:
        selectionKey - the selection key
        Throws:
        java.nio.channels.CancelledKeyException - if the key was already cancelled
      • removeConnectInterested

        public static void removeConnectInterested​(java.nio.channels.SelectionKey selectionKey)
                                            throws java.nio.channels.CancelledKeyException
        Removes an interest in connects for this selection key while maintaining other interests.
        Parameters:
        selectionKey - the selection key
        Throws:
        java.nio.channels.CancelledKeyException - if the key was already cancelled
      • setAcceptInterested

        public static void setAcceptInterested​(java.nio.channels.SelectionKey selectionKey)
                                        throws java.nio.channels.CancelledKeyException
        Adds an interest in accepts for this selection key while maintaining other interests.
        Parameters:
        selectionKey - the selection key
        Throws:
        java.nio.channels.CancelledKeyException - if the key was already cancelled
      • isWriteInterested

        public static boolean isWriteInterested​(java.nio.channels.SelectionKey selectionKey)
                                         throws java.nio.channels.CancelledKeyException
        Checks for an interest in writes for this selection key.
        Parameters:
        selectionKey - the selection key
        Returns:
        a boolean indicating if we are currently interested in writes for this channel
        Throws:
        java.nio.channels.CancelledKeyException - if the key was already cancelled