Class ByteQueue


  • public class ByteQueue
    extends java.lang.Object
    A queue for bytes. This file could be more optimized.
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteQueue()  
      ByteQueue​(byte[] buf, int off, int len)  
      ByteQueue​(int capacity)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addData​(byte[] buf, int off, int len)
      Add some data to our buffer.
      int available()  
      void copyTo​(java.io.OutputStream output, int length)
      Copy some bytes from the beginning of the data to the provided OutputStream.
      static int nextTwoPow​(int i)  
      void read​(byte[] buf, int offset, int len, int skip)
      Read data from the buffer.
      org.bouncycastle.tls.HandshakeMessageInput readHandshakeMessage​(int length)
      Return a HandshakeMessageInput over some bytes at the beginning of the data.
      int readInt32()  
      void removeData​(byte[] buf, int off, int len, int skip)
      Remove data from the buffer.
      void removeData​(int i)
      Remove some bytes from our data from the beginning.
      byte[] removeData​(int len, int skip)  
      void shrink()  
      • Methods inherited from class java.lang.Object

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

      • ByteQueue

        public ByteQueue()
      • ByteQueue

        public ByteQueue​(int capacity)
      • ByteQueue

        public ByteQueue​(byte[] buf,
                         int off,
                         int len)
    • Method Detail

      • nextTwoPow

        public static int nextTwoPow​(int i)
        Returns:
        The smallest number which can be written as 2^x which is bigger than i.
      • addData

        public void addData​(byte[] buf,
                            int off,
                            int len)
        Add some data to our buffer.
        Parameters:
        buf - A byte-array to read data from.
        off - How many bytes to skip at the beginning of the array.
        len - How many bytes to read from the array.
      • available

        public int available()
        Returns:
        The number of bytes which are available in this buffer.
      • copyTo

        public void copyTo​(java.io.OutputStream output,
                           int length)
                    throws java.io.IOException
        Copy some bytes from the beginning of the data to the provided OutputStream.
        Parameters:
        output - The OutputStream to copy the bytes to.
        length - How many bytes to copy.
        Throws:
        java.io.IOException
      • read

        public void read​(byte[] buf,
                         int offset,
                         int len,
                         int skip)
        Read data from the buffer.
        Parameters:
        buf - The buffer where the read data will be copied to.
        offset - How many bytes to skip at the beginning of buf.
        len - How many bytes to read at all.
        skip - How many bytes from our data to skip.
      • readHandshakeMessage

        public org.bouncycastle.tls.HandshakeMessageInput readHandshakeMessage​(int length)
        Return a HandshakeMessageInput over some bytes at the beginning of the data.
        Parameters:
        length - How many bytes will be readable.
        Returns:
        A HandshakeMessageInput over the data.
      • readInt32

        public int readInt32()
      • removeData

        public void removeData​(int i)
        Remove some bytes from our data from the beginning.
        Parameters:
        i - How many bytes to remove.
      • removeData

        public void removeData​(byte[] buf,
                               int off,
                               int len,
                               int skip)
        Remove data from the buffer.
        Parameters:
        buf - The buffer where the removed data will be copied to.
        off - How many bytes to skip at the beginning of buf.
        len - How many bytes to read at all.
        skip - How many bytes from our data to skip.
      • removeData

        public byte[] removeData​(int len,
                                 int skip)
      • shrink

        public void shrink()