Class WebSocketMessage
- java.lang.Object
-
- tech.greenfield.vertx.irked.websocket.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 fromWebSocketMessage(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.BufferappendBuffer(io.vertx.core.buffer.Buffer buff)Appends the specifiedBufferto the end of this Buffer.io.vertx.core.buffer.BufferappendBuffer(io.vertx.core.buffer.Buffer buff, int offset, int len)Appends the specifiedBufferstarting at theoffsetusinglento the end of this Buffer.io.vertx.core.buffer.BufferappendByte(byte b)Appends the specifiedbyteto the end of the Buffer.io.vertx.core.buffer.BufferappendBytes(byte[] bytes)Appends the specifiedbyte[]to the end of the Buffer.io.vertx.core.buffer.BufferappendBytes(byte[] bytes, int offset, int len)Appends the specified number of bytes frombyte[]to the end of the Buffer, starting at the given offset.io.vertx.core.buffer.BufferappendDouble(double d)io.vertx.core.buffer.BufferappendFloat(float f)io.vertx.core.buffer.BufferappendInt(int i)Appends the specifiedintto the end of the Buffer.io.vertx.core.buffer.BufferappendIntLE(int i)io.vertx.core.buffer.BufferappendLong(long l)io.vertx.core.buffer.BufferappendLongLE(long l)io.vertx.core.buffer.BufferappendMedium(int i)io.vertx.core.buffer.BufferappendMediumLE(int i)io.vertx.core.buffer.BufferappendShort(short s)io.vertx.core.buffer.BufferappendShortLE(short s)io.vertx.core.buffer.BufferappendString(String str)io.vertx.core.buffer.BufferappendString(String str, String enc)io.vertx.core.buffer.BufferappendUnsignedByte(short b)Appends the specifiedbyteto the end of the Buffer.io.vertx.core.buffer.BufferappendUnsignedInt(long i)io.vertx.core.buffer.BufferappendUnsignedIntLE(long i)io.vertx.core.buffer.BufferappendUnsignedShort(int s)io.vertx.core.buffer.BufferappendUnsignedShortLE(int s)io.vertx.core.buffer.Buffercopy()io.vertx.core.buffer.BuffergetBuffer(int start, int end)bytegetByte(int pos)io.netty.buffer.ByteBufgetByteBuf()Deprecated.removed from public API in Vert.x 5byte[]getBytes()io.vertx.core.buffer.BuffergetBytes(byte[] dst)Transfers the content of the Buffer into abyte[].io.vertx.core.buffer.BuffergetBytes(byte[] dst, int dstIndex)Transfers the content of the Buffer into abyte[]at the specific destination.byte[]getBytes(int start, int end)io.vertx.core.buffer.BuffergetBytes(int start, int end, byte[] dst)Transfers the content of the Buffer starting at positionstartand ending at positionend - 1into abyte[].io.vertx.core.buffer.BuffergetBytes(int start, int end, byte[] dst, int dstIndex)Transfers the content of the Buffer starting at positionstartand ending at positionend - 1into abyte[]at the specific destination.doublegetDouble(int pos)floatgetFloat(int pos)intgetInt(int pos)intgetIntLE(int pos)longgetLong(int pos)longgetLongLE(int pos)intgetMedium(int pos)intgetMediumLE(int pos)shortgetShort(int pos)shortgetShortLE(int pos)StringgetString(int start, int end)StringgetString(int start, int end, String enc)shortgetUnsignedByte(int pos)longgetUnsignedInt(int pos)longgetUnsignedIntLE(int pos)intgetUnsignedMedium(int pos)intgetUnsignedMediumLE(int pos)intgetUnsignedShort(int pos)intgetUnsignedShortLE(int pos)booleanisBinary()Check whether the incoming message is binary or textintlength()intreadFromBuffer(int pos, io.vertx.core.buffer.Buffer buffer)voidreply(io.vertx.core.buffer.Buffer buffer)Send back a binary reply to the other endvoidreply(String text)Send back a text reply to the other endRequestrequest()Retrieve the request that was upgraded to the WebSocketio.vertx.core.buffer.BuffersetBuffer(int pos, io.vertx.core.buffer.Buffer b)io.vertx.core.buffer.BuffersetBuffer(int pos, io.vertx.core.buffer.Buffer b, int offset, int len)io.vertx.core.buffer.BuffersetByte(int pos, byte b)io.vertx.core.buffer.BuffersetBytes(int pos, byte[] b)io.vertx.core.buffer.BuffersetBytes(int pos, byte[] b, int offset, int len)io.vertx.core.buffer.BuffersetBytes(int pos, ByteBuffer b)io.vertx.core.buffer.BuffersetDouble(int pos, double d)io.vertx.core.buffer.BuffersetFloat(int pos, float f)io.vertx.core.buffer.BuffersetInt(int pos, int i)io.vertx.core.buffer.BuffersetIntLE(int pos, int i)io.vertx.core.buffer.BuffersetLong(int pos, long l)io.vertx.core.buffer.BuffersetLongLE(int pos, long l)io.vertx.core.buffer.BuffersetMedium(int pos, int i)io.vertx.core.buffer.BuffersetMediumLE(int pos, int i)io.vertx.core.buffer.BuffersetShort(int pos, short s)io.vertx.core.buffer.BuffersetShortLE(int pos, short s)io.vertx.core.buffer.BuffersetString(int pos, String str)io.vertx.core.buffer.BuffersetString(int pos, String str, String enc)Sets the bytes at positionposin the Buffer to the value ofstrencoded in encodingenc.io.vertx.core.buffer.BuffersetUnsignedByte(int pos, short b)io.vertx.core.buffer.BuffersetUnsignedInt(int pos, long i)io.vertx.core.buffer.BuffersetUnsignedIntLE(int pos, long i)io.vertx.core.buffer.BuffersetUnsignedShort(int pos, int s)io.vertx.core.buffer.BuffersetUnsignedShortLE(int pos, int s)io.vertx.core.buffer.Bufferslice()Returns a slice of this buffer.io.vertx.core.buffer.Bufferslice(int start, int end)Returns a slice of this buffer.io.vertx.core.http.ServerWebSocketsocket()Retrieve the WebSocket on which this message was receivedio.vertx.core.json.JsonArraytoJsonArray()io.vertx.core.json.JsonObjecttoJsonObject()StringtoString()StringtoString(String enc)StringtoString(Charset enc)voidwriteToBuffer(io.vertx.core.buffer.Buffer buffer)
-
-
-
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 WebSocketsocket- WebSocket where the message was receivedbuffer- 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 WebSocketsocket- WebSocket where the message was receivedtext- 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:
writeToBufferin interfaceio.vertx.core.shareddata.ClusterSerializable- Specified by:
writeToBufferin interfaceio.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:
readFromBufferin interfaceio.vertx.core.shareddata.ClusterSerializable- Specified by:
readFromBufferin interfaceio.vertx.core.shareddata.impl.ClusterSerializable- Parameters:
pos- Position in the buffer to start unmarshaling frombuffer- 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()
-
toString
public String toString(String enc)
- Specified by:
toStringin interfaceio.vertx.core.buffer.Buffer- Parameters:
enc- String encoding to use- Returns:
- a
Stringrepresentation of the Buffer with the encoding specified byenc - See Also:
Buffer.toString(java.lang.String)
-
toString
public String toString(Charset enc)
- Specified by:
toStringin interfaceio.vertx.core.buffer.Buffer- Parameters:
enc- String encoding to use- Returns:
- a
Stringrepresentation of the Buffer with the encoding specified byenc - See Also:
Buffer.toString(java.nio.charset.Charset)
-
toJsonObject
public io.vertx.core.json.JsonObject toJsonObject()
- Specified by:
toJsonObjectin interfaceio.vertx.core.buffer.Buffer- Returns:
- a
Stringrepresentation of the Buffer with the encoding specified byenc - See Also:
Buffer.toJsonObject()
-
toJsonArray
public io.vertx.core.json.JsonArray toJsonArray()
- Specified by:
toJsonArrayin interfaceio.vertx.core.buffer.Buffer- Returns:
- a Json array representation of the Buffer.
- See Also:
Buffer.toJsonArray()
-
getByte
public byte getByte(int pos)
- Specified by:
getBytein interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- the
byteat positionposin the Buffer. - Throws:
IndexOutOfBoundsException- if the specifiedposis less than0orpos + 1is greater than the length of the Buffer.- See Also:
Buffer.getByte(int)
-
getUnsignedByte
public short getUnsignedByte(int pos)
- Specified by:
getUnsignedBytein interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- the unsigned
byteat positionposin the Buffer, as ashort. - Throws:
IndexOutOfBoundsException- if the specifiedposis less than0orpos + 1is greater than the length of the Buffer.- See Also:
Buffer.getUnsignedByte(int)
-
getInt
public int getInt(int pos)
- Specified by:
getIntin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- the
intat positionposin the Buffer. - Throws:
IndexOutOfBoundsException- if the specifiedposis less than0orpos + 4is greater than the length of the Buffer.- See Also:
Buffer.getInt(int)
-
getIntLE
public int getIntLE(int pos)
- Specified by:
getIntLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- a 32-bit integer at the specified absolute
indexin this buffer with Little Endian Byte Order. - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 4is greater thanthis.capacity- See Also:
Buffer.getIntLE(int)
-
getUnsignedInt
public long getUnsignedInt(int pos)
- Specified by:
getUnsignedIntin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- the unsigned
intat positionposin the Buffer, as along. - Throws:
IndexOutOfBoundsException- if the specifiedposis less than0orpos + 4is greater than the length of the Buffer.- See Also:
Buffer.getUnsignedInt(int)
-
getUnsignedIntLE
public long getUnsignedIntLE(int pos)
- Specified by:
getUnsignedIntLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- the unsigned
intat positionposin the Buffer, as alongin Little Endian Byte Order. - Throws:
IndexOutOfBoundsException- if the specifiedposis less than0orpos + 4is greater than the length of the Buffer.- See Also:
Buffer.getUnsignedIntLE(int)
-
getLong
public long getLong(int pos)
- Specified by:
getLongin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- the
longat positionposin the Buffer. - Throws:
IndexOutOfBoundsException- if the specifiedposis less than0orpos + 8is greater than the length of the Buffer.- See Also:
Buffer.getLong(int)
-
getLongLE
public long getLongLE(int pos)
- Specified by:
getLongLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- a 64-bit long integer at the specified absolute
indexin this buffer in Little Endian Byte Order. - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 8is greater than the length of the Buffer.- See Also:
Buffer.getLongLE(int)
-
getDouble
public double getDouble(int pos)
- Specified by:
getDoublein interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- the
doubleat positionposin the Buffer. - Throws:
IndexOutOfBoundsException- if the specifiedposis less than0orpos + 8is greater than the length of the Buffer.- See Also:
Buffer.getDouble(int)
-
getFloat
public float getFloat(int pos)
- Specified by:
getFloatin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- the
floatat positionposin the Buffer. - Throws:
IndexOutOfBoundsException- if the specifiedposis less than0orpos + 4is greater than the length of the Buffer.- See Also:
Buffer.getFloat(int)
-
getShort
public short getShort(int pos)
- Specified by:
getShortin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- the
shortat positionposin the Buffer. - Throws:
IndexOutOfBoundsException- if the specifiedposis less than0orpos + 2is greater than the length of the Buffer.- See Also:
Buffer.getShort(int)
-
getShortLE
public short getShortLE(int pos)
- Specified by:
getShortLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- a 16-bit short integer at the specified absolute
indexin this buffer in Little Endian Byte Order. - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 2is greater than the length of the Buffer.- See Also:
Buffer.getShortLE(int)
-
getUnsignedShort
public int getUnsignedShort(int pos)
- Specified by:
getUnsignedShortin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- the unsigned
shortat positionposin the Buffer, as anint. - Throws:
IndexOutOfBoundsException- if the specifiedposis less than0orpos + 2is greater than the length of the Buffer.- See Also:
Buffer.getUnsignedShort(int)
-
getUnsignedShortLE
public int getUnsignedShortLE(int pos)
- Specified by:
getUnsignedShortLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- an unsigned 16-bit short integer at the specified absolute
indexin this buffer in Little Endian Byte Order. - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 2is greater than the length of the Buffer.- See Also:
Buffer.getUnsignedShortLE(int)
-
getMedium
public int getMedium(int pos)
- Specified by:
getMediumin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- a 24-bit medium integer at the specified absolute
indexin this buffer. - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 3is greater than the length of the Buffer.- See Also:
Buffer.getMedium(int)
-
getMediumLE
public int getMediumLE(int pos)
- Specified by:
getMediumLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- a 24-bit medium integer at the specified absolute
indexin this buffer in the Little Endian Byte Order. - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 3is greater than the length of the Buffer.- See Also:
Buffer.getMediumLE(int)
-
getUnsignedMedium
public int getUnsignedMedium(int pos)
- Specified by:
getUnsignedMediumin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- an unsigned 24-bit medium integer at the specified absolute
indexin this buffer. - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 3is greater than the length of the Buffer.- See Also:
Buffer.getUnsignedMedium(int)
-
getUnsignedMediumLE
public int getUnsignedMediumLE(int pos)
- Specified by:
getUnsignedMediumLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- Position in the buffer to check- Returns:
- an unsigned 24-bit medium integer at the specified absolute
indexin this buffer in Little Endian Byte Order. - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 3is greater than the length of the Buffer.- See Also:
Buffer.getUnsignedMediumLE(int)
-
getBytes
public byte[] getBytes()
- Specified by:
getBytesin interfaceio.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:
getBytesin interfaceio.vertx.core.buffer.Buffer- Parameters:
start- position to start copy fromend- position to end copy at- Returns:
- a copy of a sub-sequence the Buffer as a
byte[]starting at positionstartand ending at positionend - 1 - See Also:
Buffer.getBytes(int, int)
-
getBytes
public io.vertx.core.buffer.Buffer getBytes(byte[] dst)
Transfers the content of the Buffer into abyte[].- Specified by:
getBytesin interfaceio.vertx.core.buffer.Buffer- Parameters:
dst- the destination byte array- Returns:
- a reference to
thisso 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 abyte[]at the specific destination.- Specified by:
getBytesin interfaceio.vertx.core.buffer.Buffer- Parameters:
dst- the destination byte arraydstIndex- the index into the destination array where to star the copy- Returns:
- a reference to
thisso 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 positionstartand ending at positionend - 1into abyte[].- Specified by:
getBytesin interfaceio.vertx.core.buffer.Buffer- Parameters:
start- position to start copy fromend- position to end copy atdst- the destination byte array- Returns:
- a reference to
thisso 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 positionstartand ending at positionend - 1into abyte[]at the specific destination.- Specified by:
getBytesin interfaceio.vertx.core.buffer.Buffer- Parameters:
start- position to start copy fromend- position to end copy atdst- the destination byte arraydstIndex- the index into the destination array where to star the copy- Returns:
- a reference to
thisso 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:
getBufferin interfaceio.vertx.core.buffer.Buffer- Parameters:
start- position to start copy fromend- position to end copy at- Returns:
- a copy of a sub-sequence the Buffer as a
Bufferstarting at positionstartand ending at positionend - 1 - See Also:
Buffer.getBuffer(int, int)
-
getString
public String getString(int start, int end, String enc)
- Specified by:
getStringin interfaceio.vertx.core.buffer.Buffer- Parameters:
start- position to start copy fromend- position to end copy atenc- String encoding to use- Returns:
- a copy of a sub-sequence the Buffer as a
Stringstarting at positionstartand ending at positionend - 1interpreted 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:
getStringin interfaceio.vertx.core.buffer.Buffer- Parameters:
start- position to start copy fromend- position to end copy at- Returns:
- a copy of a sub-sequence the Buffer as a
Stringstarting at positionstartand ending at positionend - 1interpreted 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 specifiedBufferto the end of this Buffer. The buffer will expand as necessary to accommodate any bytes written.- Specified by:
appendBufferin interfaceio.vertx.core.buffer.Buffer- Parameters:
buff- buffer to append- Returns:
- a reference to
thisso 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 specifiedBufferstarting at theoffsetusinglento the end of this Buffer. The buffer will expand as necessary to accommodate any bytes written.- Specified by:
appendBufferin interfaceio.vertx.core.buffer.Buffer- Parameters:
buff- buffer to appendoffset- offset where to start appendinglen- length of the buffer to append- Returns:
- a reference to
thisso 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 specifiedbyte[]to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.- Specified by:
appendBytesin interfaceio.vertx.core.buffer.Buffer- Parameters:
bytes- bytes to append- Returns:
- a reference to
thisso 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 frombyte[]to the end of the Buffer, starting at the given offset. The buffer will expand as necessary to accommodate any bytes written.- Specified by:
appendBytesin interfaceio.vertx.core.buffer.Buffer- Parameters:
bytes- bytes to appendoffset- offset where to start appendinglen- length of the buffer to append- Returns:
- a reference to
thisso 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 specifiedbyteto the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.- Specified by:
appendBytein interfaceio.vertx.core.buffer.Buffer- Parameters:
b- byte to append- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.appendByte(byte)
-
appendUnsignedByte
public io.vertx.core.buffer.Buffer appendUnsignedByte(short b)
Appends the specifiedbyteto the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.- Specified by:
appendUnsignedBytein interfaceio.vertx.core.buffer.Buffer- Parameters:
b- byte to append- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.appendUnsignedByte(short)
-
appendInt
public io.vertx.core.buffer.Buffer appendInt(int i)
Appends the specifiedintto the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.- Specified by:
appendIntin interfaceio.vertx.core.buffer.Buffer- Parameters:
i- integer to append- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.appendInt(int)
-
appendIntLE
public io.vertx.core.buffer.Buffer appendIntLE(int i)
- Specified by:
appendIntLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
i- integer to append- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.appendIntLE(int)
-
appendUnsignedInt
public io.vertx.core.buffer.Buffer appendUnsignedInt(long i)
- Specified by:
appendUnsignedIntin interfaceio.vertx.core.buffer.Buffer- Parameters:
i- integer to append- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.appendUnsignedInt(long)
-
appendUnsignedIntLE
public io.vertx.core.buffer.Buffer appendUnsignedIntLE(long i)
- Specified by:
appendUnsignedIntLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
i- integer to append- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.appendUnsignedIntLE(long)
-
appendMedium
public io.vertx.core.buffer.Buffer appendMedium(int i)
- Specified by:
appendMediumin interfaceio.vertx.core.buffer.Buffer- Parameters:
i- integer to append- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.appendMedium(int)
-
appendMediumLE
public io.vertx.core.buffer.Buffer appendMediumLE(int i)
- Specified by:
appendMediumLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
i- integer to append- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.appendMediumLE(int)
-
appendLong
public io.vertx.core.buffer.Buffer appendLong(long l)
- Specified by:
appendLongin interfaceio.vertx.core.buffer.Buffer- Parameters:
l- long to append- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.appendLong(long)
-
appendLongLE
public io.vertx.core.buffer.Buffer appendLongLE(long l)
- Specified by:
appendLongLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
l- long to append- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.appendLongLE(long)
-
appendShort
public io.vertx.core.buffer.Buffer appendShort(short s)
- Specified by:
appendShortin interfaceio.vertx.core.buffer.Buffer- Parameters:
s- short to append- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.appendShort(short)
-
appendShortLE
public io.vertx.core.buffer.Buffer appendShortLE(short s)
- Specified by:
appendShortLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
s- short to append- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.appendShortLE(short)
-
appendUnsignedShort
public io.vertx.core.buffer.Buffer appendUnsignedShort(int s)
- Specified by:
appendUnsignedShortin interfaceio.vertx.core.buffer.Buffer- Parameters:
s- short to append- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.appendUnsignedShort(int)
-
appendUnsignedShortLE
public io.vertx.core.buffer.Buffer appendUnsignedShortLE(int s)
- Specified by:
appendUnsignedShortLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
s- short to append- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.appendUnsignedShortLE(int)
-
appendFloat
public io.vertx.core.buffer.Buffer appendFloat(float f)
- Specified by:
appendFloatin interfaceio.vertx.core.buffer.Buffer- Parameters:
f- float to append- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.appendFloat(float)
-
appendDouble
public io.vertx.core.buffer.Buffer appendDouble(double d)
- Specified by:
appendDoublein interfaceio.vertx.core.buffer.Buffer- Parameters:
d- double to append- Returns:
- a reference to
thisso 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:
appendStringin interfaceio.vertx.core.buffer.Buffer- Parameters:
str- String to appendenc- encoding to use for the string- Returns:
- a reference to
thisso 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:
appendStringin interfaceio.vertx.core.buffer.Buffer- Parameters:
str- string to append- Returns:
- a reference to
thisso 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:
setBytein interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the byteb- byte to write- Returns:
- a reference to
thisso 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:
setUnsignedBytein interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the shortb- short to write- Returns:
- a reference to
thisso 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:
setIntin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the integeri- integer to write- Returns:
- a reference to
thisso 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:
setIntLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the integeri- integer to write- Returns:
- a reference to
thisso 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:
setUnsignedIntin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the integeri- integer to write- Returns:
- a reference to
thisso 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:
setUnsignedIntLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the integeri- integer to write- Returns:
- a reference to
thisso 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:
setMediumin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the integeri- integer to write- Returns:
- a reference to
thisso 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:
setMediumLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the integeri- integer to write- Returns:
- a reference to
thisso 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:
setLongin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the longl- long to write- Returns:
- a reference to
thisso 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:
setLongLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the longl- long to write- Returns:
- a reference to
thisso 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:
setDoublein interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the doubled- double to write- Returns:
- a reference to
thisso 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:
setFloatin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the floatf- float to write- Returns:
- a reference to
thisso 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:
setShortin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the shorts- short to write- Returns:
- a reference to
thisso 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:
setShortLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the shorts- short to write- Returns:
- a reference to
thisso 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:
setUnsignedShortin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the shorts- short to write- Returns:
- a reference to
thisso 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:
setUnsignedShortLEin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the shorts- short to write- Returns:
- a reference to
thisso 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:
setBufferin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the bufferb- buffer to write- Returns:
- a reference to
thisso 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:
setBufferin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the bufferb- buffer to writeoffset- offset into the source buffer to read fromlen- amount of bytes to read from the source buffer- Returns:
- a reference to
thisso 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:
setBytesin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the bufferb- buffer to write- Returns:
- a reference to
thisso 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:
setBytesin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the bytesb- bytes to write- Returns:
- a reference to
thisso 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:
setBytesin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the bytesb- bytes to writeoffset- offset into the source byte array to read fromlen- amount of bytes to read from the source byte array- Returns:
- a reference to
thisso 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:
setStringin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position where to write the stringstr- string to write- Returns:
- a reference to
thisso 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 positionposin the Buffer to the value ofstrencoded in encodingenc. The buffer will expand as necessary to accommodate any value written.- Specified by:
setStringin interfaceio.vertx.core.buffer.Buffer- Parameters:
pos- position to start modifying the bufferstr- value to write in the bufferenc- String encoding to use- Returns:
- a reference to
thisso multiple operations can be appended together. - See Also:
Buffer.setString(int, java.lang.String, java.lang.String)
-
length
public int length()
- Specified by:
lengthin interfaceio.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:
copyin interfaceio.vertx.core.buffer.Buffer- Specified by:
copyin interfaceio.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:
slicein interfaceio.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:
slicein interfaceio.vertx.core.buffer.Buffer- Parameters:
start- position to start copy fromend- 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 5Returns the Buffer as a NettyByteBuf.The returned buffer is a duplicate.
The returned
ByteBufmight have itsreaderIndex > 0This method is meant for internal use only.- Specified by:
getByteBufin interfaceio.vertx.core.buffer.Buffer- Returns:
- a Netty
ByteBuf - See Also:
Buffer.getByteBuf()
-
-