Class NIOHelper


  • public class NIOHelper
    extends Object
    static helper for ssl/nio related handshaking/input/output
    Author:
    eduard
    • Field Detail

      • EMPTY_BUFFER

        public static final ByteBuffer EMPTY_BUFFER
    • Method Detail

      • logBuffer

        public static void logBuffer​(ByteBuffer b)
        logs info on a bytebuffer at level FINE with name "unknown"
        Parameters:
        b -
      • logBuffer

        public static void logBuffer​(ByteBuffer b,
                                     String name)
        logs info on a bytebuffer at level FINE with name <name>
        Parameters:
        b -
      • logBuffer

        public static void logBuffer​(ByteBuffer b,
                                     String name,
                                     Level l)
        logs info on a bytebuffer at level <l> with name <name>
        Parameters:
        b -
      • copyAsMuchAsFits

        public static int copyAsMuchAsFits​(ByteBuffer dst,
                                           ByteBuffer src)
        copy data from src to dst, as much as fits in dst. src's position() will be moved when data are copied.
        Parameters:
        src - copy from
        dst - copy to
        Returns:
        number of bytes copied
      • enlargeBuffer

        public static ByteBuffer enlargeBuffer​(ByteBuffer b,
                                               int extraSpace,
                                               String name,
                                               boolean doLog)
        returns an enlarged, empty buffer
        Parameters:
        b -
        extraSpace -
        name - the name of the buffer
        doLog - log the changes or not
        Returns:
        the new enlarged buffer
      • enlargeAndFillBuffer

        public static ByteBuffer enlargeAndFillBuffer​(ByteBuffer b,
                                                      int extraSpace,
                                                      String name)
        returns an enlarged, filled with bytes from the buffer argument
        Parameters:
        b -
        extraSpace -
        Returns:
        the new enlarged buffer