Package org.conscrypt

Class BufferUtils


  • final class BufferUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private BufferUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static void checkNotNull​(java.nio.ByteBuffer[] buffers)
      Throws IllegalArgumentException if any of the buffers in the array are null.
      (package private) static void consume​(java.nio.ByteBuffer[] sourceBuffers, int toConsume)
      Marks toConsume bytes of data as consumed from the buffer array.
      (package private) static java.nio.ByteBuffer copyNoConsume​(java.nio.ByteBuffer[] buffers, java.nio.ByteBuffer destination, int maxAmount)
      Copies up to maxAmount bytes from a buffer array to destination.
      (package private) static java.nio.ByteBuffer getBufferLargerThan​(java.nio.ByteBuffer[] buffers, int minSize)
      Looks for a buffer in the buffer array which EITHER is larger than minSize AND has no preceding non-empty buffers OR is the only non-empty buffer in the array.
      (package private) static long remaining​(java.nio.ByteBuffer[] buffers)
      Returns the total number of bytes remaining in the buffer array.
      • Methods inherited from class java.lang.Object

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

      • BufferUtils

        private BufferUtils()
    • Method Detail

      • checkNotNull

        static void checkNotNull​(java.nio.ByteBuffer[] buffers)
        Throws IllegalArgumentException if any of the buffers in the array are null.
      • remaining

        static long remaining​(java.nio.ByteBuffer[] buffers)
        Returns the total number of bytes remaining in the buffer array.
      • consume

        static void consume​(java.nio.ByteBuffer[] sourceBuffers,
                            int toConsume)
        Marks toConsume bytes of data as consumed from the buffer array.
        Throws:
        java.lang.IllegalArgumentException - if there are fewer than toConsume bytes remaining
      • getBufferLargerThan

        static java.nio.ByteBuffer getBufferLargerThan​(java.nio.ByteBuffer[] buffers,
                                                       int minSize)
        Looks for a buffer in the buffer array which EITHER is larger than minSize AND has no preceding non-empty buffers OR is the only non-empty buffer in the array.
      • copyNoConsume

        static java.nio.ByteBuffer copyNoConsume​(java.nio.ByteBuffer[] buffers,
                                                 java.nio.ByteBuffer destination,
                                                 int maxAmount)
        Copies up to maxAmount bytes from a buffer array to destination. The copied data is not marked as consumed from the source buffers, on the assumption the copy will be passed to some method which will consume between 0 and maxAmount bytes which can then be reflected in the source array using the consume() method.