Top Fields Constructors Methods
io.rsocket.util

public final Class ByteBufPayload

extends AbstractReferenceCounted
implements Payload
Class Inheritance
All Implemented Interfaces
io.rsocket.Payload, io.netty.util.ReferenceCounted
Imports
io.netty.buffer.ByteBuf, .ByteBufAllocator, .ByteBufUtil, .Unpooled, io.netty.util.AbstractReferenceCounted, .IllegalReferenceCountException, .Recycler, .Recycler.Handle, io.rsocket.Payload, java.nio.ByteBuffer, .CharBuffer, java.nio.charset.Charset, reactor.util.annotation.Nullable

Field Summary

Modifier and TypeField and Description
private ByteBuf
private final Recycler.Handle<ByteBufPayload>
private ByteBuf
private static final Recycler<ByteBufPayload>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Payload

Returns:

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

Static factory method for a text payload.

public static Payload

Returns:

a payload.
create
(String
the data of the payload.
data
,
String
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.
protected void
deallocate()

Implements abstract io.netty.util.AbstractReferenceCounted.deallocate.

Called once refCnt() is equals 0.
pack-priv void
ensureAccessible()

Should be called by every method that tries to access the buffers content to check if the buffer was released before.

public boolean
hasMetadata()

Implements io.rsocket.Payload.hasMetadata.

Returns whether the payload has metadata, useful for tell if metadata is empty or not present.
pack-priv boolean
isAccessible()

Used internally by ByteBufPayload#ensureAccessible() to try to guard against using the buffer after it was released (best-effort).

public ByteBuf
metadata()

Implements io.rsocket.Payload.metadata.

Returns the Payloads' metadata without slicing if possible.
public ByteBufPayload
public ByteBufPayload
retain(int increment)

Overrides io.netty.util.AbstractReferenceCounted.retain.

Implements io.rsocket.Payload.retain, io.netty.util.ReferenceCounted.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.
public ByteBufPayload
touch()

Overrides io.netty.util.AbstractReferenceCounted.touch.

Implements io.rsocket.Payload.touch, io.netty.util.ReferenceCounted.touch.

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

Implements io.rsocket.Payload.touch, io.netty.util.ReferenceCounted.touch.

Records the current access location of this object with an additional arbitrary information for debugging purposes.
Inherited from io.netty.util.AbstractReferenceCounted:
refCntreleasereleasesetRefCnt

Field Detail

databack to summary
private ByteBuf data
handleback to summary
private final Recycler.Handle<ByteBufPayload> handle
metadataback to summary
private ByteBuf metadata
RECYCLERback to summary
private static final Recycler<ByteBufPayload> RECYCLER

Constructor Detail

ByteBufPayloadback to summary
private ByteBufPayload(final Recycler.Handle<ByteBufPayload> handle)

Method Detail

createback to summary
public static Payload create(String data)

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

Parameters
data:String

the data of the payload.

Returns:Payload

a payload.

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

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

Parameters
data:String

the data of the payload.

metadata:String

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
deallocateback to summary
protected void deallocate()

Implements abstract io.netty.util.AbstractReferenceCounted.deallocate.

Doc from io.netty.util.AbstractReferenceCounted.deallocate.

Called once refCnt() is equals 0.

Annotations
@Override
ensureAccessibleback to summary
pack-priv void ensureAccessible()

Should be called by every method that tries to access the buffers content to check if the buffer was released before.

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
isAccessibleback to summary
pack-priv boolean isAccessible()

Used internally by ByteBufPayload#ensureAccessible() to try to guard against using the buffer after it was released (best-effort).

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
retainback to summary
public ByteBufPayload retain()

Overrides io.netty.util.AbstractReferenceCounted.retain.

Implements io.rsocket.Payload.retain, io.netty.util.ReferenceCounted.retain.

Doc from io.rsocket.Payload.retain.

Increases the reference count by 1.

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

Overrides io.netty.util.AbstractReferenceCounted.retain.

Implements io.rsocket.Payload.retain, io.netty.util.ReferenceCounted.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
touchback to summary
public ByteBufPayload touch()

Overrides io.netty.util.AbstractReferenceCounted.touch.

Implements io.rsocket.Payload.touch, io.netty.util.ReferenceCounted.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 ByteBufPayload touch(Object hint)

Implements io.rsocket.Payload.touch, io.netty.util.ReferenceCounted.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