public final class DefaultPayload extends Object implements Payload
Payload. This implementation is not thread-safe, and hence
any method can not be invoked concurrently.| Modifier and Type | Field and Description |
|---|---|
static ByteBuffer |
EMPTY_BUFFER |
| Modifier and Type | Method and Description |
|---|---|
static Payload |
create(byte[] data) |
static Payload |
create(byte[] data,
byte[] metadata) |
static Payload |
create(ByteBuf data) |
static Payload |
create(ByteBuf data,
ByteBuf metadata) |
static Payload |
create(ByteBuffer data) |
static Payload |
create(ByteBuffer data,
ByteBuffer metadata) |
static Payload |
create(CharSequence data)
Static factory method for a text payload.
|
static Payload |
create(CharSequence data,
CharSequence metadata)
Static factory method for a text payload.
|
static Payload |
create(CharSequence data,
Charset dataCharset) |
static Payload |
create(CharSequence data,
Charset dataCharset,
CharSequence metadata,
Charset metadataCharset) |
static Payload |
create(Payload payload) |
ByteBuffer |
getData() |
ByteBuffer |
getMetadata() |
boolean |
hasMetadata()
Returns whether the payload has metadata, useful for tell if metadata is empty or not present.
|
int |
refCnt() |
boolean |
release() |
boolean |
release(int decrement) |
DefaultPayload |
retain()
Increases the reference count by
1. |
DefaultPayload |
retain(int increment)
Increases the reference count by the specified
increment. |
ByteBuf |
sliceData()
Returns the Payload data.
|
ByteBuf |
sliceMetadata()
Returns the Payload metadata.
|
DefaultPayload |
touch()
Records the current access location of this object for debugging purposes.
|
DefaultPayload |
touch(Object hint)
Records the current access location of this object with an additional arbitrary information for
debugging purposes.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDataUtf8, getMetadataUtf8public static final ByteBuffer EMPTY_BUFFER
public boolean hasMetadata()
PayloadhasMetadata in interface Payloadpublic ByteBuf sliceMetadata()
PayloadPayload.hasMetadata() to differentiate
null from "".sliceMetadata in interface Payloadpublic ByteBuf sliceData()
Payloadpublic ByteBuffer getMetadata()
getMetadata in interface Payloadpublic ByteBuffer getData()
public int refCnt()
refCnt in interface ReferenceCountedpublic DefaultPayload retain()
Payload1.retain in interface ReferenceCountedretain in interface Payloadpublic DefaultPayload retain(int increment)
Payloadincrement.retain in interface ReferenceCountedretain in interface Payloadpublic DefaultPayload touch()
PayloadResourceLeakDetector. This method is a shortcut to touch(null).touch in interface ReferenceCountedtouch in interface Payloadpublic DefaultPayload touch(Object hint)
PayloadResourceLeakDetector.touch in interface ReferenceCountedtouch in interface Payloadpublic boolean release()
release in interface ReferenceCountedpublic boolean release(int decrement)
release in interface ReferenceCountedpublic static Payload create(CharSequence data)
data - the data of the payload.public static Payload create(CharSequence data, @Nullable CharSequence metadata)
data - the data of the payload.metadata - the metadata for the payload.public static Payload create(CharSequence data, Charset dataCharset)
public static Payload create(CharSequence data, Charset dataCharset, @Nullable CharSequence metadata, Charset metadataCharset)
public static Payload create(byte[] data)
public static Payload create(ByteBuffer data)
public static Payload create(ByteBuffer data, @Nullable ByteBuffer metadata)