Class Buffer

  • All Implemented Interfaces:
    io.vertx.core.shareddata.impl.ClusterSerializable

    public class Buffer
    extends Object
    implements io.vertx.core.shareddata.impl.ClusterSerializable
    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.

    NOTE: This class has been automatically generated from the original non Mutiny-ified interface using Vert.x codegen.

    • Constructor Detail

      • Buffer

        public Buffer​(io.vertx.core.buffer.Buffer delegate)
      • Buffer

        public Buffer​(Object delegate)
    • Method Detail

      • getDelegate

        public io.vertx.core.buffer.Buffer getDelegate()
      • writeToBuffer

        public void writeToBuffer​(io.vertx.core.buffer.Buffer buffer)
        Specified by:
        writeToBuffer in interface io.vertx.core.shareddata.impl.ClusterSerializable
      • readFromBuffer

        public int readFromBuffer​(int pos,
                                  io.vertx.core.buffer.Buffer buffer)
        Specified by:
        readFromBuffer in interface io.vertx.core.shareddata.impl.ClusterSerializable
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • buffer

        public static Buffer buffer()
        Returns:
        the buffer
      • buffer

        public static Buffer buffer​(int initialSizeHint)
        Parameters:
        initialSizeHint - the hint, in bytes
        Returns:
        the buffer
      • buffer

        public static Buffer buffer​(String string)
        Parameters:
        string - the string
        Returns:
        the buffer
      • buffer

        public static Buffer buffer​(String string,
                                    String enc)
        Parameters:
        string - the string
        enc -
        Returns:
        the buffer
      • toString

        public String toString​(String enc)
        Parameters:
        enc -
        Returns:
      • toJsonObject

        public io.vertx.core.json.JsonObject toJsonObject()
        Returns:
      • toJsonArray

        public io.vertx.core.json.JsonArray toJsonArray()
        Returns:
      • toJson

        public Object toJson()
        Returns:
        a JSON element which can be a , , String, ...etc if the buffer contains an array, object, string, ...etc
      • getByte

        public byte getByte​(int pos)
        Parameters:
        pos -
        Returns:
      • getUnsignedByte

        public short getUnsignedByte​(int pos)
        Parameters:
        pos -
        Returns:
      • getInt

        public int getInt​(int pos)
        Parameters:
        pos -
        Returns:
      • getIntLE

        public int getIntLE​(int pos)
        Parameters:
        pos -
        Returns:
      • getUnsignedInt

        public long getUnsignedInt​(int pos)
        Parameters:
        pos -
        Returns:
      • getUnsignedIntLE

        public long getUnsignedIntLE​(int pos)
        Parameters:
        pos -
        Returns:
      • getLong

        public long getLong​(int pos)
        Parameters:
        pos -
        Returns:
      • getLongLE

        public long getLongLE​(int pos)
        Parameters:
        pos -
        Returns:
      • getDouble

        public double getDouble​(int pos)
        Parameters:
        pos -
        Returns:
      • getFloat

        public float getFloat​(int pos)
        Parameters:
        pos -
        Returns:
      • getShort

        public short getShort​(int pos)
        Parameters:
        pos -
        Returns:
      • getShortLE

        public short getShortLE​(int pos)
        Parameters:
        pos -
        Returns:
      • getUnsignedShort

        public int getUnsignedShort​(int pos)
        Parameters:
        pos -
        Returns:
      • getUnsignedShortLE

        public int getUnsignedShortLE​(int pos)
        Parameters:
        pos -
        Returns:
      • getMedium

        public int getMedium​(int pos)
        Parameters:
        pos -
        Returns:
      • getMediumLE

        public int getMediumLE​(int pos)
        Parameters:
        pos -
        Returns:
      • getUnsignedMedium

        public int getUnsignedMedium​(int pos)
        Parameters:
        pos -
        Returns:
      • getUnsignedMediumLE

        public int getUnsignedMediumLE​(int pos)
        Parameters:
        pos -
        Returns:
      • getBuffer

        public Buffer getBuffer​(int start,
                                int end)
        Parameters:
        start -
        end -
        Returns:
      • getString

        public String getString​(int start,
                                int end,
                                String enc)
        Parameters:
        start -
        end -
        enc -
        Returns:
      • getString

        public String getString​(int start,
                                int end)
        Parameters:
        start -
        end -
        Returns:
      • appendBuffer

        public Buffer appendBuffer​(Buffer buff)
        Parameters:
        buff -
        Returns:
        the instance of Buffer to chain method calls.
      • appendBuffer

        public Buffer appendBuffer​(Buffer buff,
                                   int offset,
                                   int len)
        Parameters:
        buff -
        offset -
        len -
        Returns:
        the instance of Buffer to chain method calls.
      • appendByte

        public Buffer appendByte​(byte b)
        Parameters:
        b -
        Returns:
        the instance of Buffer to chain method calls.
      • appendUnsignedByte

        public Buffer appendUnsignedByte​(short b)
        Parameters:
        b -
        Returns:
        the instance of Buffer to chain method calls.
      • appendInt

        public Buffer appendInt​(int i)
        Parameters:
        i -
        Returns:
        the instance of Buffer to chain method calls.
      • appendIntLE

        public Buffer appendIntLE​(int i)
        Parameters:
        i -
        Returns:
        the instance of Buffer to chain method calls.
      • appendUnsignedInt

        public Buffer appendUnsignedInt​(long i)
        Parameters:
        i -
        Returns:
        the instance of Buffer to chain method calls.
      • appendUnsignedIntLE

        public Buffer appendUnsignedIntLE​(long i)
        Parameters:
        i -
        Returns:
        the instance of Buffer to chain method calls.
      • appendMedium

        public Buffer appendMedium​(int i)
        Parameters:
        i -
        Returns:
        the instance of Buffer to chain method calls.
      • appendMediumLE

        public Buffer appendMediumLE​(int i)
        Parameters:
        i -
        Returns:
        the instance of Buffer to chain method calls.
      • appendLong

        public Buffer appendLong​(long l)
        Parameters:
        l -
        Returns:
        the instance of Buffer to chain method calls.
      • appendLongLE

        public Buffer appendLongLE​(long l)
        Parameters:
        l -
        Returns:
        the instance of Buffer to chain method calls.
      • appendShort

        public Buffer appendShort​(short s)
        Parameters:
        s -
        Returns:
        the instance of Buffer to chain method calls.
      • appendShortLE

        public Buffer appendShortLE​(short s)
        Parameters:
        s -
        Returns:
        the instance of Buffer to chain method calls.
      • appendUnsignedShort

        public Buffer appendUnsignedShort​(int s)
        Parameters:
        s -
        Returns:
        the instance of Buffer to chain method calls.
      • appendUnsignedShortLE

        public Buffer appendUnsignedShortLE​(int s)
        Parameters:
        s -
        Returns:
        the instance of Buffer to chain method calls.
      • appendFloat

        public Buffer appendFloat​(float f)
        Parameters:
        f -
        Returns:
        the instance of Buffer to chain method calls.
      • appendDouble

        public Buffer appendDouble​(double d)
        Parameters:
        d -
        Returns:
        the instance of Buffer to chain method calls.
      • appendString

        public Buffer appendString​(String str,
                                   String enc)
        Parameters:
        str -
        enc -
        Returns:
        the instance of Buffer to chain method calls.
      • appendString

        public Buffer appendString​(String str)
        Parameters:
        str -
        Returns:
        the instance of Buffer to chain method calls.
      • setByte

        public Buffer setByte​(int pos,
                              byte b)
        Parameters:
        pos -
        b -
        Returns:
        the instance of Buffer to chain method calls.
      • setUnsignedByte

        public Buffer setUnsignedByte​(int pos,
                                      short b)
        Parameters:
        pos -
        b -
        Returns:
        the instance of Buffer to chain method calls.
      • setInt

        public Buffer setInt​(int pos,
                             int i)
        Parameters:
        pos -
        i -
        Returns:
        the instance of Buffer to chain method calls.
      • setIntLE

        public Buffer setIntLE​(int pos,
                               int i)
        Parameters:
        pos -
        i -
        Returns:
        the instance of Buffer to chain method calls.
      • setUnsignedInt

        public Buffer setUnsignedInt​(int pos,
                                     long i)
        Parameters:
        pos -
        i -
        Returns:
        the instance of Buffer to chain method calls.
      • setUnsignedIntLE

        public Buffer setUnsignedIntLE​(int pos,
                                       long i)
        Parameters:
        pos -
        i -
        Returns:
        the instance of Buffer to chain method calls.
      • setMedium

        public Buffer setMedium​(int pos,
                                int i)
        Parameters:
        pos -
        i -
        Returns:
        the instance of Buffer to chain method calls.
      • setMediumLE

        public Buffer setMediumLE​(int pos,
                                  int i)
        Parameters:
        pos -
        i -
        Returns:
        the instance of Buffer to chain method calls.
      • setLong

        public Buffer setLong​(int pos,
                              long l)
        Parameters:
        pos -
        l -
        Returns:
        the instance of Buffer to chain method calls.
      • setLongLE

        public Buffer setLongLE​(int pos,
                                long l)
        Parameters:
        pos -
        l -
        Returns:
        the instance of Buffer to chain method calls.
      • setDouble

        public Buffer setDouble​(int pos,
                                double d)
        Parameters:
        pos -
        d -
        Returns:
        the instance of Buffer to chain method calls.
      • setFloat

        public Buffer setFloat​(int pos,
                               float f)
        Parameters:
        pos -
        f -
        Returns:
        the instance of Buffer to chain method calls.
      • setShort

        public Buffer setShort​(int pos,
                               short s)
        Parameters:
        pos -
        s -
        Returns:
        the instance of Buffer to chain method calls.
      • setShortLE

        public Buffer setShortLE​(int pos,
                                 short s)
        Parameters:
        pos -
        s -
        Returns:
        the instance of Buffer to chain method calls.
      • setUnsignedShort

        public Buffer setUnsignedShort​(int pos,
                                       int s)
        Parameters:
        pos -
        s -
        Returns:
        the instance of Buffer to chain method calls.
      • setUnsignedShortLE

        public Buffer setUnsignedShortLE​(int pos,
                                         int s)
        Parameters:
        pos -
        s -
        Returns:
        the instance of Buffer to chain method calls.
      • setBuffer

        public Buffer setBuffer​(int pos,
                                Buffer b)
        Parameters:
        pos -
        b -
        Returns:
        the instance of Buffer to chain method calls.
      • setBuffer

        public Buffer setBuffer​(int pos,
                                Buffer b,
                                int offset,
                                int len)
        Parameters:
        pos -
        b -
        offset -
        len -
        Returns:
        the instance of Buffer to chain method calls.
      • setString

        public Buffer setString​(int pos,
                                String str)
        Parameters:
        pos -
        str -
        Returns:
        the instance of Buffer to chain method calls.
      • setString

        public Buffer setString​(int pos,
                                String str,
                                String enc)
        Parameters:
        pos -
        str -
        enc -
        Returns:
        the instance of Buffer to chain method calls.
      • length

        public int length()
        Returns:
      • copy

        public Buffer copy()
        Returns:
      • slice

        public Buffer slice()
        Returns:
      • slice

        public Buffer slice​(int start,
                            int end)
        Parameters:
        start -
        end -
        Returns:
      • buffer

        public static Buffer buffer​(byte[] bytes)
        Parameters:
        bytes - the byte array
        Returns:
        the buffer
      • buffer

        public static Buffer buffer​(io.netty.buffer.ByteBuf byteBuf)
        Parameters:
        byteBuf - the Netty ByteBuf
        Returns:
        the buffer
      • toString

        public String toString​(Charset enc)
        Parameters:
        enc -
        Returns:
      • getBytes

        public byte[] getBytes()
        Returns:
      • getBytes

        public byte[] getBytes​(int start,
                               int end)
        Parameters:
        start -
        end -
        Returns:
      • getBytes

        public Buffer getBytes​(byte[] dst)
        Parameters:
        dst - the destination byte array
        Returns:
        the instance of Buffer to chain method calls.
      • getBytes

        public Buffer getBytes​(byte[] dst,
                               int dstIndex)
        Parameters:
        dst - the destination byte array
        dstIndex -
        Returns:
        the instance of Buffer to chain method calls.
      • getBytes

        public Buffer getBytes​(int start,
                               int end,
                               byte[] dst)
        Parameters:
        start -
        end -
        dst - the destination byte array
        Returns:
        the instance of Buffer to chain method calls.
      • getBytes

        public Buffer getBytes​(int start,
                               int end,
                               byte[] dst,
                               int dstIndex)
        Parameters:
        start -
        end -
        dst - the destination byte array
        dstIndex -
        Returns:
        the instance of Buffer to chain method calls.
      • appendBytes

        public Buffer appendBytes​(byte[] bytes)
        Parameters:
        bytes -
        Returns:
        the instance of Buffer to chain method calls.
      • appendBytes

        public Buffer appendBytes​(byte[] bytes,
                                  int offset,
                                  int len)
        Parameters:
        bytes -
        offset -
        len -
        Returns:
        the instance of Buffer to chain method calls.
      • setBytes

        public Buffer setBytes​(int pos,
                               ByteBuffer b)
        Parameters:
        pos -
        b -
        Returns:
        the instance of Buffer to chain method calls.
      • setBytes

        public Buffer setBytes​(int pos,
                               byte[] b)
        Parameters:
        pos -
        b -
        Returns:
        the instance of Buffer to chain method calls.
      • setBytes

        public Buffer setBytes​(int pos,
                               byte[] b,
                               int offset,
                               int len)
        Parameters:
        pos -
        b -
        offset -
        len -
        Returns:
        the instance of Buffer to chain method calls.
      • getByteBuf

        public io.netty.buffer.ByteBuf getByteBuf()
        Returns:
      • newInstance

        public static Buffer newInstance​(io.vertx.core.buffer.Buffer arg)