Class Payload

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected byte[] data
      the byte array containing the payload data
      protected int length
      the length of the payload data
      protected int offset
      the offset within the byte array
    • Constructor Summary

      Constructors 
      Constructor Description
      Payload()
      Creates an empty payload and does not allocate a byte array.
      Payload​(byte[] data)
      Creates a new payload with the the given array as data.
      Payload​(byte[] data, int offset, int length)
      Creates a new payload with the the given array as data.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte byteAt​(int index)
      Returns the byte at the given index.
      Object clone()
      Clones this payload by creating a copy of the underlying byte array.
      void copyTo​(byte[] target, int targetOffset)
      Copies the payload data to a byte array.
      boolean equals​(Object obj)  
      byte[] getData()
      Returns a reference to the underlying byte array that holds this payloads data.
      int getOffset()
      Returns the offset in the underlying byte array
      int hashCode()  
      int length()
      Returns the length of the payload data.
      void setData​(byte[] data)
      Sets this payloads data.
      void setData​(byte[] data, int offset, int length)
      Sets this payloads data.
      byte[] toByteArray()
      Allocates a new byte array, copies the payload data into it and returns it.
    • Field Detail

      • data

        protected byte[] data
        the byte array containing the payload data
      • offset

        protected int offset
        the offset within the byte array
      • length

        protected int length
        the length of the payload data
    • Constructor Detail

      • Payload

        public Payload()
        Creates an empty payload and does not allocate a byte array.
      • Payload

        public Payload​(byte[] data)
        Creates a new payload with the the given array as data. A reference to the passed-in array is held, i. e. no copy is made.
        Parameters:
        data - the data of this payload
      • Payload

        public Payload​(byte[] data,
                       int offset,
                       int length)
        Creates a new payload with the the given array as data. A reference to the passed-in array is held, i. e. no copy is made.
        Parameters:
        data - the data of this payload
        offset - the offset in the data byte array
        length - the length of the data
    • Method Detail

      • setData

        public void setData​(byte[] data)
        Sets this payloads data. A reference to the passed-in array is held, i. e. no copy is made.
      • setData

        public void setData​(byte[] data,
                            int offset,
                            int length)
        Sets this payloads data. A reference to the passed-in array is held, i. e. no copy is made.
      • getData

        public byte[] getData()
        Returns a reference to the underlying byte array that holds this payloads data.
      • getOffset

        public int getOffset()
        Returns the offset in the underlying byte array
      • length

        public int length()
        Returns the length of the payload data.
      • byteAt

        public byte byteAt​(int index)
        Returns the byte at the given index.
      • toByteArray

        public byte[] toByteArray()
        Allocates a new byte array, copies the payload data into it and returns it.
      • copyTo

        public void copyTo​(byte[] target,
                           int targetOffset)
        Copies the payload data to a byte array.
        Parameters:
        target - the target byte array
        targetOffset - the offset in the target byte array
      • clone

        public Object clone()
        Clones this payload by creating a copy of the underlying byte array.
        Overrides:
        clone in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object