Top Description Fields Constructors Methods
io.rsocket.util

public final Class DefaultPayload

extends Object
implements Payload
Class Inheritance
All Implemented Interfaces
io.rsocket.Payload, io.netty.util.ReferenceCounted
Imports
io.netty.buffer.ByteBuf, .Unpooled, io.rsocket.Payload, java.nio.ByteBuffer, .CharBuffer, java.nio.charset.Charset, .StandardCharsets, reactor.util.annotation.Nullable

An implementation of Payload. This implementation is not thread-safe, and hence any method can not be invoked concurrently.

Field Summary

Modifier and TypeField and Description
private final ByteBuffer
public static final ByteBuffer
private final ByteBuffer

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Payload

Returns:

a payload.
create
(CharSequence
the data of the payload.
data
)

Static factory method for a text payload.

public static Payload

Returns:

a payload.
create
(CharSequence
the data of the payload.
data
,
CharSequence
the metadata for the payload.
metadata
)

Static factory method for a text payload.

public static Payload
create(CharSequence data, Charset dataCharset)

public static Payload
create(CharSequence data, Charset dataCharset, CharSequence metadata, Charset metadataCharset)

public static Payload
create(byte[] data)

public static Payload
create(byte[] data, byte[] metadata)

public static Payload
public static Payload
create(ByteBuffer data, ByteBuffer metadata)

public static Payload
public static Payload
create(ByteBuf data, ByteBuf metadata)

public static Payload
create(Payload payload)

public ByteBuf
data()

Implements io.rsocket.Payload.data.

Returns the Payloads' data without slicing if possible.
public ByteBuffer
getData()

Overrides default io.rsocket.Payload.getData.

public ByteBuffer
public boolean
hasMetadata()

Implements io.rsocket.Payload.hasMetadata.

Returns whether the payload has metadata, useful for tell if metadata is empty or not present.
public ByteBuf
metadata()

Implements io.rsocket.Payload.metadata.

Returns the Payloads' metadata without slicing if possible.
public int
refCnt()

Implements io.netty.util.ReferenceCounted.refCnt.

Returns the reference count of this object.
public boolean
release()

Implements io.netty.util.ReferenceCounted.release.

Decreases the reference count by 1 and deallocates this object if the reference count reaches at 0.
public boolean
release(int decrement)

Implements io.netty.util.ReferenceCounted.release.

Decreases the reference count by the specified decrement and deallocates this object if the reference count reaches at 0.
public DefaultPayload
retain()

Implements io.rsocket.Payload.retain.

Increases the reference count by 1.
public DefaultPayload
retain(int increment)

Implements io.rsocket.Payload.retain.

Increases the reference count by the specified increment.
public ByteBuf
sliceData()

Implements io.rsocket.Payload.sliceData.

Returns the Payload data.
public ByteBuf
sliceMetadata()

Implements io.rsocket.Payload.sliceMetadata.

Returns a slice Payload metadata.
private static byte[]
toBytes(ByteBuf byteBuf)

public DefaultPayload
touch()

Implements io.rsocket.Payload.touch.

Records the current access location of this object for debugging purposes.
public DefaultPayload
touch(Object hint)

Implements io.rsocket.Payload.touch.

Records the current access location of this object with an additional arbitrary information for debugging purposes.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

databack to summary
private final ByteBuffer data
EMPTY_BUFFERback to summary
public static final ByteBuffer EMPTY_BUFFER
metadataback to summary
private final ByteBuffer metadata

Constructor Detail

DefaultPayloadback to summary
private DefaultPayload(ByteBuffer data, ByteBuffer metadata)

Method Detail

createback to summary
public static Payload create(CharSequence data)

Static factory method for a text payload. Mainly looks better than "new DefaultPayload(data)"

Parameters
data:CharSequence

the data of the payload.

Returns:Payload

a payload.

createback to summary
public static Payload create(CharSequence data, CharSequence metadata)

Static factory method for a text payload. Mainly looks better than "new DefaultPayload(data, metadata)"

Parameters
data:CharSequence

the data of the payload.

metadata:CharSequence

the metadata for the payload.

Returns:Payload

a payload.

