Package io.gravitee.gateway.api.buffer
Interface Buffer
public interface Buffer
Mainly inspired by Vertx.io
- Author:
- David BRASSELY (david at gravitee.io), GraviteeSource Team
- See Also:
-
Buffer
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription@NonNull BufferappendBuffer(Buffer buff) Appends the specifiedBufferto the current one.appendBuffer(Buffer buff, int length) Appends the firstlengthbytes of the specifiedBufferto the current one.appendString(String str) Appends the specifiedStringto the current one.appendString(String str, String charset) Appends the specifiedStringwith the given charset to the current one.static Bufferbuffer()Creates an empty buffer.static Bufferbuffer(byte[] bytes) Creates a buffer from the specified byte array.static Bufferbuffer(int initialSizeHint) Creates an empty buffer with reserved space.static Bufferbuffer(io.netty.buffer.ByteBuf nativeBuffer) Creates a buffer from a nettyByteBuf.static Bufferbuffer(io.vertx.core.buffer.Buffer vertxBuffer) Creates a buffer from a vertxBuffer.static Bufferbuffer(io.vertx.rxjava3.core.buffer.Buffer vertxBuffer) Creates a buffer from a vertxBuffer.static BufferCreates a buffer from the specifiedString.static BufferSame asbuffer(String)but with the given charset.byte[]getBytes()Returns the byte array corresponding to the content of this buffer.io.netty.buffer.ByteBufReturns the netty native buffer (ByteBuf) behind this buffer.intlength()Returns the length of this buffer.toString()Returns theStringrepresentation of this current buffer.Returns theStringrepresentation of this current buffer with the given charset.Returns theStringrepresentation of this current buffer with the given charset.
-
Field Details
-
factory
-
-
Method Details
-
buffer
Creates an empty buffer.- Returns:
- the newly created buffer.
-
buffer
Creates a buffer from a vertxBuffer.- Returns:
- the newly created buffer.
- See Also:
-
buffer
Creates a buffer from a vertxBuffer.- Returns:
- the newly created buffer.
- See Also:
-
buffer
Creates a buffer from a nettyByteBuf.- Returns:
- the newly created buffer.
-
buffer
Creates an empty buffer with reserved space.- Returns:
- the newly created buffer.
-
buffer
Creates a buffer from the specifiedString. WARN: creating a buffer from a string allocates dedicated space in the memory. When creating aBufferwith the content of another one, it is recommended to use one of the alternative methods:- Returns:
- the newly created buffer.
- See Also:
-
buffer
Same asbuffer(String)but with the given charset.- Returns:
- the newly created buffer.
- See Also:
-
buffer
Creates a buffer from the specified byte array. WARN: creating a buffer from a byte array allocates dedicated space in the memory. When creating aBufferwith the content of another one, it is recommended to use one of the alternative methods:- Returns:
- the newly created buffer.
- See Also:
-
appendBuffer
Appends the specifiedBufferto the current one.- Returns:
- the current buffer.
-
appendBuffer
Appends the firstlengthbytes of the specifiedBufferto the current one.- Returns:
- the current buffer.
-
appendString
Appends the specifiedStringwith the given charset to the current one.- Returns:
- the current buffer.
-
appendString
Appends the specifiedStringto the current one.- Returns:
- the current buffer.
-
toString
String toString()Returns theStringrepresentation of this current buffer. -
toString
Returns theStringrepresentation of this current buffer with the given charset.- Returns:
- the string representation of this buffer with the given charset.
- See Also:
-
toString
Returns theStringrepresentation of this current buffer with the given charset.- Returns:
- the string representation of this buffer with the given charset.
- See Also:
-
getBytes
byte[] getBytes()Returns the byte array corresponding to the content of this buffer.- Returns:
- the byte array of this buffer.
-
length
int length()Returns the length of this buffer. It corresponds to the number of bytes of this buffer.- Returns:
- the number of bytes of this buffer.
-
getNativeBuffer
io.netty.buffer.ByteBuf getNativeBuffer()Returns the netty native buffer (ByteBuf) behind this buffer. This can be particularly useful to access it when wanted to optimise memory consumption and avoid byte array copy to transmit the buffer.- Returns:
- the netty native buffer.
-