|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.vertx.java.core.buffer.Buffer
org.vertx.groovy.core.buffer.Buffer
class Buffer extends Buffer
A Buffer represents a sequence of zero or more bytes that can be written to or read from, and which expands as necessary to accomodate any bytes written to it.
There are two ways to write data to a Buffer: The first method involves methods that take the form setXXX. These methods write data into the buffer starting at the specified position. The position does not have to be inside data that has already been written to the buffer; the buffer will automatically expand to encompass the position plus any data that needs to be written. All positions are measured in bytes and start with zero.
The second method involves methods that take the form appendXXX; these methods append data at the end of the buffer.
Methods exist to both set and append all primitive types, java.lang.String, java.nio.ByteBuffer and other instances of Buffer.
Data can be read from a buffer by invoking methods which take the form getXXX. These methods take a parameter representing the position in the Buffer from where to read data.
Methods putAt and getAt are defined allowing you to use index notation to get/set bytes at a specific position in the buffer.
Methods leftShift are defined to mean append allowing you to use the familiar Groovy << operator on buffers.
Constructor Summary | |
Buffer()
Create an empty buffer |
|
Buffer(int initialSizeHint)
Creates a new empty Buffer that is expected to have a size of initialSizeHint after data has been written to it. |
|
Buffer(byte[] bytes)
Create a new Buffer that contains the contents of a byte[] |
|
Buffer(java.lang.String str, java.lang.String enc)
Create a new Buffer that contains the contents of a String str encoded according to the encoding enc |
|
Buffer(java.lang.String str)
Create a new Buffer that contains the contents of String str encoded with UTF-8 encoding |
Method Summary | |
---|---|
Buffer
|
appendBuffer(Buffer buff)
Appends the specified Buffer 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
|
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 accomodate any bytes written. |
Buffer
|
appendString(java.lang.String str, java.lang.String enc)
Appends the specified String to the end of the Buffer with the encoding as specified by enc. |
Buffer
|
appendString(java.lang.String str)
Appends the specified String str to the end of the Buffer with UTF-8 encoding. |
Buffer
|
copy()
Returns a copy of the entire Buffer. |
byte
|
getAt(int pos)
Same as getByte(int) |
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. |
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. |
int
|
getLength()
Synonym for length |
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. |
java.lang.String
|
getString(int start, int end, java.lang.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 |
java.lang.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 |
int
|
hashCode()
|
Buffer
|
leftShift(Buffer buff)
Same as appendBuffer(Buffer) |
Buffer
|
leftShift(byte[] bytes)
Same as appendBytes(byte[]) |
Buffer
|
leftShift(byte b)
Same as appendByte(byte) |
Buffer
|
leftShift(int i)
Same as appendInt(int) |
Buffer
|
leftShift(long l)
Same as appendLong(long) |
Buffer
|
leftShift(short s)
Same as appendShort(short) |
Buffer
|
leftShift(float f)
Same as appendFloat(float) |
Buffer
|
leftShift(double d)
Same as appendDouble(double) |
Buffer
|
leftShift(java.lang.String s)
Same as appendString(String) |
int
|
length()
Returns the length of the buffer, measured in bytes. |
void
|
putAt(int pos, byte b)
Same as setByte(int, byte) |
void
|
putAt(int pos, int i)
Same as setInt(int, int) |
void
|
putAt(int pos, long l)
Same as setLong(int, long) |
void
|
putAt(int pos, double d)
Same as setDouble(int, double) |
void
|
putAt(int pos, float f)
Same as setFloat(int, float) |
void
|
putAt(int pos, short s)
Same as setShort(int, short) |
void
|
putAt(int pos, Buffer b)
Same as setBuffer(int, Buffer) |
void
|
putAt(int pos, java.nio.ByteBuffer b)
Same as setBytes(int, ByteBuffer) |
void
|
putAt(int pos, byte[] b)
Same as setBytes(int, byte[]) |
void
|
putAt(int pos, java.lang.String str)
Same as setString(int, String) |
Buffer
|
setBuffer(int pos, Buffer b)
Sets the bytes at position pos in the Buffer to the bytes represented by the Buffer b. |
Buffer
|
setByte(int pos, byte b)
Sets the byte at position pos in the Buffer to the value b. |
Buffer
|
setBytes(int pos, java.nio.ByteBuffer b)
Sets the bytes at position pos in the Buffer to the bytes represented by the ByteBuffer 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
|
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, java.lang.String str)
Sets the bytes at position pos in the Buffer to the value of str endoded in UTF-8. |
Buffer
|
setString(int pos, java.lang.String str, java.lang.String enc)
Sets the bytes at position pos in the Buffer to the value of str encoded in encoding enc. |
JBuffer
|
toJavaBuffer()
Returns the underlying Java buffer |
java.lang.String
|
toString()
Returns a String represention of the Buffer with the encoding specified by enc |
Constructor Detail |
---|
Buffer()
Buffer(int initialSizeHint)
Please note that length of the Buffer immediately after creation will be zero.
The initialSizeHint is merely a hint to the system for how much memory to initially allocate to the buffer to prevent excessive automatic re-allocations as data is written to it.
Buffer(byte[] bytes)
Buffer(java.lang.String str, java.lang.String enc)
Buffer(java.lang.String str)
Method Detail |
---|
Buffer appendBuffer(Buffer buff)
Returns a reference to this so multiple operations can be appended together.
Buffer appendByte(byte b)
Returns a reference to this so multiple operations can be appended together.
Buffer appendBytes(byte[] bytes)
Returns a reference to this so multiple operations can be appended together.
Buffer appendDouble(double d)
Returns a reference to this so multiple operations can be appended together.
Buffer appendFloat(float f)
Returns a reference to this so multiple operations can be appended together.
Buffer appendInt(int i)
Returns a reference to this so multiple operations can be appended together.
Buffer appendLong(long l)
Returns a reference to this so multiple operations can be appended together.
Buffer appendShort(short s)
Returns a reference to this so multiple operations can be appended together.
Buffer appendString(java.lang.String str, java.lang.String enc)
The buffer will expand as necessary to accomodate any bytes written.
Returns a reference to this so multiple operations can be appended together.
Buffer appendString(java.lang.String str)
The buffer will expand as necessary to accomodate any bytes written.
Returns a reference to this so multiple operations can be appended together
Buffer copy()
byte getAt(int pos)
Buffer getBuffer(int start, int end)
byte getByte(int pos)
byte[] getBytes()
byte[] getBytes(int start, int end)
double getDouble(int pos)
float getFloat(int pos)
int getInt(int pos)
int getLength()
long getLong(int pos)
short getShort(int pos)
java.lang.String getString(int start, int end, java.lang.String enc)
java.lang.String getString(int start, int end)
int hashCode()
Buffer leftShift(Buffer buff)
Buffer leftShift(byte[] bytes)
Buffer leftShift(byte b)
Buffer leftShift(int i)
Buffer leftShift(long l)
Buffer leftShift(short s)
Buffer leftShift(float f)
Buffer leftShift(double d)
Buffer leftShift(java.lang.String s)
int length()
void putAt(int pos, byte b)
void putAt(int pos, int i)
void putAt(int pos, long l)
void putAt(int pos, double d)
void putAt(int pos, float f)
void putAt(int pos, short s)
void putAt(int pos, Buffer b)
void putAt(int pos, java.nio.ByteBuffer b)
void putAt(int pos, byte[] b)
void putAt(int pos, java.lang.String str)
Buffer setBuffer(int pos, Buffer b)
The buffer will expand as necessary to accomodate any value written.
Buffer setByte(int pos, byte b)
The buffer will expand as necessary to accomodate any value written.
Buffer setBytes(int pos, java.nio.ByteBuffer b)
The buffer will expand as necessary to accomodate any value written.
Buffer setBytes(int pos, byte[] b)
The buffer will expand as necessary to accomodate any value written.
Buffer setDouble(int pos, double d)
The buffer will expand as necessary to accomodate any value written.
Buffer setFloat(int pos, float f)
The buffer will expand as necessary to accomodate any value written.
Buffer setInt(int pos, int i)
The buffer will expand as necessary to accomodate any value written.
Buffer setLong(int pos, long l)
The buffer will expand as necessary to accomodate any value written.
Buffer setShort(int pos, short s)
The buffer will expand as necessary to accomodate any value written.
Buffer setString(int pos, java.lang.String str)
The buffer will expand as necessary to accomodate any value written.
Buffer setString(int pos, java.lang.String str, java.lang.String enc)
The buffer will expand as necessary to accomodate any value written.
JBuffer toJavaBuffer()
java.lang.String toString()
Groovy Documentation