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) |
ByteBuf |
data()
Returns the Payloads' data without slicing if possible.
|
ByteBuffer |
getData() |
ByteBuffer |
getMetadata() |
boolean |
hasMetadata()
Returns whether the payload has metadata, useful for tell if metadata is empty or not present.
|
ByteBuf |
metadata()
Returns the Payloads' metadata without slicing if possible.
|
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 a slice 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, wait
getDataUtf8, getMetadataUtf8
public static final ByteBuffer EMPTY_BUFFER
public 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)
public boolean hasMetadata()
Payload
hasMetadata
in interface Payload
public ByteBuf sliceMetadata()
Payload
Payload.hasMetadata()
to
differentiate null from "".sliceMetadata
in interface Payload
public ByteBuf sliceData()
Payload
public ByteBuffer getMetadata()
getMetadata
in interface Payload
public ByteBuffer getData()
public ByteBuf data()
Payload
public ByteBuf metadata()
Payload
public int refCnt()
refCnt
in interface ReferenceCounted
public DefaultPayload retain()
Payload
1
.retain
in interface ReferenceCounted
retain
in interface Payload
public DefaultPayload retain(int increment)
Payload
increment
.retain
in interface ReferenceCounted
retain
in interface Payload
public DefaultPayload touch()
Payload
ResourceLeakDetector
. This method is a shortcut to touch(null)
.touch
in interface ReferenceCounted
touch
in interface Payload
public DefaultPayload touch(Object hint)
Payload
ResourceLeakDetector
.touch
in interface ReferenceCounted
touch
in interface Payload
public boolean release()
release
in interface ReferenceCounted
public boolean release(int decrement)
release
in interface ReferenceCounted