createback to summary
public static Payload create(CharSequence data, Charset dataCharset)
createback to summary
public static Payload create(CharSequence data, Charset dataCharset, CharSequence metadata, Charset metadataCharset)
createback to summary
public static Payload create(byte[] data)
createback to summary
public static Payload create(byte[] data, byte[] metadata)
createback to summary
public static Payload create(ByteBuffer data)
createback to summary
public static Payload create(ByteBuffer data, ByteBuffer metadata)
createback to summary
public static Payload create(ByteBuf data)
createback to summary
public static Payload create(ByteBuf data, ByteBuf metadata)
createback to summary
public static Payload create(Payload payload)
databack to summary
public ByteBuf data()

Implements io.rsocket.Payload.data.

Doc from io.rsocket.Payload.data.

Returns the Payloads' data without slicing if possible. This is not safe and editing this could effect the payload. It is recommended to call sliceData().

Returns:ByteBuf

data as a bytebuf or slice of the data

Annotations
@Override
getDataback to summary
public ByteBuffer getData()

Overrides default io.rsocket.Payload.getData.

Annotations
@Override
getMetadataback to summary
public ByteBuffer getMetadata()

Overrides default io.rsocket.Payload.getMetadata.

Annotations
@Override
hasMetadataback to summary
public boolean hasMetadata()

Implements io.rsocket.Payload.hasMetadata.

Doc from io.rsocket.Payload.hasMetadata.

Returns whether the payload has metadata, useful for tell if metadata is empty or not present.

Returns:boolean

whether payload has non-null (possibly empty) metadata

Annotations
@Override
metadataback to summary
public ByteBuf metadata()

Implements io.rsocket.Payload.metadata.

Doc from io.rsocket.Payload.metadata.

Returns the Payloads' metadata without slicing if possible. This is not safe and editing this could effect the payload. It is recommended to call sliceMetadata().

Returns:ByteBuf

metadata as a bytebuf or slice of the metadata

Annotations
@Override
refCntback to summary
public int refCnt()

Implements io.netty.util.ReferenceCounted.refCnt.

Doc from io.netty.util.ReferenceCounted.refCnt.

Returns the reference count of this object. If 0, it means this object has been deallocated.

Annotations
@Override
releaseback to summary
public boolean release()

Implements io.netty.util.ReferenceCounted.release.

Doc from io.netty.util.ReferenceCounted.release.

Decreases the reference count by 1 and deallocates this object if the reference count reaches at 0.

Returns:boolean

true if and only if the reference count became 0 and this object has been deallocated

Annotations
@Override
releaseback to summary
public boolean release(int decrement)

Implements io.netty.util.ReferenceCounted.release.

Doc from io.netty.util.ReferenceCounted.release.

Decreases the reference count by the specified decrement and deallocates this object if the reference count reaches at 0.

Returns:boolean

true if and only if the reference count became 0 and this object has been deallocated

Annotations
@Override
retainback to summary
public DefaultPayload retain()

Implements io.rsocket.Payload.retain.

Doc from io.rsocket.Payload.retain.

Increases the reference count by 1.

Annotations
@Override
retainback to summary
public DefaultPayload retain(int increment)

Implements io.rsocket.Payload.retain.

Doc from io.rsocket.Payload.retain.

Increases the reference count by the specified increment.

Annotations
@Override
sliceDataback to summary
public ByteBuf sliceData()

Implements io.rsocket.Payload.sliceData.

Doc from io.rsocket.Payload.sliceData.

Returns the Payload data. Always non-null.

Returns:ByteBuf

payload data.

Annotations
@Override
sliceMetadataback to summary
public ByteBuf sliceMetadata()

Implements io.rsocket.Payload.sliceMetadata.

Doc from io.rsocket.Payload.sliceMetadata.

Returns a slice Payload metadata. Always non-null, check hasMetadata() to differentiate null from "".

Returns:ByteBuf

payload metadata.

Annotations
@Override
toBytesback to summary
private static byte[] toBytes(ByteBuf byteBuf)
touchback to summary
public DefaultPayload touch()

Implements io.rsocket.Payload.touch.

Doc from io.rsocket.Payload.touch.

Records the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you via ResourceLeakDetector. This method is a shortcut to touch(null).

Annotations
@Override
touchback to summary
public DefaultPayload touch(Object hint)

Implements io.rsocket.Payload.touch.

Doc from io.rsocket.Payload.touch.

Records the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you via ResourceLeakDetector.

Annotations
@Override