public class BufferImpl extends Object implements Buffer
Modifier and Type | Method and Description |
---|---|
Buffer |
appendBuffer(Buffer buff)
Appends the specified
Buffer to the end of this Buffer. |
Buffer |
appendBuffer(Buffer buff,
int offset,
int len)
Appends the specified
Buffer starting at the offset using len to the end of this Buffer. |
Buffer |
appendByte(byte b)
Appends the specified
byte to the end of the Buffer. |
Buffer |
appendBytes(byte[] bytes)
Appends the specified
byte[] to the end of the 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. |
Buffer |
appendDouble(double d)
Appends the specified
double to the end of the Buffer. |
Buffer |
appendFloat(float f)
Appends the specified
float to the end of the Buffer. |
Buffer |
appendInt(int i)
Appends the specified
int to the end of the Buffer. |
Buffer |
appendLong(long l)
Appends the specified
long to the end of the Buffer. |
Buffer |
appendShort(short s)
Appends the specified
short to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written. |
Buffer |
appendString(String str)
Appends the specified
String str to the end of the Buffer with UTF-8 encoding. |
Buffer |
appendString(String str,
String enc)
Appends the specified
String to the end of the Buffer with the encoding as specified by enc . |
Buffer |
copy()
Returns a copy of the entire Buffer.
|
boolean |
equals(Object o) |
Buffer |
getBuffer(int start,
int end)
Returns a copy of a sub-sequence the Buffer as a
Buffer starting at position start
and ending at position end - 1 |
byte |
getByte(int pos)
Returns the
byte at position pos in the Buffer. |
io.netty.buffer.ByteBuf |
getByteBuf()
Returns the Buffer as a Netty
ByteBuf . |
byte[] |
getBytes()
Returns a copy of the entire Buffer as a
byte[] |
byte[] |
getBytes(int start,
int end)
Returns a copy of a sub-sequence the Buffer as a
byte[] starting at position start
and ending at position end - 1 |
double |
getDouble(int pos)
Returns the
double at position pos in the Buffer. |
float |
getFloat(int pos)
Returns the
float at position pos in the Buffer. |
int |
getInt(int pos)
Returns the
int at position pos in the Buffer. |
long |
getLong(int pos)
Returns the
long at position pos in the Buffer. |
short |
getShort(int pos)
Returns the
short at position pos in the Buffer. |
String |
getString(int start,
int end)
Returns a copy of a sub-sequence the Buffer as a
String starting at position start
and ending at position end - 1 interpreted as a String in UTF-8 encoding |
String |
getString(int start,
int end,
String enc)
Returns a copy of a sub-sequence the Buffer as a
String starting at position start
and ending at position end - 1 interpreted as a String in the specified encoding |
int |
hashCode() |
int |
length()
Returns the length of the buffer, measured in bytes.
|
int |
readFromBuffer(int pos,
Buffer buffer) |
Buffer |
setBuffer(int pos,
Buffer b)
Sets the bytes at position
pos in the Buffer to the bytes represented by the Buffer b . |
Buffer |
setBuffer(int pos,
Buffer b,
int offset,
int len)
Sets the bytes at position
pos in the Buffer to the bytes represented by the Buffer b on the given offset and len . |
Buffer |
setByte(int pos,
byte b)
Sets the
byte at position pos in the Buffer to the value b . |
Buffer |
setBytes(int pos,
byte[] b)
Sets the bytes at position
pos in the Buffer to the bytes represented by the byte[] b . |
Buffer |
setBytes(int pos,
byte[] b,
int offset,
int len)
Sets the given number of bytes at position
pos in the Buffer to the bytes represented by the byte[] b . |
BufferImpl |
setBytes(int pos,
ByteBuffer b)
Sets the bytes at position
pos in the Buffer to the bytes represented by the ByteBuffer b . |
Buffer |
setDouble(int pos,
double d)
Sets the
double at position pos in the Buffer to the value d . |
Buffer |
setFloat(int pos,
float f)
Sets the
float at position pos in the Buffer to the value f . |
Buffer |
setInt(int pos,
int i)
Sets the
int at position pos in the Buffer to the value i . |
Buffer |
setLong(int pos,
long l)
Sets the
long at position pos in the Buffer to the value l . |
Buffer |
setShort(int pos,
short s)
Sets the
short at position pos in the Buffer to the value s . |
Buffer |
setString(int pos,
String str)
Sets the bytes at position
pos in the Buffer to the value of str encoded in UTF-8. |
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 . |
Buffer |
slice()
Returns a slice of this buffer.
|
Buffer |
slice(int start,
int end)
Returns a slice of this buffer.
|
String |
toString() |
String |
toString(String enc)
Returns a
String representation of the Buffer with the encoding specified by enc |
void |
writeToBuffer(Buffer buff) |
public String toString(String enc)
Buffer
String
representation of the Buffer with the encoding specified by enc
public byte getByte(int pos)
Buffer
byte
at position pos
in the Buffer.public int getInt(int pos)
Buffer
int
at position pos
in the Buffer.public long getLong(int pos)
Buffer
long
at position pos
in the Buffer.public double getDouble(int pos)
Buffer
double
at position pos
in the Buffer.public float getFloat(int pos)
Buffer
float
at position pos
in the Buffer.public short getShort(int pos)
Buffer
short
at position pos
in the Buffer.public byte[] getBytes()
Buffer
byte[]
public byte[] getBytes(int start, int end)
Buffer
byte[]
starting at position start
and ending at position end - 1
public Buffer getBuffer(int start, int end)
Buffer
Buffer
starting at position start
and ending at position end - 1
public String getString(int start, int end, String enc)
Buffer
String
starting at position start
and ending at position end - 1
interpreted as a String in the specified encodingpublic String getString(int start, int end)
Buffer
String
starting at position start
and ending at position end - 1
interpreted as a String in UTF-8 encodingpublic Buffer appendBuffer(Buffer buff)
Buffer
Buffer
to the end of this Buffer. The buffer will expand as necessary to accommodate
any bytes written.
Returns a reference to this
so multiple operations can be appended together.
appendBuffer
in interface Buffer
public Buffer appendBuffer(Buffer buff, int offset, int len)
Buffer
Buffer
starting at the offset
using len
to the end of this Buffer. The buffer will expand as necessary to accommodate
any bytes written.
Returns a reference to this
so multiple operations can be appended together.
appendBuffer
in interface Buffer
public Buffer appendBytes(byte[] bytes)
Buffer
byte[]
to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.
Returns a reference to this
so multiple operations can be appended together.
appendBytes
in interface Buffer
public Buffer appendBytes(byte[] bytes, int offset, int len)
Buffer
byte[]
to the end of the Buffer, starting at the given offset.
The buffer will expand as necessary to accommodate any bytes written.
Returns a reference to this
so multiple operations can be appended together.
appendBytes
in interface Buffer
public Buffer appendByte(byte b)
Buffer
byte
to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.
Returns a reference to this
so multiple operations can be appended together.
appendByte
in interface Buffer
public Buffer appendInt(int i)
Buffer
int
to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.
Returns a reference to this
so multiple operations can be appended together.
public Buffer appendLong(long l)
Buffer
long
to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.
Returns a reference to this
so multiple operations can be appended together.
appendLong
in interface Buffer
public Buffer appendShort(short s)
Buffer
short
to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.
Returns a reference to this
so multiple operations can be appended together.
appendShort
in interface Buffer
public Buffer appendFloat(float f)
Buffer
float
to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.
Returns a reference to this
so multiple operations can be appended together.
appendFloat
in interface Buffer
public Buffer appendDouble(double d)
Buffer
double
to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.
Returns a reference to this
so multiple operations can be appended together.
appendDouble
in interface Buffer
public Buffer appendString(String str, String enc)
Buffer
String
to the end of the Buffer with the encoding as specified by enc
.The buffer will expand as necessary to accommodate any bytes written.
Returns a reference to this
so multiple operations can be appended together.
appendString
in interface Buffer
public Buffer appendString(String str)
Buffer
String str
to the end of the Buffer with UTF-8 encoding.The buffer will expand as necessary to accommodate any bytes written.
Returns a reference to this
so multiple operations can be appended together
appendString
in interface Buffer
public Buffer setByte(int pos, byte b)
Buffer
byte
at position pos
in the Buffer to the value b
.The buffer will expand as necessary to accommodate any value written.
public Buffer setInt(int pos, int i)
Buffer
int
at position pos
in the Buffer to the value i
.The buffer will expand as necessary to accommodate any value written.
public Buffer setLong(int pos, long l)
Buffer
long
at position pos
in the Buffer to the value l
.The buffer will expand as necessary to accommodate any value written.
public Buffer setDouble(int pos, double d)
Buffer
double
at position pos
in the Buffer to the value d
.The buffer will expand as necessary to accommodate any value written.
public Buffer setFloat(int pos, float f)
Buffer
float
at position pos
in the Buffer to the value f
.The buffer will expand as necessary to accommodate any value written.
public Buffer setShort(int pos, short s)
Buffer
short
at position pos
in the Buffer to the value s
.The buffer will expand as necessary to accommodate any value written.
public Buffer setBuffer(int pos, Buffer b)
Buffer
pos
in the Buffer to the bytes represented by the Buffer b
.The buffer will expand as necessary to accommodate any value written.
public Buffer setBuffer(int pos, Buffer b, int offset, int len)
Buffer
pos
in the Buffer to the bytes represented by the Buffer b
on the given offset
and len
.The buffer will expand as necessary to accommodate any value written.
public BufferImpl setBytes(int pos, ByteBuffer b)
Buffer
pos
in the Buffer to the bytes represented by the ByteBuffer b
.The buffer will expand as necessary to accommodate any value written.
public Buffer setBytes(int pos, byte[] b)
Buffer
pos
in the Buffer to the bytes represented by the byte[] b
.The buffer will expand as necessary to accommodate any value written.
public Buffer setBytes(int pos, byte[] b, int offset, int len)
Buffer
pos
in the Buffer to the bytes represented by the byte[] b
.
The buffer will expand as necessary to accommodate any value written.public Buffer setString(int pos, String str)
Buffer
pos
in the Buffer to the value of str
encoded in UTF-8.The buffer will expand as necessary to accommodate any value written.
public Buffer setString(int pos, String str, String enc)
Buffer
pos
in the Buffer to the value of str
encoded in encoding enc
.The buffer will expand as necessary to accommodate any value written.
public int length()
Buffer
public Buffer copy()
Buffer
public Buffer slice()
Buffer
public Buffer slice(int start, int end)
Buffer
public io.netty.buffer.ByteBuf getByteBuf()
Buffer
ByteBuf
.This method is meant for internal use only.
getByteBuf
in interface Buffer
public void writeToBuffer(Buffer buff)
writeToBuffer
in interface ClusterSerializable
public int readFromBuffer(int pos, Buffer buffer)
readFromBuffer
in interface ClusterSerializable
Copyright © 2015. All Rights Reserved.