Class WebSocketMessage

  • All Implemented Interfaces:
    io.vertx.core.buffer.Buffer, io.vertx.core.shareddata.ClusterSerializable, io.vertx.core.shareddata.impl.ClusterSerializable, io.vertx.core.shareddata.Shareable

    public class WebSocketMessage
    extends Object
    implements io.vertx.core.buffer.Buffer
    • Constructor Summary

      Constructors 
      Constructor Description
      WebSocketMessage​(Request request, io.vertx.core.http.ServerWebSocket socket, io.vertx.core.buffer.Buffer buffer)
      Contextual constructor that knows where the message came from
      WebSocketMessage​(Request request, io.vertx.core.http.ServerWebSocket socket, String text)
      Cheat constructor for text messages.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      io.vertx.core.buffer.Buffer appendBuffer​(io.vertx.core.buffer.Buffer buff)
      Appends the specified Buffer to the end of this Buffer.
      io.vertx.core.buffer.Buffer appendBuffer​(io.vertx.core.buffer.Buffer buff, int offset, int len)
      Appends the specified Buffer starting at the offset using len to the end of this Buffer.
      io.vertx.core.buffer.Buffer appendByte​(byte b)
      Appends the specified byte to the end of the Buffer.
      io.vertx.core.buffer.Buffer appendBytes​(byte[] bytes)
      Appends the specified byte[] to the end of the Buffer.
      io.vertx.core.buffer.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.
      io.vertx.core.buffer.Buffer appendDouble​(double d)  
      io.vertx.core.buffer.Buffer appendFloat​(float f)  
      io.vertx.core.buffer.Buffer appendInt​(int i)
      Appends the specified int to the end of the Buffer.
      io.vertx.core.buffer.Buffer appendIntLE​(int i)  
      io.vertx.core.buffer.Buffer appendLong​(long l)  
      io.vertx.core.buffer.Buffer appendLongLE​(long l)  
      io.vertx.core.buffer.Buffer appendMedium​(int i)  
      io.vertx.core.buffer.Buffer appendMediumLE​(int i)  
      io.vertx.core.buffer.Buffer appendShort​(short s)  
      io.vertx.core.buffer.Buffer appendShortLE​(short s)  
      io.vertx.core.buffer.Buffer appendString​(String str)  
      io.vertx.core.buffer.Buffer appendString​(String str, String enc)  
      io.vertx.core.buffer.Buffer appendUnsignedByte​(short b)
      Appends the specified byte to the end of the Buffer.
      io.vertx.core.buffer.Buffer appendUnsignedInt​(long i)  
      io.vertx.core.buffer.Buffer appendUnsignedIntLE​(long i)  
      io.vertx.core.buffer.Buffer appendUnsignedShort​(int s)  
      io.vertx.core.buffer.Buffer appendUnsignedShortLE​(int s)  
      io.vertx.core.buffer.Buffer copy()  
      io.vertx.core.buffer.Buffer getBuffer​(int start, int end)  
      byte getByte​(int pos)  
      io.netty.buffer.ByteBuf getByteBuf()
      Deprecated.
      removed from public API in Vert.x 5
      byte[] getBytes()  
      io.vertx.core.buffer.Buffer getBytes​(byte[] dst)
      Transfers the content of the Buffer into a byte[].
      io.vertx.core.buffer.Buffer getBytes​(byte[] dst, int dstIndex)
      Transfers the content of the Buffer into a byte[] at the specific destination.
      byte[] getBytes​(int start, int end)  
      io.vertx.core.buffer.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[].
      io.vertx.core.buffer.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.
      double getDouble​(int pos)  
      float getFloat​(int pos)  
      int getInt​(int pos)  
      int getIntLE​(int pos)  
      long getLong​(int pos)  
      long getLongLE​(int pos)  
      int getMedium​(int pos)  
      int getMediumLE​(int pos)  
      short getShort​(int pos)  
      short getShortLE​(int pos)  
      String getString​(int start, int end)  
      String getString​(int start, int end, String enc)  
      short getUnsignedByte​(int pos)  
      long getUnsignedInt​(int pos)  
      long getUnsignedIntLE​(int pos)  
      int getUnsignedMedium​(int pos)  
      int getUnsignedMediumLE​(int pos)  
      int getUnsignedShort​(int pos)  
      int getUnsignedShortLE​(int pos)  
      boolean isBinary()
      Check whether the incoming message is binary or text
      int length()  
      int readFromBuffer​(int pos, io.vertx.core.buffer.Buffer buffer)  
      void reply​(io.vertx.core.buffer.Buffer buffer)
      Send back a binary reply to the other end
      void reply​(String text)
      Send back a text reply to the other end
      Request request()
      Retrieve the request that was upgraded to the WebSocket
      io.vertx.core.buffer.Buffer setBuffer​(int pos, io.vertx.core.buffer.Buffer b)  
      io.vertx.core.buffer.Buffer setBuffer​(int pos, io.vertx.core.buffer.Buffer b, int offset, int len)  
      io.vertx.core.buffer.Buffer setByte​(int pos, byte b)  
      io.vertx.core.buffer.Buffer setBytes​(int pos, byte[] b)  
      io.vertx.core.buffer.Buffer setBytes​(int pos, byte[] b, int offset, int len)  
      io.vertx.core.buffer.Buffer setBytes​(int pos, ByteBuffer b)  
      io.vertx.core.buffer.Buffer setDouble​(int pos, double d)  
      io.vertx.core.buffer.Buffer setFloat​(int pos, float f)  
      io.vertx.core.buffer.Buffer setInt​(int pos, int i)  
      io.vertx.core.buffer.Buffer setIntLE​(int pos, int i)  
      io.vertx.core.buffer.Buffer setLong​(int pos, long l)  
      io.vertx.core.buffer.Buffer setLongLE​(int pos, long l)  
      io.vertx.core.buffer.Buffer setMedium​(int pos, int i)  
      io.vertx.core.buffer.Buffer setMediumLE​(int pos, int i)  
      io.vertx.core.buffer.Buffer setShort​(int pos, short s)  
      io.vertx.core.buffer.Buffer setShortLE​(int pos, short s)  
      io.vertx.core.buffer.Buffer setString​(int pos, String str)  
      io.vertx.core.buffer.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.
      io.vertx.core.buffer.Buffer setUnsignedByte​(int pos, short b)  
      io.vertx.core.buffer.Buffer setUnsignedInt​(int pos, long i)  
      io.vertx.core.buffer.Buffer setUnsignedIntLE​(int pos, long i)  
      io.vertx.core.buffer.Buffer setUnsignedShort​(int pos, int s)  
      io.vertx.core.buffer.Buffer setUnsignedShortLE​(int pos, int s)  
      io.vertx.core.buffer.Buffer slice()
      Returns a slice of this buffer.
      io.vertx.core.buffer.Buffer slice​(int start, int end)
      Returns a slice of this buffer.
      io.vertx.core.http.ServerWebSocket socket()
      Retrieve the WebSocket on which this message was received
      io.vertx.core.json.JsonArray toJsonArray()  
      io.vertx.core.json.JsonObject toJsonObject()  
      String toString()  
      String toString​(String enc)  
      String toString​(Charset enc)  
      void writeToBuffer​(io.vertx.core.buffer.Buffer buffer)  
      • Methods inherited from interface io.vertx.core.buffer.Buffer

        toJson, toJsonValue
    • Constructor Detail

      • WebSocketMessage

        public WebSocketMessage​(Request request,
                                io.vertx.core.http.ServerWebSocket socket,
                                io.vertx.core.buffer.Buffer buffer)
        Contextual constructor that knows where the message came from
        Parameters:
        request - Request that was upgraded to the WebSocket
        socket - WebSocket where the message was received
        buffer - message that was received
      • WebSocketMessage

        public WebSocketMessage​(Request request,
                                io.vertx.core.http.ServerWebSocket socket,
                                String text)
        Cheat constructor for text messages. Vert.x likes to handle text messages in a special way by just decoding them from UTF-8. For a unified API in exchange for a small performance impact we convert them back to bytes and let the consumer decide how they want to read them.
        Parameters:
        request - Request that was upgraded to the WebSocket
        socket - WebSocket where the message was received
        text - message that was received
    • Method Detail

      • request

        public Request request()
        Retrieve the request that was upgraded to the WebSocket
        Returns:
        original routing context
      • socket

        public io.vertx.core.http.ServerWebSocket socket()
        Retrieve the WebSocket on which this message was received
        Returns:
        The socket that handles this message
      • reply

        public void reply​(String text)
        Send back a text reply to the other end
        Parameters:
        text - Text message to send
      • reply

        public void reply​(io.vertx.core.buffer.Buffer buffer)
        Send back a binary reply to the other end
        Parameters:
        buffer - Binary data to send
      • isBinary

        public boolean isBinary()
        Check whether the incoming message is binary or text
        Returns:
        true if the message is binary
      • writeToBuffer

        public void writeToBuffer​(io.vertx.core.buffer.Buffer buffer)
        Specified by:
        writeToBuffer in interface io.vertx.core.shareddata.ClusterSerializable
        Specified by:
        writeToBuffer in interface io.vertx.core.shareddata.impl.ClusterSerializable
        Parameters:
        buffer - Buffer to marshal into
        See Also:
        ClusterSerializable.writeToBuffer(io.vertx.core.buffer.Buffer)
      • readFromBuffer

        public int readFromBuffer​(int pos,
                                  io.vertx.core.buffer.Buffer buffer)
        Specified by:
        readFromBuffer in interface io.vertx.core.shareddata.ClusterSerializable
        Specified by:
        readFromBuffer in interface io.vertx.core.shareddata.impl.ClusterSerializable
        Parameters:
        pos - Position in the buffer to start unmarshaling from
        buffer - Buffer to unmarshal from
        Returns:
        amount of bytes read from the buffer
        See Also:
        ClusterSerializable.readFromBuffer(int, io.vertx.core.buffer.Buffer)
      • toString

        public String toString()
        Specified by:
        toString in interface io.vertx.core.buffer.Buffer
        Overrides:
        toString in class Object
        Returns:
        a String representation of the Buffer with the UTF-8 encoding
        See Also:
        Buffer.toString()
      • toString

        public String toString​(String enc)
        Specified by:
        toString in interface io.vertx.core.buffer.Buffer
        Parameters:
        enc - String encoding to use
        Returns:
        a String representation of the Buffer with the encoding specified by enc
        See Also:
        Buffer.toString(java.lang.String)
      • toString

        public String toString​(Charset enc)
        Specified by:
        toString in interface io.vertx.core.buffer.Buffer
        Parameters:
        enc - String encoding to use
        Returns:
        a String representation of the Buffer with the encoding specified by enc
        See Also:
        Buffer.toString(java.nio.charset.Charset)
      • toJsonObject

        public io.vertx.core.json.JsonObject toJsonObject()
        Specified by:
        toJsonObject in interface io.vertx.core.buffer.Buffer
        Returns:
        a String representation of the Buffer with the encoding specified by enc
        See Also:
        Buffer.toJsonObject()
      • toJsonArray

        public io.vertx.core.json.JsonArray toJsonArray()
        Specified by:
        toJsonArray in interface io.vertx.core.buffer.Buffer
        Returns:
        a Json array representation of the Buffer.
        See Also:
        Buffer.toJsonArray()
      • getByte

        public byte getByte​(int pos)
        Specified by:
        getByte in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        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.
        See Also:
        Buffer.getByte(int)
      • getUnsignedByte

        public short getUnsignedByte​(int pos)
        Specified by:
        getUnsignedByte in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        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.
        See Also:
        Buffer.getUnsignedByte(int)
      • getInt

        public int getInt​(int pos)
        Specified by:
        getInt in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        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.
        See Also:
        Buffer.getInt(int)
      • getIntLE

        public int getIntLE​(int pos)
        Specified by:
        getIntLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        Returns:
        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
        See Also:
        Buffer.getIntLE(int)
      • getUnsignedInt

        public long getUnsignedInt​(int pos)
        Specified by:
        getUnsignedInt in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        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.
        See Also:
        Buffer.getUnsignedInt(int)
      • getUnsignedIntLE

        public long getUnsignedIntLE​(int pos)
        Specified by:
        getUnsignedIntLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        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.
        See Also:
        Buffer.getUnsignedIntLE(int)
      • getLong

        public long getLong​(int pos)
        Specified by:
        getLong in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        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.
        See Also:
        Buffer.getLong(int)
      • getLongLE

        public long getLongLE​(int pos)
        Specified by:
        getLongLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        Returns:
        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.
        See Also:
        Buffer.getLongLE(int)
      • getDouble

        public double getDouble​(int pos)
        Specified by:
        getDouble in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        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.
        See Also:
        Buffer.getDouble(int)
      • getFloat

        public float getFloat​(int pos)
        Specified by:
        getFloat in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        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.
        See Also:
        Buffer.getFloat(int)
      • getShort

        public short getShort​(int pos)
        Specified by:
        getShort in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        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.
        See Also:
        Buffer.getShort(int)
      • getShortLE

        public short getShortLE​(int pos)
        Specified by:
        getShortLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        Returns:
        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.
        See Also:
        Buffer.getShortLE(int)
      • getUnsignedShort

        public int getUnsignedShort​(int pos)
        Specified by:
        getUnsignedShort in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        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.
        See Also:
        Buffer.getUnsignedShort(int)
      • getUnsignedShortLE

        public int getUnsignedShortLE​(int pos)
        Specified by:
        getUnsignedShortLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        Returns:
        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.
        See Also:
        Buffer.getUnsignedShortLE(int)
      • getMedium

        public int getMedium​(int pos)
        Specified by:
        getMedium in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        Returns:
        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.
        See Also:
        Buffer.getMedium(int)
      • getMediumLE

        public int getMediumLE​(int pos)
        Specified by:
        getMediumLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        Returns:
        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.
        See Also:
        Buffer.getMediumLE(int)
      • getUnsignedMedium

        public int getUnsignedMedium​(int pos)
        Specified by:
        getUnsignedMedium in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        Returns:
        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.
        See Also:
        Buffer.getUnsignedMedium(int)
      • getUnsignedMediumLE

        public int getUnsignedMediumLE​(int pos)
        Specified by:
        getUnsignedMediumLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - Position in the buffer to check
        Returns:
        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.
        See Also:
        Buffer.getUnsignedMediumLE(int)
      • getBytes

        public byte[] getBytes()
        Specified by:
        getBytes in interface io.vertx.core.buffer.Buffer
        Returns:
        a copy of the entire Buffer as a byte[]
        See Also:
        Buffer.getBytes()
      • getBytes

        public byte[] getBytes​(int start,
                               int end)
        Specified by:
        getBytes in interface io.vertx.core.buffer.Buffer
        Parameters:
        start - position to start copy from
        end - position to end copy at
        Returns:
        a copy of a sub-sequence the Buffer as a byte[] starting at position start and ending at position end - 1
        See Also:
        Buffer.getBytes(int, int)
      • getBytes

        public io.vertx.core.buffer.Buffer getBytes​(byte[] dst)
        Transfers the content of the Buffer into a byte[].
        Specified by:
        getBytes in interface io.vertx.core.buffer.Buffer
        Parameters:
        dst - the destination byte array
        Returns:
        a reference to this so multiple operations can be appended together.
        Throws:
        IndexOutOfBoundsException - if the content of the Buffer cannot fit into the destination byte array
        See Also:
        Buffer.getBytes(byte[])
      • getBytes

        public io.vertx.core.buffer.Buffer getBytes​(byte[] dst,
                                                    int dstIndex)
        Transfers the content of the Buffer into a byte[] at the specific destination.
        Specified by:
        getBytes in interface io.vertx.core.buffer.Buffer
        Parameters:
        dst - the destination byte array
        dstIndex - the index into the destination array where to star the copy
        Returns:
        a reference to this so multiple operations can be appended together.
        Throws:
        IndexOutOfBoundsException - if the content of the Buffer cannot fit into the destination byte array
        See Also:
        Buffer.getBytes(byte[], int)
      • getBytes

        public io.vertx.core.buffer.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[].
        Specified by:
        getBytes in interface io.vertx.core.buffer.Buffer
        Parameters:
        start - position to start copy from
        end - position to end copy at
        dst - the destination byte array
        Returns:
        a reference to this so multiple operations can be appended together.
        Throws:
        IndexOutOfBoundsException - if the content of the Buffer cannot fit into the destination byte array
        See Also:
        Buffer.getBytes(int, int, byte[])
      • getBytes

        public io.vertx.core.buffer.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.
        Specified by:
        getBytes in interface io.vertx.core.buffer.Buffer
        Parameters:
        start - position to start copy from
        end - position to end copy at
        dst - the destination byte array
        dstIndex - the index into the destination array where to star the copy
        Returns:
        a reference to this so multiple operations can be appended together.
        Throws:
        IndexOutOfBoundsException - if the content of the Buffer cannot fit into the destination byte array
        See Also:
        Buffer.getBytes(int, int, byte[], int)
      • getBuffer

        public io.vertx.core.buffer.Buffer getBuffer​(int start,
                                                     int end)
        Specified by:
        getBuffer in interface io.vertx.core.buffer.Buffer
        Parameters:
        start - position to start copy from
        end - position to end copy at
        Returns:
        a copy of a sub-sequence the Buffer as a Buffer starting at position start and ending at position end - 1
        See Also:
        Buffer.getBuffer(int, int)
      • getString

        public String getString​(int start,
                                int end,
                                String enc)
        Specified by:
        getString in interface io.vertx.core.buffer.Buffer
        Parameters:
        start - position to start copy from
        end - position to end copy at
        enc - String encoding to use
        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
        See Also:
        Buffer.getString(int, int, java.lang.String)
      • getString

        public String getString​(int start,
                                int end)
        Specified by:
        getString in interface io.vertx.core.buffer.Buffer
        Parameters:
        start - position to start copy from
        end - position to end copy at
        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
        See Also:
        Buffer.getString(int, int)
      • appendBuffer

        public io.vertx.core.buffer.Buffer appendBuffer​(io.vertx.core.buffer.Buffer buff)
        Appends the specified Buffer to the end of this Buffer. The buffer will expand as necessary to accommodate any bytes written.
        Specified by:
        appendBuffer in interface io.vertx.core.buffer.Buffer
        Parameters:
        buff - buffer to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendBuffer(io.vertx.core.buffer.Buffer)
      • appendBuffer

        public io.vertx.core.buffer.Buffer appendBuffer​(io.vertx.core.buffer.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.
        Specified by:
        appendBuffer in interface io.vertx.core.buffer.Buffer
        Parameters:
        buff - buffer to append
        offset - offset where to start appending
        len - length of the buffer to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendBuffer(io.vertx.core.buffer.Buffer, int, int)
      • appendBytes

        public io.vertx.core.buffer.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.
        Specified by:
        appendBytes in interface io.vertx.core.buffer.Buffer
        Parameters:
        bytes - bytes to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendBytes(byte[])
      • appendBytes

        public io.vertx.core.buffer.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.
        Specified by:
        appendBytes in interface io.vertx.core.buffer.Buffer
        Parameters:
        bytes - bytes to append
        offset - offset where to start appending
        len - length of the buffer to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendBytes(byte[], int, int)
      • appendByte

        public io.vertx.core.buffer.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.
        Specified by:
        appendByte in interface io.vertx.core.buffer.Buffer
        Parameters:
        b - byte to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendByte(byte)
      • appendUnsignedByte

        public io.vertx.core.buffer.Buffer appendUnsignedByte​(short b)
        Appends the specified byte to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.
        Specified by:
        appendUnsignedByte in interface io.vertx.core.buffer.Buffer
        Parameters:
        b - byte to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendUnsignedByte(short)
      • appendInt

        public io.vertx.core.buffer.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.
        Specified by:
        appendInt in interface io.vertx.core.buffer.Buffer
        Parameters:
        i - integer to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendInt(int)
      • appendIntLE

        public io.vertx.core.buffer.Buffer appendIntLE​(int i)
        Specified by:
        appendIntLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        i - integer to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendIntLE(int)
      • appendUnsignedInt

        public io.vertx.core.buffer.Buffer appendUnsignedInt​(long i)
        Specified by:
        appendUnsignedInt in interface io.vertx.core.buffer.Buffer
        Parameters:
        i - integer to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendUnsignedInt(long)
      • appendUnsignedIntLE

        public io.vertx.core.buffer.Buffer appendUnsignedIntLE​(long i)
        Specified by:
        appendUnsignedIntLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        i - integer to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendUnsignedIntLE(long)
      • appendMedium

        public io.vertx.core.buffer.Buffer appendMedium​(int i)
        Specified by:
        appendMedium in interface io.vertx.core.buffer.Buffer
        Parameters:
        i - integer to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendMedium(int)
      • appendMediumLE

        public io.vertx.core.buffer.Buffer appendMediumLE​(int i)
        Specified by:
        appendMediumLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        i - integer to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendMediumLE(int)
      • appendLong

        public io.vertx.core.buffer.Buffer appendLong​(long l)
        Specified by:
        appendLong in interface io.vertx.core.buffer.Buffer
        Parameters:
        l - long to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendLong(long)
      • appendLongLE

        public io.vertx.core.buffer.Buffer appendLongLE​(long l)
        Specified by:
        appendLongLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        l - long to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendLongLE(long)
      • appendShort

        public io.vertx.core.buffer.Buffer appendShort​(short s)
        Specified by:
        appendShort in interface io.vertx.core.buffer.Buffer
        Parameters:
        s - short to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendShort(short)
      • appendShortLE

        public io.vertx.core.buffer.Buffer appendShortLE​(short s)
        Specified by:
        appendShortLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        s - short to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendShortLE(short)
      • appendUnsignedShort

        public io.vertx.core.buffer.Buffer appendUnsignedShort​(int s)
        Specified by:
        appendUnsignedShort in interface io.vertx.core.buffer.Buffer
        Parameters:
        s - short to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendUnsignedShort(int)
      • appendUnsignedShortLE

        public io.vertx.core.buffer.Buffer appendUnsignedShortLE​(int s)
        Specified by:
        appendUnsignedShortLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        s - short to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendUnsignedShortLE(int)
      • appendFloat

        public io.vertx.core.buffer.Buffer appendFloat​(float f)
        Specified by:
        appendFloat in interface io.vertx.core.buffer.Buffer
        Parameters:
        f - float to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendFloat(float)
      • appendDouble

        public io.vertx.core.buffer.Buffer appendDouble​(double d)
        Specified by:
        appendDouble in interface io.vertx.core.buffer.Buffer
        Parameters:
        d - double to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendDouble(double)
      • appendString

        public io.vertx.core.buffer.Buffer appendString​(String str,
                                                        String enc)
        Specified by:
        appendString in interface io.vertx.core.buffer.Buffer
        Parameters:
        str - String to append
        enc - encoding to use for the string
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendString(java.lang.String, java.lang.String)
      • appendString

        public io.vertx.core.buffer.Buffer appendString​(String str)
        Specified by:
        appendString in interface io.vertx.core.buffer.Buffer
        Parameters:
        str - string to append
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.appendString(java.lang.String)
      • setByte

        public io.vertx.core.buffer.Buffer setByte​(int pos,
                                                   byte b)
        Specified by:
        setByte in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the byte
        b - byte to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setByte(int, byte)
      • setUnsignedByte

        public io.vertx.core.buffer.Buffer setUnsignedByte​(int pos,
                                                           short b)
        Specified by:
        setUnsignedByte in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the short
        b - short to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setUnsignedByte(int, short)
      • setInt

        public io.vertx.core.buffer.Buffer setInt​(int pos,
                                                  int i)
        Specified by:
        setInt in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the integer
        i - integer to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setInt(int, int)
      • setIntLE

        public io.vertx.core.buffer.Buffer setIntLE​(int pos,
                                                    int i)
        Specified by:
        setIntLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the integer
        i - integer to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setIntLE(int, int)
      • setUnsignedInt

        public io.vertx.core.buffer.Buffer setUnsignedInt​(int pos,
                                                          long i)
        Specified by:
        setUnsignedInt in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the integer
        i - integer to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setUnsignedInt(int, long)
      • setUnsignedIntLE

        public io.vertx.core.buffer.Buffer setUnsignedIntLE​(int pos,
                                                            long i)
        Specified by:
        setUnsignedIntLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the integer
        i - integer to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setUnsignedIntLE(int, long)
      • setMedium

        public io.vertx.core.buffer.Buffer setMedium​(int pos,
                                                     int i)
        Specified by:
        setMedium in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the integer
        i - integer to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setMedium(int, int)
      • setMediumLE

        public io.vertx.core.buffer.Buffer setMediumLE​(int pos,
                                                       int i)
        Specified by:
        setMediumLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the integer
        i - integer to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setMediumLE(int, int)
      • setLong

        public io.vertx.core.buffer.Buffer setLong​(int pos,
                                                   long l)
        Specified by:
        setLong in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the long
        l - long to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setLong(int, long)
      • setLongLE

        public io.vertx.core.buffer.Buffer setLongLE​(int pos,
                                                     long l)
        Specified by:
        setLongLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the long
        l - long to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setLongLE(int, long)
      • setDouble

        public io.vertx.core.buffer.Buffer setDouble​(int pos,
                                                     double d)
        Specified by:
        setDouble in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the double
        d - double to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setDouble(int, double)
      • setFloat

        public io.vertx.core.buffer.Buffer setFloat​(int pos,
                                                    float f)
        Specified by:
        setFloat in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the float
        f - float to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setFloat(int, float)
      • setShort

        public io.vertx.core.buffer.Buffer setShort​(int pos,
                                                    short s)
        Specified by:
        setShort in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the short
        s - short to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setShort(int, short)
      • setShortLE

        public io.vertx.core.buffer.Buffer setShortLE​(int pos,
                                                      short s)
        Specified by:
        setShortLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the short
        s - short to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setShortLE(int, short)
      • setUnsignedShort

        public io.vertx.core.buffer.Buffer setUnsignedShort​(int pos,
                                                            int s)
        Specified by:
        setUnsignedShort in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the short
        s - short to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setUnsignedShort(int, int)
      • setUnsignedShortLE

        public io.vertx.core.buffer.Buffer setUnsignedShortLE​(int pos,
                                                              int s)
        Specified by:
        setUnsignedShortLE in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the short
        s - short to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setUnsignedShortLE(int, int)
      • setBuffer

        public io.vertx.core.buffer.Buffer setBuffer​(int pos,
                                                     io.vertx.core.buffer.Buffer b)
        Specified by:
        setBuffer in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the buffer
        b - buffer to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setBuffer(int, io.vertx.core.buffer.Buffer)
      • setBuffer

        public io.vertx.core.buffer.Buffer setBuffer​(int pos,
                                                     io.vertx.core.buffer.Buffer b,
                                                     int offset,
                                                     int len)
        Specified by:
        setBuffer in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the buffer
        b - buffer to write
        offset - offset into the source buffer to read from
        len - amount of bytes to read from the source buffer
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setBuffer(int, io.vertx.core.buffer.Buffer, int, int)
      • setBytes

        public io.vertx.core.buffer.Buffer setBytes​(int pos,
                                                    ByteBuffer b)
        Specified by:
        setBytes in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the buffer
        b - buffer to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setBytes(int, java.nio.ByteBuffer)
      • setBytes

        public io.vertx.core.buffer.Buffer setBytes​(int pos,
                                                    byte[] b)
        Specified by:
        setBytes in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the bytes
        b - bytes to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setBytes(int, byte[])
      • setBytes

        public io.vertx.core.buffer.Buffer setBytes​(int pos,
                                                    byte[] b,
                                                    int offset,
                                                    int len)
        Specified by:
        setBytes in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the bytes
        b - bytes to write
        offset - offset into the source byte array to read from
        len - amount of bytes to read from the source byte array
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setBytes(int, byte[], int, int)
      • setString

        public io.vertx.core.buffer.Buffer setString​(int pos,
                                                     String str)
        Specified by:
        setString in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position where to write the string
        str - string to write
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setString(int, java.lang.String)
      • setString

        public io.vertx.core.buffer.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.
        Specified by:
        setString in interface io.vertx.core.buffer.Buffer
        Parameters:
        pos - position to start modifying the buffer
        str - value to write in the buffer
        enc - String encoding to use
        Returns:
        a reference to this so multiple operations can be appended together.
        See Also:
        Buffer.setString(int, java.lang.String, java.lang.String)
      • length

        public int length()
        Specified by:
        length in interface io.vertx.core.buffer.Buffer
        Returns:
        the length of the buffer, measured in bytes. All positions are indexed from zero.
        See Also:
        Buffer.length()
      • copy

        public io.vertx.core.buffer.Buffer copy()
        Specified by:
        copy in interface io.vertx.core.buffer.Buffer
        Specified by:
        copy in interface io.vertx.core.shareddata.Shareable
        Returns:
        a copy of the entire Buffer.
        See Also:
        Buffer.copy()
      • slice

        public io.vertx.core.buffer.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.
        Specified by:
        slice in interface io.vertx.core.buffer.Buffer
        Returns:
        a slice of this buffer
        See Also:
        Buffer.slice()
      • slice

        public io.vertx.core.buffer.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.
        Specified by:
        slice in interface io.vertx.core.buffer.Buffer
        Parameters:
        start - position to start copy from
        end - position to end copy at
        Returns:
        a slice of this buffer
        See Also:
        Buffer.slice(int, int)
      • getByteBuf

        @Deprecated
        public io.netty.buffer.ByteBuf getByteBuf()
        Deprecated.
        removed from public API in Vert.x 5
        Returns the Buffer as a Netty ByteBuf.

        The returned buffer is a duplicate.

        The returned ByteBuf might have its readerIndex > 0 This method is meant for internal use only.

        Specified by:
        getByteBuf in interface io.vertx.core.buffer.Buffer
        Returns:
        a Netty ByteBuf
        See Also:
        Buffer.getByteBuf()