Interface Buffer

All Superinterfaces:
ClusterSerializable, Shareable

public interface Buffer extends ClusterSerializable, Shareable
Most data is shuffled around inside Vert.x using buffers.

A buffer is a sequence of zero or more bytes that can read from or written to and which expands automatically as necessary to accommodate any bytes written to it. You can perhaps think of a buffer as smart byte array.

Please consult the documentation for more information on buffers.

Author:
Tim Fox
  • Method Summary

    Modifier and Type
    Method
    Description
    Appends the specified Buffer to the end of this Buffer.
    appendBuffer(Buffer buff, int offset, int len)
    Appends the specified Buffer starting at the offset using len to the end of this Buffer.
    appendByte(byte b)
    Appends the specified byte to the end of the Buffer.
    appendBytes(byte[] bytes)
    Appends the specified byte[] to the end of the Buffer.
    appendBytes(byte[] bytes, int offset, int len)
    Appends the specified number of bytes from byte[] to the end of the Buffer, starting at the given offset.
    appendDouble(double d)
    Appends the specified double to the end of the Buffer.
    appendDoubleLE(double d)
    Appends the specified unsigned double to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.
    appendFloat(float f)
    Appends the specified float to the end of the Buffer.
    appendFloatLE(float f)
    Appends the specified unsigned float to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.
    appendInt(int i)
    Appends the specified int to the end of the Buffer.
    appendIntLE(int i)
    Appends the specified int to the end of the Buffer in the Little Endian Byte Order.
    appendLong(long l)
    Appends the specified long to the end of the Buffer.
    appendLongLE(long l)
    Appends the specified long to the end of the Buffer in the Little Endian Byte Order.
    appendMedium(int i)
    Appends the specified 24bit int to the end of the Buffer.
    Appends the specified 24bit int to the end of the Buffer in the Little Endian Byte Order.
    appendShort(short s)
    Appends the specified short to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.
    appendShortLE(short s)
    Appends the specified short to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.
    Appends the specified String str to the end of the Buffer with UTF-8 encoding.
    Appends the specified String to the end of the Buffer with the encoding as specified by enc.
    Appends the specified unsigned byte to the end of the Buffer.
    Appends the specified unsigned int to the end of the Buffer.
    Appends the specified unsigned int to the end of the Buffer in the Little Endian Byte Order.
    Appends the specified unsigned short to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.
    Appends the specified unsigned short to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.
    static Buffer
    Create a new, empty buffer.
    static Buffer
    buffer(byte[] bytes)
    Create a new buffer from a byte[].
    static Buffer
    buffer(int initialSizeHint)
    Create a new buffer given the initial size hint.
    static Buffer
    buffer(String string)
    Create a new buffer from a string.
    static Buffer
    buffer(String string, String enc)
    Create a new buffer from a string and using the specified encoding.
    Returns a copy of the entire Buffer.
    static Buffer
    Create a buffer from the base 64 URL encoded value
    getBuffer(int start, int end)
    Returns a copy of a sub-sequence the Buffer as a Buffer starting at position start and ending at position end - 1
    byte
    getByte(int pos)
    Returns the byte at position pos in the Buffer.
    byte[]
    Returns a copy of the entire Buffer as a byte[]
    getBytes(byte[] dst)
    Transfers the content of the Buffer into a byte[].
    getBytes(byte[] dst, int dstIndex)
    Transfers the content of the Buffer into a byte[] at the specific destination.
    byte[]
    getBytes(int start, int end)
    Returns a copy of a sub-sequence the Buffer as a byte[] starting at position start and ending at position end - 1
    getBytes(int start, int end, byte[] dst)
    Transfers the content of the Buffer starting at position start and ending at position end - 1 into a byte[].
    getBytes(int start, int end, byte[] dst, int dstIndex)
    Transfers the content of the Buffer starting at position start and ending at position end - 1 into a byte[] at the specific destination.
    double
    getDouble(int pos)
    Returns the double at position pos in the Buffer.
    double
    getDoubleLE(int pos)
    Gets a double at the specified absolute index in this buffer in Little Endian Byte Order.
    float
    getFloat(int pos)
    Returns the float at position pos in the Buffer.
    float
    getFloatLE(int pos)
    Gets a float at the specified absolute index in this buffer in Little Endian Byte Order.
    int
    getInt(int pos)
    Returns the int at position pos in the Buffer.
    int
    getIntLE(int pos)
    Gets a 32-bit integer at the specified absolute index in this buffer with Little Endian Byte Order.
    long
    getLong(int pos)
    Returns the long at position pos in the Buffer.
    long
    getLongLE(int pos)
    Gets a 64-bit long integer at the specified absolute index in this buffer in Little Endian Byte Order.
    int
    getMedium(int pos)
    Gets a 24-bit medium integer at the specified absolute index in this buffer.
    int
    getMediumLE(int pos)
    Gets a 24-bit medium integer at the specified absolute index in this buffer in the Little Endian Byte Order.
    short
    getShort(int pos)
    Returns the short at position pos in the Buffer.
    short
    getShortLE(int pos)
    Gets a 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order.
    getString(int start, int end)
    Returns a copy of a sub-sequence the Buffer as a String starting at position start and ending at position end - 1 interpreted as a String in UTF-8 encoding
    getString(int start, int end, String enc)
    Returns a copy of a sub-sequence the Buffer as a String starting at position start and ending at position end - 1 interpreted as a String in the specified encoding
    short
    getUnsignedByte(int pos)
    Returns the unsigned byte at position pos in the Buffer, as a short.
    long
    getUnsignedInt(int pos)
    Returns the unsigned int at position pos in the Buffer, as a long.
    long
    Returns the unsigned int at position pos in the Buffer, as a long in Little Endian Byte Order.
    int
    Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer.
    int
    Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer in Little Endian Byte Order.
    int
    Returns the unsigned short at position pos in the Buffer, as an int.
    int
    Gets an unsigned 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order.
    int
    Returns the length of the buffer, measured in bytes.
    setBuffer(int pos, Buffer b)
    Sets the bytes at position pos in the Buffer to the bytes represented by the Buffer b.
    setBuffer(int pos, Buffer b, int offset, int len)
    Sets the bytes at position pos in the Buffer to the bytes represented by the Buffer b on the given offset and len.
    setByte(int pos, byte b)
    Sets the byte at position pos in the Buffer to the value b.
    setBytes(int pos, byte[] b)
    Sets the bytes at position pos in the Buffer to the bytes represented by the byte[] b.
    setBytes(int pos, byte[] b, int offset, int len)
    Sets the given number of bytes at position pos in the Buffer to the bytes represented by the byte[] b.
    setBytes(int pos, ByteBuffer b)
    Sets the bytes at position pos in the Buffer to the bytes represented by the ByteBuffer b.
    setDouble(int pos, double d)
    Sets the double at position pos in the Buffer to the value d.
    setDoubleLE(int pos, double d)
    Sets the double at position pos in the Buffer to the value d in the Little Endian Byte Order.
    setFloat(int pos, float f)
    Sets the float at position pos in the Buffer to the value f.
    setFloatLE(int pos, float f)
    Sets the float at position pos in the Buffer to the value f in the Little Endian Byte Order.
    setInt(int pos, int i)
    Sets the int at position pos in the Buffer to the value i.
    setIntLE(int pos, int i)
    Sets the int at position pos in the Buffer to the value i in the Little Endian Byte Order.
    setLong(int pos, long l)
    Sets the long at position pos in the Buffer to the value l.
    setLongLE(int pos, long l)
    Sets the long at position pos in the Buffer to the value l in the Little Endian Byte Order.
    setMedium(int pos, int i)
    Sets the 24bit int at position pos in the Buffer to the value i.
    setMediumLE(int pos, int i)
    Sets the 24bit int at position pos in the Buffer to the value i. in the Little Endian Byte Order
    setShort(int pos, short s)
    Sets the short at position pos in the Buffer to the value s.
    setShortLE(int pos, short s)
    Sets the short at position pos in the Buffer to the value s in the Little Endian Byte Order.
    setString(int pos, String str)
    Sets the bytes at position pos in the Buffer to the value of str encoded in UTF-8.
    setString(int pos, String str, String enc)
    Sets the bytes at position pos in the Buffer to the value of str encoded in encoding enc.
    setUnsignedByte(int pos, short b)
    Sets the unsigned byte at position pos in the Buffer to the value b.
    setUnsignedInt(int pos, long i)
    Sets the unsigned int at position pos in the Buffer to the value i.
    setUnsignedIntLE(int pos, long i)
    Sets the unsigned int at position pos in the Buffer to the value i in the Little Endian Byte Order.
    setUnsignedShort(int pos, int s)
    Sets the unsigned short at position pos in the Buffer to the value s.
    setUnsignedShortLE(int pos, int s)
    Sets the unsigned short at position pos in the Buffer to the value s in the Little Endian Byte Order.
    Returns a slice of this buffer.
    slice(int start, int end)
    Returns a slice of this buffer.
    default String
    Encode the buffer bytes to their base 64 URL encoded representation.
    Returns a JsonArray representation of this buffer's content.
    Returns a JsonObject representation of this buffer's content.
    default Object
    Returns a Json value representation of this buffer's content.
    Returns a String representation of the Buffer with the UTF-8 encoding
    Returns a String representation of the Buffer with the encoding specified by enc
    Returns a String representation of the Buffer with the encoding specified by enc

    Methods inherited from interface ClusterSerializable

    readFromBuffer, writeToBuffer
  • Method Details

    • fromJson

      static Buffer fromJson(String value)
      Create a buffer from the base 64 URL encoded value
      Parameters:
      value - the base64 encoded value
      Returns:
      the buffer
    • buffer

      static Buffer buffer()
      Create a new, empty buffer.
      Returns:
      the buffer
    • buffer

      static Buffer buffer(int initialSizeHint)
      Create a new buffer given the initial size hint.

      If you know the buffer will require a certain size, providing the hint can prevent unnecessary re-allocations as the buffer is written to and resized.

      Parameters:
      initialSizeHint - the hint, in bytes
      Returns:
      the buffer
    • buffer

      static Buffer buffer(String string)
      Create a new buffer from a string. The string will be UTF-8 encoded into the buffer.
      Parameters:
      string - the string
      Returns:
      the buffer
    • buffer

      static Buffer buffer(String string, String enc)
      Create a new buffer from a string and using the specified encoding. The string will be encoded into the buffer using the specified encoding.
      Parameters:
      string - the string
      Returns:
      the buffer
    • buffer

      static Buffer buffer(byte[] bytes)
      Create a new buffer from a byte[]. The byte[] will be copied to form the buffer.
      Parameters:
      bytes - the byte array
      Returns:
      the buffer
    • toString

      String toString()
      Returns a String representation of the Buffer with the UTF-8 encoding
      Overrides:
      toString in class Object
    • toString

      String toString(String enc)
      Returns a String representation of the Buffer with the encoding specified by enc
    • toString

      String toString(Charset enc)
      Returns a String representation of the Buffer with the encoding specified by enc
    • toJsonObject

      JsonObject toJsonObject()
      Returns a JsonObject representation of this buffer's content.
    • toJsonArray

      JsonArray toJsonArray()
      Returns a JsonArray representation of this buffer's content.
    • toJsonValue

      default Object toJsonValue()
      Returns a Json value representation of this buffer's content.
      Returns:
      a Json value which can be a JsonArray, JsonObject, String, ... if the buffer contains an array, object, string, ...etc
    • toJson

      default String toJson()
      Encode the buffer bytes to their base 64 URL encoded representation.
    • getByte

      byte getByte(int pos)
      Returns the byte at position pos in the Buffer.
      Throws:
      IndexOutOfBoundsException - if the specified pos is less than 0 or pos + 1 is greater than the length of the Buffer.
    • getUnsignedByte

      short getUnsignedByte(int pos)
      Returns the unsigned byte at position pos in the Buffer, as a short.
      Throws:
      IndexOutOfBoundsException - if the specified pos is less than 0 or pos + 1 is greater than the length of the Buffer.
    • getInt

      int getInt(int pos)
      Returns the int at position pos in the Buffer.
      Throws:
      IndexOutOfBoundsException - if the specified pos is less than 0 or pos + 4 is greater than the length of the Buffer.
    • getIntLE

      int getIntLE(int pos)
      Gets a 32-bit integer at the specified absolute index in this buffer with Little Endian Byte Order.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 4 is greater than this.capacity
    • getUnsignedInt

      long getUnsignedInt(int pos)
      Returns the unsigned int at position pos in the Buffer, as a long.
      Throws:
      IndexOutOfBoundsException - if the specified pos is less than 0 or pos + 4 is greater than the length of the Buffer.
    • getUnsignedIntLE

      long getUnsignedIntLE(int pos)
      Returns the unsigned int at position pos in the Buffer, as a long in Little Endian Byte Order.
      Throws:
      IndexOutOfBoundsException - if the specified pos is less than 0 or pos + 4 is greater than the length of the Buffer.
    • getLong

      long getLong(int pos)
      Returns the long at position pos in the Buffer.
      Throws:
      IndexOutOfBoundsException - if the specified pos is less than 0 or pos + 8 is greater than the length of the Buffer.
    • getLongLE

      long getLongLE(int pos)
      Gets a 64-bit long integer at the specified absolute index in this buffer in Little Endian Byte Order.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 8 is greater than the length of the Buffer.
    • getDouble

      double getDouble(int pos)
      Returns the double at position pos in the Buffer.
      Throws:
      IndexOutOfBoundsException - if the specified pos is less than 0 or pos + 8 is greater than the length of the Buffer.
    • getDoubleLE

      double getDoubleLE(int pos)
      Gets a double at the specified absolute index in this buffer in Little Endian Byte Order.
      Throws:
      IndexOutOfBoundsException - if the specified pos is less than 0 or pos + 8 is greater than the length of the Buffer.
    • getFloat

      float getFloat(int pos)
      Returns the float at position pos in the Buffer.
      Throws:
      IndexOutOfBoundsException - if the specified pos is less than 0 or pos + 4 is greater than the length of the Buffer.
    • getFloatLE

      float getFloatLE(int pos)
      Gets a float at the specified absolute index in this buffer in Little Endian Byte Order.
      Throws:
      IndexOutOfBoundsException - if the specified pos is less than 0 or pos + 4 is greater than the length of the Buffer.
    • getShort

      short getShort(int pos)
      Returns the short at position pos in the Buffer.
      Throws:
      IndexOutOfBoundsException - if the specified pos is less than 0 or pos + 2 is greater than the length of the Buffer.
    • getShortLE

      short getShortLE(int pos)
      Gets a 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 2 is greater than the length of the Buffer.
    • getUnsignedShort

      int getUnsignedShort(int pos)
      Returns the unsigned short at position pos in the Buffer, as an int.
      Throws:
      IndexOutOfBoundsException - if the specified pos is less than 0 or pos + 2 is greater than the length of the Buffer.
    • getUnsignedShortLE

      int getUnsignedShortLE(int pos)
      Gets an unsigned 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 2 is greater than the length of the Buffer.
    • getMedium

      int getMedium(int pos)
      Gets a 24-bit medium integer at the specified absolute index in this buffer.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 3 is greater than the length of the Buffer.
    • getMediumLE

      int getMediumLE(int pos)
      Gets a 24-bit medium integer at the specified absolute index in this buffer in the Little Endian Byte Order.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 3 is greater than the length of the Buffer.
    • getUnsignedMedium

      int getUnsignedMedium(int pos)
      Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 3 is greater than the length of the Buffer.
    • getUnsignedMediumLE

      int getUnsignedMediumLE(int pos)
      Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer in Little Endian Byte Order.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 3 is greater than the length of the Buffer.
    • getBytes

      byte[] getBytes()
      Returns a copy of the entire Buffer as a byte[]
    • getBytes

      byte[] getBytes(int start, int end)
      Returns a copy of a sub-sequence the Buffer as a byte[] starting at position start and ending at position end - 1
    • getBytes

      Buffer getBytes(byte[] dst)
      Transfers the content of the Buffer into a byte[].
      Parameters:
      dst - the destination byte array
      Throws:
      IndexOutOfBoundsException - if the content of the Buffer cannot fit into the destination byte array
    • getBytes

      Buffer getBytes(byte[] dst, int dstIndex)
      Transfers the content of the Buffer into a byte[] at the specific destination.
      Parameters:
      dst - the destination byte array
      Throws:
      IndexOutOfBoundsException - if the content of the Buffer cannot fit into the destination byte array
    • getBytes

      Buffer getBytes(int start, int end, byte[] dst)
      Transfers the content of the Buffer starting at position start and ending at position end - 1 into a byte[].
      Parameters:
      dst - the destination byte array
      Throws:
      IndexOutOfBoundsException - if the content of the Buffer cannot fit into the destination byte array
    • getBytes

      Buffer getBytes(int start, int end, byte[] dst, int dstIndex)
      Transfers the content of the Buffer starting at position start and ending at position end - 1 into a byte[] at the specific destination.
      Parameters:
      dst - the destination byte array
      Throws:
      IndexOutOfBoundsException - if the content of the Buffer cannot fit into the destination byte array
    • getBuffer

      Buffer getBuffer(int start, int end)
      Returns a copy of a sub-sequence the Buffer as a Buffer starting at position start and ending at position end - 1
    • getString

      String getString(int start, int end, String enc)
      Returns a copy of a sub-sequence the Buffer as a String starting at position start and ending at position end - 1 interpreted as a String in the specified encoding
    • getString

      String getString(int start, int end)
      Returns a copy of a sub-sequence the Buffer as a String starting at position start and ending at position end - 1 interpreted as a String in UTF-8 encoding
    • appendBuffer

      Buffer appendBuffer(Buffer buff)
      Appends the specified Buffer to the end of this Buffer. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendBuffer

      Buffer appendBuffer(Buffer buff, int offset, int len)
      Appends the specified Buffer starting at the offset using len to the end of this Buffer. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendBytes

      Buffer appendBytes(byte[] bytes)
      Appends the specified byte[] to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendBytes

      Buffer appendBytes(byte[] bytes, int offset, int len)
      Appends the specified number of bytes from byte[] to the end of the Buffer, starting at the given offset. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendByte

      Buffer appendByte(byte b)
      Appends the specified byte to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendUnsignedByte

      Buffer appendUnsignedByte(short b)
      Appends the specified unsigned byte to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendInt

      Buffer appendInt(int i)
      Appends the specified int to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendIntLE

      Buffer appendIntLE(int i)
      Appends the specified int to the end of the Buffer in the Little Endian Byte Order. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendUnsignedInt

      Buffer appendUnsignedInt(long i)
      Appends the specified unsigned int to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendUnsignedIntLE

      Buffer appendUnsignedIntLE(long i)
      Appends the specified unsigned int to the end of the Buffer in the Little Endian Byte Order. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendMedium

      Buffer appendMedium(int i)
      Appends the specified 24bit int to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendMediumLE

      Buffer appendMediumLE(int i)
      Appends the specified 24bit int to the end of the Buffer in the Little Endian Byte Order. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendLong

      Buffer appendLong(long l)
      Appends the specified long to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendLongLE

      Buffer appendLongLE(long l)
      Appends the specified long to the end of the Buffer in the Little Endian Byte Order. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendShort

      Buffer appendShort(short s)
      Appends the specified short to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendShortLE

      Buffer appendShortLE(short s)
      Appends the specified short to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendUnsignedShort

      Buffer appendUnsignedShort(int s)
      Appends the specified unsigned short to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendUnsignedShortLE

      Buffer appendUnsignedShortLE(int s)
      Appends the specified unsigned short to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendFloat

      Buffer appendFloat(float f)
      Appends the specified float to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendFloatLE

      Buffer appendFloatLE(float f)
      Appends the specified unsigned float to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendDouble

      Buffer appendDouble(double d)
      Appends the specified double to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendDoubleLE

      Buffer appendDoubleLE(double d)
      Appends the specified unsigned double to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendString

      Buffer appendString(String str, String enc)
      Appends the specified String to the end of the Buffer with the encoding as specified by enc.

      The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together.

    • appendString

      Buffer appendString(String str)
      Appends the specified String str to the end of the Buffer with UTF-8 encoding.

      The buffer will expand as necessary to accommodate any bytes written.

      Returns a reference to this so multiple operations can be appended together

    • setByte

      Buffer setByte(int pos, byte b)
      Sets the byte at position pos in the Buffer to the value b.

      The buffer will expand as necessary to accommodate any value written.

    • setUnsignedByte

      Buffer setUnsignedByte(int pos, short b)
      Sets the unsigned byte at position pos in the Buffer to the value b.

      The buffer will expand as necessary to accommodate any value written.

    • setInt

      Buffer setInt(int pos, int i)
      Sets the int at position pos in the Buffer to the value i.

      The buffer will expand as necessary to accommodate any value written.

    • setIntLE

      Buffer setIntLE(int pos, int i)
      Sets the int at position pos in the Buffer to the value i in the Little Endian Byte Order.

      The buffer will expand as necessary to accommodate any value written.

    • setUnsignedInt

      Buffer setUnsignedInt(int pos, long i)
      Sets the unsigned int at position pos in the Buffer to the value i.

      The buffer will expand as necessary to accommodate any value written.

    • setUnsignedIntLE

      Buffer setUnsignedIntLE(int pos, long i)
      Sets the unsigned int at position pos in the Buffer to the value i in the Little Endian Byte Order.

      The buffer will expand as necessary to accommodate any value written.

    • setMedium

      Buffer setMedium(int pos, int i)
      Sets the 24bit int at position pos in the Buffer to the value i.

      The buffer will expand as necessary to accommodate any value written.

    • setMediumLE

      Buffer setMediumLE(int pos, int i)
      Sets the 24bit int at position pos in the Buffer to the value i. in the Little Endian Byte Order

      The buffer will expand as necessary to accommodate any value written.

    • setLong

      Buffer setLong(int pos, long l)
      Sets the long at position pos in the Buffer to the value l.

      The buffer will expand as necessary to accommodate any value written.

    • setLongLE

      Buffer setLongLE(int pos, long l)
      Sets the long at position pos in the Buffer to the value l in the Little Endian Byte Order.

      The buffer will expand as necessary to accommodate any value written.

    • setDouble

      Buffer setDouble(int pos, double d)
      Sets the double at position pos in the Buffer to the value d.

      The buffer will expand as necessary to accommodate any value written.

    • setDoubleLE

      Buffer setDoubleLE(int pos, double d)
      Sets the double at position pos in the Buffer to the value d in the Little Endian Byte Order.

      The buffer will expand as necessary to accommodate any value written.

    • setFloat

      Buffer setFloat(int pos, float f)
      Sets the float at position pos in the Buffer to the value f.

      The buffer will expand as necessary to accommodate any value written.

    • setFloatLE

      Buffer setFloatLE(int pos, float f)
      Sets the float at position pos in the Buffer to the value f in the Little Endian Byte Order.

      The buffer will expand as necessary to accommodate any value written.

    • setShort

      Buffer setShort(int pos, short s)
      Sets the short at position pos in the Buffer to the value s.

      The buffer will expand as necessary to accommodate any value written.

    • setShortLE

      Buffer setShortLE(int pos, short s)
      Sets the short at position pos in the Buffer to the value s in the Little Endian Byte Order.

      The buffer will expand as necessary to accommodate any value written.

    • setUnsignedShort

      Buffer setUnsignedShort(int pos, int s)
      Sets the unsigned short at position pos in the Buffer to the value s.

      The buffer will expand as necessary to accommodate any value written.

    • setUnsignedShortLE

      Buffer setUnsignedShortLE(int pos, int s)
      Sets the unsigned short at position pos in the Buffer to the value s in the Little Endian Byte Order.

      The buffer will expand as necessary to accommodate any value written.

    • setBuffer

      Buffer setBuffer(int pos, Buffer b)
      Sets the bytes at position pos in the Buffer to the bytes represented by the Buffer b.

      The buffer will expand as necessary to accommodate any value written.

    • setBuffer

      Buffer setBuffer(int pos, Buffer b, int offset, int len)
      Sets the bytes at position pos in the Buffer to the bytes represented by the Buffer b on the given offset and len.

      The buffer will expand as necessary to accommodate any value written.

    • setBytes

      Buffer setBytes(int pos, ByteBuffer b)
      Sets the bytes at position pos in the Buffer to the bytes represented by the ByteBuffer b.

      The buffer will expand as necessary to accommodate any value written.

    • setBytes

      Buffer setBytes(int pos, byte[] b)
      Sets the bytes at position pos in the Buffer to the bytes represented by the byte[] b.

      The buffer will expand as necessary to accommodate any value written.

    • setBytes

      Buffer setBytes(int pos, byte[] b, int offset, int len)
      Sets the given number of bytes at position pos in the Buffer to the bytes represented by the byte[] b.

      The buffer will expand as necessary to accommodate any value written.
    • setString

      Buffer setString(int pos, String str)
      Sets the bytes at position pos in the Buffer to the value of str encoded in UTF-8.

      The buffer will expand as necessary to accommodate any value written.

    • setString

      Buffer setString(int pos, String str, String enc)
      Sets the bytes at position pos in the Buffer to the value of str encoded in encoding enc.

      The buffer will expand as necessary to accommodate any value written.

    • length

      int length()
      Returns the length of the buffer, measured in bytes. All positions are indexed from zero.
    • copy

      Buffer copy()
      Returns a copy of the entire Buffer.
      Specified by:
      copy in interface Shareable
    • slice

      Buffer slice()
      Returns a slice of this buffer. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks.
    • slice

      Buffer slice(int start, int end)
      Returns a slice of this buffer. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks.