Interface Buffer
-
- All Superinterfaces:
ClusterSerializable
,Shareable
public interface Buffer extends ClusterSerializable, Shareable
Most data is shuffled around inside Vert.x using buffers.A buffer is a sequence of zero or more bytes that can read from or written to and which expands automatically as necessary to accommodate any bytes written to it. You can perhaps think of a buffer as smart byte array.
Please consult the documentation for more information on buffers.
- Author:
- Tim Fox
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Buffer
appendBuffer(Buffer buff)
Appends the specifiedBuffer
to the end of this Buffer.Buffer
appendBuffer(Buffer buff, int offset, int len)
Appends the specifiedBuffer
starting at theoffset
usinglen
to the end of this Buffer.Buffer
appendByte(byte b)
Appends the specifiedbyte
to the end of the Buffer.Buffer
appendBytes(byte[] bytes)
Appends the specifiedbyte[]
to the end of the 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.Buffer
appendDouble(double d)
Appends the specifieddouble
to the end of the Buffer.Buffer
appendDoubleLE(double d)
Appends the specified unsigneddouble
to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.Buffer
appendFloat(float f)
Appends the specifiedfloat
to the end of the Buffer.Buffer
appendFloatLE(float f)
Appends the specified unsignedfloat
to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.Buffer
appendInt(int i)
Appends the specifiedint
to the end of the Buffer.Buffer
appendIntLE(int i)
Appends the specifiedint
to the end of the Buffer in the Little Endian Byte Order.Buffer
appendLong(long l)
Appends the specifiedlong
to the end of the Buffer.Buffer
appendLongLE(long l)
Appends the specifiedlong
to the end of the Buffer in the Little Endian Byte Order.Buffer
appendMedium(int i)
Appends the specified 24bitint
to the end of the Buffer.Buffer
appendMediumLE(int i)
Appends the specified 24bitint
to the end of the Buffer in the Little Endian Byte Order.Buffer
appendShort(short s)
Appends the specifiedshort
to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.Buffer
appendShortLE(short s)
Appends the specifiedshort
to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.Buffer
appendString(String str)
Appends the specifiedString str
to the end of the Buffer with UTF-8 encoding.Buffer
appendString(String str, String enc)
Appends the specifiedString
to the end of the Buffer with the encoding as specified byenc
.Buffer
appendUnsignedByte(short b)
Appends the specified unsignedbyte
to the end of the Buffer.Buffer
appendUnsignedInt(long i)
Appends the specified unsignedint
to the end of the Buffer.Buffer
appendUnsignedIntLE(long i)
Appends the specified unsignedint
to the end of the Buffer in the Little Endian Byte Order.Buffer
appendUnsignedShort(int s)
Appends the specified unsignedshort
to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.Buffer
appendUnsignedShortLE(int s)
Appends the specified unsignedshort
to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.static Buffer
buffer()
Create a new, empty buffer.static Buffer
buffer(byte[] bytes)
Create a new buffer from a byte[].static Buffer
buffer(int initialSizeHint)
Create a new buffer given the initial size hint.static Buffer
buffer(String string)
Create a new buffer from a string.static Buffer
buffer(String string, String enc)
Create a new buffer from a string and using the specified encoding.Buffer
copy()
Returns a copy of the entire Buffer.static Buffer
fromJson(String value)
Create a buffer from the base 64 URL encodedvalue
Buffer
getBuffer(int start, int end)
Returns a copy of a sub-sequence the Buffer as aBuffer
starting at positionstart
and ending at positionend - 1
byte
getByte(int pos)
Returns thebyte
at positionpos
in the Buffer.byte[]
getBytes()
Returns a copy of the entire Buffer as abyte[]
Buffer
getBytes(byte[] dst)
Transfers the content of the Buffer into abyte[]
.Buffer
getBytes(byte[] dst, int dstIndex)
Transfers the content of the Buffer into abyte[]
at the specific destination.byte[]
getBytes(int start, int end)
Returns a copy of a sub-sequence the Buffer as abyte[]
starting at positionstart
and ending at positionend - 1
Buffer
getBytes(int start, int end, byte[] dst)
Transfers the content of the Buffer starting at positionstart
and ending at positionend - 1
into abyte[]
.Buffer
getBytes(int start, int end, byte[] dst, int dstIndex)
Transfers the content of the Buffer starting at positionstart
and ending at positionend - 1
into abyte[]
at the specific destination.double
getDouble(int pos)
Returns thedouble
at positionpos
in the Buffer.double
getDoubleLE(int pos)
Gets a double at the specified absoluteindex
in this buffer in Little Endian Byte Order.float
getFloat(int pos)
Returns thefloat
at positionpos
in the Buffer.float
getFloatLE(int pos)
Gets a float at the specified absoluteindex
in this buffer in Little Endian Byte Order.int
getInt(int pos)
Returns theint
at positionpos
in the Buffer.int
getIntLE(int pos)
Gets a 32-bit integer at the specified absoluteindex
in this buffer with Little Endian Byte Order.long
getLong(int pos)
Returns thelong
at positionpos
in the Buffer.long
getLongLE(int pos)
Gets a 64-bit long integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.int
getMedium(int pos)
Gets a 24-bit medium integer at the specified absoluteindex
in this buffer.int
getMediumLE(int pos)
Gets a 24-bit medium integer at the specified absoluteindex
in this buffer in the Little Endian Byte Order.short
getShort(int pos)
Returns theshort
at positionpos
in the Buffer.short
getShortLE(int pos)
Gets a 16-bit short integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.String
getString(int start, int end)
Returns a copy of a sub-sequence the Buffer as aString
starting at positionstart
and ending at positionend - 1
interpreted as a String in UTF-8 encodingString
getString(int start, int end, String enc)
Returns a copy of a sub-sequence the Buffer as aString
starting at positionstart
and ending at positionend - 1
interpreted as a String in the specified encodingshort
getUnsignedByte(int pos)
Returns the unsignedbyte
at positionpos
in the Buffer, as ashort
.long
getUnsignedInt(int pos)
Returns the unsignedint
at positionpos
in the Buffer, as along
.long
getUnsignedIntLE(int pos)
Returns the unsignedint
at positionpos
in the Buffer, as along
in Little Endian Byte Order.int
getUnsignedMedium(int pos)
Gets an unsigned 24-bit medium integer at the specified absoluteindex
in this buffer.int
getUnsignedMediumLE(int pos)
Gets an unsigned 24-bit medium integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.int
getUnsignedShort(int pos)
Returns the unsignedshort
at positionpos
in the Buffer, as anint
.int
getUnsignedShortLE(int pos)
Gets an unsigned 16-bit short integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.int
length()
Returns the length of the buffer, measured in bytes.Buffer
setBuffer(int pos, Buffer b)
Sets the bytes at positionpos
in the Buffer to the bytes represented by theBuffer b
.Buffer
setBuffer(int pos, Buffer b, int offset, int len)
Sets the bytes at positionpos
in the Buffer to the bytes represented by theBuffer b
on the givenoffset
andlen
.Buffer
setByte(int pos, byte b)
Sets thebyte
at positionpos
in the Buffer to the valueb
.Buffer
setBytes(int pos, byte[] b)
Sets the bytes at positionpos
in the Buffer to the bytes represented by thebyte[] b
.Buffer
setBytes(int pos, byte[] b, int offset, int len)
Sets the given number of bytes at positionpos
in the Buffer to the bytes represented by thebyte[] b
.Buffer
setBytes(int pos, ByteBuffer b)
Sets the bytes at positionpos
in the Buffer to the bytes represented by theByteBuffer b
.Buffer
setDouble(int pos, double d)
Sets thedouble
at positionpos
in the Buffer to the valued
.Buffer
setDoubleLE(int pos, double d)
Sets thedouble
at positionpos
in the Buffer to the valued
in the Little Endian Byte Order.Buffer
setFloat(int pos, float f)
Sets thefloat
at positionpos
in the Buffer to the valuef
.Buffer
setFloatLE(int pos, float f)
Sets thefloat
at positionpos
in the Buffer to the valuef
in the Little Endian Byte Order.Buffer
setInt(int pos, int i)
Sets theint
at positionpos
in the Buffer to the valuei
.Buffer
setIntLE(int pos, int i)
Sets theint
at positionpos
in the Buffer to the valuei
in the Little Endian Byte Order.Buffer
setLong(int pos, long l)
Sets thelong
at positionpos
in the Buffer to the valuel
.Buffer
setLongLE(int pos, long l)
Sets thelong
at positionpos
in the Buffer to the valuel
in the Little Endian Byte Order.Buffer
setMedium(int pos, int i)
Sets the 24bitint
at positionpos
in the Buffer to the valuei
.Buffer
setMediumLE(int pos, int i)
Sets the 24bitint
at positionpos
in the Buffer to the valuei
.Buffer
setShort(int pos, short s)
Sets theshort
at positionpos
in the Buffer to the values
.Buffer
setShortLE(int pos, short s)
Sets theshort
at positionpos
in the Buffer to the values
in the Little Endian Byte Order.Buffer
setString(int pos, String str)
Sets the bytes at positionpos
in the Buffer to the value ofstr
encoded in UTF-8.Buffer
setString(int pos, String str, String enc)
Sets the bytes at positionpos
in the Buffer to the value ofstr
encoded in encodingenc
.Buffer
setUnsignedByte(int pos, short b)
Sets the unsignedbyte
at positionpos
in the Buffer to the valueb
.Buffer
setUnsignedInt(int pos, long i)
Sets the unsignedint
at positionpos
in the Buffer to the valuei
.Buffer
setUnsignedIntLE(int pos, long i)
Sets the unsignedint
at positionpos
in the Buffer to the valuei
in the Little Endian Byte Order.Buffer
setUnsignedShort(int pos, int s)
Sets the unsignedshort
at positionpos
in the Buffer to the values
.Buffer
setUnsignedShortLE(int pos, int s)
Sets the unsignedshort
at positionpos
in the Buffer to the values
in the Little Endian Byte Order.Buffer
slice()
Returns a slice of this buffer.Buffer
slice(int start, int end)
Returns a slice of this buffer.default String
toJson()
Encode the buffer bytes to their base 64 URL encoded representation.JsonArray
toJsonArray()
Returns aJsonArray
representation of this buffer's content.JsonObject
toJsonObject()
Returns aJsonObject
representation of this buffer's content.default Object
toJsonValue()
Returns a Json value representation of this buffer's content.String
toString()
Returns aString
representation of the Buffer with theUTF-8
encodingString
toString(String enc)
Returns aString
representation of the Buffer with the encoding specified byenc
String
toString(Charset enc)
Returns aString
representation of the Buffer with the encoding specified byenc
-
Methods inherited from interface io.vertx.core.shareddata.ClusterSerializable
readFromBuffer, writeToBuffer
-
-
-
-
Method Detail
-
fromJson
static Buffer fromJson(String value)
Create a buffer from the base 64 URL encodedvalue
- Parameters:
value
- the base64 encoded value- Returns:
- the buffer
-
buffer
static Buffer buffer()
Create a new, empty buffer.- Returns:
- the buffer
-
buffer
static Buffer buffer(int initialSizeHint)
Create a new buffer given the initial size hint.If you know the buffer will require a certain size, providing the hint can prevent unnecessary re-allocations as the buffer is written to and resized.
- Parameters:
initialSizeHint
- the hint, in bytes- Returns:
- the buffer
-
buffer
static Buffer buffer(String string)
Create a new buffer from a string. The string will be UTF-8 encoded into the buffer.- Parameters:
string
- the string- Returns:
- the buffer
-
buffer
static Buffer buffer(String string, String enc)
Create a new buffer from a string and using the specified encoding. The string will be encoded into the buffer using the specified encoding.- Parameters:
string
- the string- Returns:
- the buffer
-
buffer
static Buffer buffer(byte[] bytes)
Create a new buffer from a byte[]. The byte[] will be copied to form the buffer.- Parameters:
bytes
- the byte array- Returns:
- the buffer
-
toString
String toString()
Returns aString
representation of the Buffer with theUTF-8
encoding
-
toString
String toString(String enc)
Returns aString
representation of the Buffer with the encoding specified byenc
-
toString
String toString(Charset enc)
Returns aString
representation of the Buffer with the encoding specified byenc
-
toJsonObject
JsonObject toJsonObject()
Returns aJsonObject
representation of this buffer's content.
-
toJsonValue
default Object toJsonValue()
Returns a Json value representation of this buffer's content.- Returns:
- a Json value which can be a
JsonArray
,JsonObject
,String
, ... if the buffer contains an array, object, string, ...etc
-
toJson
default String toJson()
Encode the buffer bytes to their base 64 URL encoded representation.
-
getByte
byte getByte(int pos)
Returns thebyte
at positionpos
in the Buffer.- Throws:
IndexOutOfBoundsException
- if the specifiedpos
is less than0
orpos + 1
is greater than the length of the Buffer.
-
getUnsignedByte
short getUnsignedByte(int pos)
Returns the unsignedbyte
at positionpos
in the Buffer, as ashort
.- Throws:
IndexOutOfBoundsException
- if the specifiedpos
is less than0
orpos + 1
is greater than the length of the Buffer.
-
getInt
int getInt(int pos)
Returns theint
at positionpos
in the Buffer.- Throws:
IndexOutOfBoundsException
- if the specifiedpos
is less than0
orpos + 4
is greater than the length of the Buffer.
-
getIntLE
int getIntLE(int pos)
Gets a 32-bit integer at the specified absoluteindex
in this buffer with Little Endian Byte Order.- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
getUnsignedInt
long getUnsignedInt(int pos)
Returns the unsignedint
at positionpos
in the Buffer, as along
.- Throws:
IndexOutOfBoundsException
- if the specifiedpos
is less than0
orpos + 4
is greater than the length of the Buffer.
-
getUnsignedIntLE
long getUnsignedIntLE(int pos)
Returns the unsignedint
at positionpos
in the Buffer, as along
in Little Endian Byte Order.- Throws:
IndexOutOfBoundsException
- if the specifiedpos
is less than0
orpos + 4
is greater than the length of the Buffer.
-
getLong
long getLong(int pos)
Returns thelong
at positionpos
in the Buffer.- Throws:
IndexOutOfBoundsException
- if the specifiedpos
is less than0
orpos + 8
is greater than the length of the Buffer.
-
getLongLE
long getLongLE(int pos)
Gets a 64-bit long integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 8
is greater than the length of the Buffer.
-
getDouble
double getDouble(int pos)
Returns thedouble
at positionpos
in the Buffer.- Throws:
IndexOutOfBoundsException
- if the specifiedpos
is less than0
orpos + 8
is greater than the length of the Buffer.
-
getDoubleLE
double getDoubleLE(int pos)
Gets a double at the specified absoluteindex
in this buffer in Little Endian Byte Order.- Throws:
IndexOutOfBoundsException
- if the specifiedpos
is less than0
orpos + 8
is greater than the length of the Buffer.
-
getFloat
float getFloat(int pos)
Returns thefloat
at positionpos
in the Buffer.- Throws:
IndexOutOfBoundsException
- if the specifiedpos
is less than0
orpos + 4
is greater than the length of the Buffer.
-
getFloatLE
float getFloatLE(int pos)
Gets a float at the specified absoluteindex
in this buffer in Little Endian Byte Order.- Throws:
IndexOutOfBoundsException
- if the specifiedpos
is less than0
orpos + 4
is greater than the length of the Buffer.
-
getShort
short getShort(int pos)
Returns theshort
at positionpos
in the Buffer.- Throws:
IndexOutOfBoundsException
- if the specifiedpos
is less than0
orpos + 2
is greater than the length of the Buffer.
-
getShortLE
short getShortLE(int pos)
Gets a 16-bit short integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 2
is greater than the length of the Buffer.
-
getUnsignedShort
int getUnsignedShort(int pos)
Returns the unsignedshort
at positionpos
in the Buffer, as anint
.- Throws:
IndexOutOfBoundsException
- if the specifiedpos
is less than0
orpos + 2
is greater than the length of the Buffer.
-
getUnsignedShortLE
int getUnsignedShortLE(int pos)
Gets an unsigned 16-bit short integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 2
is greater than the length of the Buffer.
-
getMedium
int getMedium(int pos)
Gets a 24-bit medium integer at the specified absoluteindex
in this buffer.- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 3
is greater than the length of the Buffer.
-
getMediumLE
int getMediumLE(int pos)
Gets a 24-bit medium integer at the specified absoluteindex
in this buffer in the Little Endian Byte Order.- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 3
is greater than the length of the Buffer.
-
getUnsignedMedium
int getUnsignedMedium(int pos)
Gets an unsigned 24-bit medium integer at the specified absoluteindex
in this buffer.- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 3
is greater than the length of the Buffer.
-
getUnsignedMediumLE
int getUnsignedMediumLE(int pos)
Gets an unsigned 24-bit medium integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 3
is greater than the length of the Buffer.
-
getBytes
byte[] getBytes()
Returns a copy of the entire Buffer as abyte[]
-
getBytes
byte[] getBytes(int start, int end)
Returns a copy of a sub-sequence the Buffer as abyte[]
starting at positionstart
and ending at positionend - 1
-
getBytes
Buffer getBytes(byte[] dst)
Transfers the content of the Buffer into abyte[]
.- Parameters:
dst
- the destination byte array- Throws:
IndexOutOfBoundsException
- if the content of the Buffer cannot fit into the destination byte array
-
getBytes
Buffer getBytes(byte[] dst, int dstIndex)
Transfers the content of the Buffer into abyte[]
at the specific destination.- Parameters:
dst
- the destination byte array- Throws:
IndexOutOfBoundsException
- if the content of the Buffer cannot fit into the destination byte array
-
getBytes
Buffer getBytes(int start, int end, byte[] dst)
Transfers the content of the Buffer starting at positionstart
and ending at positionend - 1
into abyte[]
.- Parameters:
dst
- the destination byte array- Throws:
IndexOutOfBoundsException
- if the content of the Buffer cannot fit into the destination byte array
-
getBytes
Buffer getBytes(int start, int end, byte[] dst, int dstIndex)
Transfers the content of the Buffer starting at positionstart
and ending at positionend - 1
into abyte[]
at the specific destination.- Parameters:
dst
- the destination byte array- Throws:
IndexOutOfBoundsException
- if the content of the Buffer cannot fit into the destination byte array
-
getBuffer
Buffer getBuffer(int start, int end)
Returns a copy of a sub-sequence the Buffer as aBuffer
starting at positionstart
and ending at positionend - 1
-
getString
String getString(int start, int end, String enc)
Returns a copy of a sub-sequence the Buffer as aString
starting at positionstart
and ending at positionend - 1
interpreted as a String in the specified encoding
-
getString
String getString(int start, int end)
Returns a copy of a sub-sequence the Buffer as aString
starting at positionstart
and ending at positionend - 1
interpreted as a String in UTF-8 encoding
-
appendBuffer
Buffer appendBuffer(Buffer buff)
Appends the specifiedBuffer
to the end of this Buffer. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendBuffer
Buffer appendBuffer(Buffer buff, int offset, int len)
Appends the specifiedBuffer
starting at theoffset
usinglen
to the end of this Buffer. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendBytes
Buffer appendBytes(byte[] bytes)
Appends the specifiedbyte[]
to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendBytes
Buffer appendBytes(byte[] bytes, int offset, int len)
Appends the specified number of bytes frombyte[]
to the end of the Buffer, starting at the given offset. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendByte
Buffer appendByte(byte b)
Appends the specifiedbyte
to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendUnsignedByte
Buffer appendUnsignedByte(short b)
Appends the specified unsignedbyte
to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendInt
Buffer appendInt(int i)
Appends the specifiedint
to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendIntLE
Buffer appendIntLE(int i)
Appends the specifiedint
to the end of the Buffer in the Little Endian Byte Order. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendUnsignedInt
Buffer appendUnsignedInt(long i)
Appends the specified unsignedint
to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendUnsignedIntLE
Buffer appendUnsignedIntLE(long i)
Appends the specified unsignedint
to the end of the Buffer in the Little Endian Byte Order. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendMedium
Buffer appendMedium(int i)
Appends the specified 24bitint
to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendMediumLE
Buffer appendMediumLE(int i)
Appends the specified 24bitint
to the end of the Buffer in the Little Endian Byte Order. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendLong
Buffer appendLong(long l)
Appends the specifiedlong
to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendLongLE
Buffer appendLongLE(long l)
Appends the specifiedlong
to the end of the Buffer in the Little Endian Byte Order. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendShort
Buffer appendShort(short s)
Appends the specifiedshort
to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendShortLE
Buffer appendShortLE(short s)
Appends the specifiedshort
to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendUnsignedShort
Buffer appendUnsignedShort(int s)
Appends the specified unsignedshort
to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendUnsignedShortLE
Buffer appendUnsignedShortLE(int s)
Appends the specified unsignedshort
to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendFloat
Buffer appendFloat(float f)
Appends the specifiedfloat
to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendFloatLE
Buffer appendFloatLE(float f)
Appends the specified unsignedfloat
to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendDouble
Buffer appendDouble(double d)
Appends the specifieddouble
to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendDoubleLE
Buffer appendDoubleLE(double d)
Appends the specified unsigneddouble
to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.Returns a reference to
this
so multiple operations can be appended together.
-
appendString
Buffer appendString(String str, String enc)
Appends the specifiedString
to the end of the Buffer with the encoding as specified byenc
.The buffer will expand as necessary to accommodate any bytes written.
Returns a reference to
this
so multiple operations can be appended together.
-
appendString
Buffer appendString(String str)
Appends the specifiedString str
to the end of the Buffer with UTF-8 encoding.The buffer will expand as necessary to accommodate any bytes written.
Returns a reference to
this
so multiple operations can be appended together
-
setByte
Buffer setByte(int pos, byte b)
Sets thebyte
at positionpos
in the Buffer to the valueb
.The buffer will expand as necessary to accommodate any value written.
-
setUnsignedByte
Buffer setUnsignedByte(int pos, short b)
Sets the unsignedbyte
at positionpos
in the Buffer to the valueb
.The buffer will expand as necessary to accommodate any value written.
-
setInt
Buffer setInt(int pos, int i)
Sets theint
at positionpos
in the Buffer to the valuei
.The buffer will expand as necessary to accommodate any value written.
-
setIntLE
Buffer setIntLE(int pos, int i)
Sets theint
at positionpos
in the Buffer to the valuei
in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any value written.
-
setUnsignedInt
Buffer setUnsignedInt(int pos, long i)
Sets the unsignedint
at positionpos
in the Buffer to the valuei
.The buffer will expand as necessary to accommodate any value written.
-
setUnsignedIntLE
Buffer setUnsignedIntLE(int pos, long i)
Sets the unsignedint
at positionpos
in the Buffer to the valuei
in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any value written.
-
setMedium
Buffer setMedium(int pos, int i)
Sets the 24bitint
at positionpos
in the Buffer to the valuei
.The buffer will expand as necessary to accommodate any value written.
-
setMediumLE
Buffer setMediumLE(int pos, int i)
Sets the 24bitint
at positionpos
in the Buffer to the valuei
. in the Little Endian Byte OrderThe buffer will expand as necessary to accommodate any value written.
-
setLong
Buffer setLong(int pos, long l)
Sets thelong
at positionpos
in the Buffer to the valuel
.The buffer will expand as necessary to accommodate any value written.
-
setLongLE
Buffer setLongLE(int pos, long l)
Sets thelong
at positionpos
in the Buffer to the valuel
in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any value written.
-
setDouble
Buffer setDouble(int pos, double d)
Sets thedouble
at positionpos
in the Buffer to the valued
.The buffer will expand as necessary to accommodate any value written.
-
setDoubleLE
Buffer setDoubleLE(int pos, double d)
Sets thedouble
at positionpos
in the Buffer to the valued
in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any value written.
-
setFloat
Buffer setFloat(int pos, float f)
Sets thefloat
at positionpos
in the Buffer to the valuef
.The buffer will expand as necessary to accommodate any value written.
-
setFloatLE
Buffer setFloatLE(int pos, float f)
Sets thefloat
at positionpos
in the Buffer to the valuef
in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any value written.
-
setShort
Buffer setShort(int pos, short s)
Sets theshort
at positionpos
in the Buffer to the values
.The buffer will expand as necessary to accommodate any value written.
-
setShortLE
Buffer setShortLE(int pos, short s)
Sets theshort
at positionpos
in the Buffer to the values
in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any value written.
-
setUnsignedShort
Buffer setUnsignedShort(int pos, int s)
Sets the unsignedshort
at positionpos
in the Buffer to the values
.The buffer will expand as necessary to accommodate any value written.
-
setUnsignedShortLE
Buffer setUnsignedShortLE(int pos, int s)
Sets the unsignedshort
at positionpos
in the Buffer to the values
in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any value written.
-
setBuffer
Buffer setBuffer(int pos, Buffer b)
Sets the bytes at positionpos
in the Buffer to the bytes represented by theBuffer b
.The buffer will expand as necessary to accommodate any value written.
-
setBuffer
Buffer setBuffer(int pos, Buffer b, int offset, int len)
Sets the bytes at positionpos
in the Buffer to the bytes represented by theBuffer b
on the givenoffset
andlen
.The buffer will expand as necessary to accommodate any value written.
-
setBytes
Buffer setBytes(int pos, ByteBuffer b)
Sets the bytes at positionpos
in the Buffer to the bytes represented by theByteBuffer b
.The buffer will expand as necessary to accommodate any value written.
-
setBytes
Buffer setBytes(int pos, byte[] b)
Sets the bytes at positionpos
in the Buffer to the bytes represented by thebyte[] b
.The buffer will expand as necessary to accommodate any value written.
-
setBytes
Buffer setBytes(int pos, byte[] b, int offset, int len)
Sets the given number of bytes at positionpos
in the Buffer to the bytes represented by thebyte[] b
. The buffer will expand as necessary to accommodate any value written.
-
setString
Buffer setString(int pos, String str)
Sets the bytes at positionpos
in the Buffer to the value ofstr
encoded in UTF-8.The buffer will expand as necessary to accommodate any value written.
-
setString
Buffer setString(int pos, String str, String enc)
Sets the bytes at positionpos
in the Buffer to the value ofstr
encoded in encodingenc
.The buffer will expand as necessary to accommodate any value written.
-
length
int length()
Returns the length of the buffer, measured in bytes. All positions are indexed from zero.
-
slice
Buffer slice()
Returns a slice of this buffer. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks.
-
slice
Buffer slice(int start, int end)
Returns a slice of this buffer. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks.
-
-