Top Description Inners Fields Constructors Methods
io.rsocket.metadata

public final Class CompositeMetadata

extends Object
implements Iterable<CompositeMetadata.Entry>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Static Imports
io.rsocket.metadata.CompositeMetadataCodec.computeNextEntryIndex, .CompositeMetadataCodec.decodeMimeAndContentBuffersSlices, .CompositeMetadataCodec.decodeMimeIdFromMimeBuffer, .CompositeMetadataCodec.decodeMimeTypeFromMimeBuffer, .CompositeMetadataCodec.hasEntry, .CompositeMetadataCodec.isWellKnownMimeType

An Iterable wrapper around a ByteBuf that exposes metadata entry information at each decoding step. This is only possible on frame types used to initiate interactions, if the SETUP metadata mime type was WellKnownMimeType#MESSAGE_RSOCKET_COMPOSITE_METADATA.

This allows efficient incremental decoding of the entries (without moving the source's io.netty.buffer.ByteBuf#readerIndex()). The buffer is assumed to contain just enough bytes to represent one or more entries (mime type compressed or not). The decoding stops when the buffer reaches 0 readable bytes, and fails if it contains bytes but not enough to correctly decode an entry.

A note on future-proofness: it is possible to come across a compressed mime type that this implementation doesn't recognize. This is likely to be due to the use of a byte id that is merely reserved in this implementation, but maps to a WellKnownMimeType in the implementation that encoded the metadata. This can be detected by detecting that an entry is a ReservedMimeTypeEntry. In this case Entry#getMimeType() will return null. The encoded id can be retrieved using ReservedMimeTypeEntry#getType(). The byte and content buffer should be kept around and re-encoded using CompositeMetadataCodec#encodeAndAddMetadata(CompositeByteBuf, ByteBufAllocator, byte, ByteBuf) in case passing that entry through is required.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
public static class
CompositeMetadata.ExplicitMimeTimeEntry

An Entry backed by an explicitly declared MIME type.

public static class
CompositeMetadata.ReservedMimeTypeEntry

An Entry backed by a WellKnownMimeType entry, but one that is not understood by this implementation.

public static class

Field Summary

Modifier and TypeField and Description
private final boolean
private final ByteBuf

Constructor Summary

AccessConstructor and Description
public
CompositeMetadata(ByteBuf source, boolean retainSlices)

Method Summary

Modifier and TypeMethod and Description
public Iterator<CompositeMetadata.Entry>

Returns:

the composite metadata Iterator
iterator
()

Implements java.lang.Iterable.iterator.

An Iterator that lazily decodes Entry in this composite metadata.
public Stream<CompositeMetadata.Entry>

Returns:

the composite metadata sequential Stream
stream
()

Turn this CompositeMetadata into a sequential Stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

retainSlicesback to summary
private final boolean retainSlices
sourceback to summary
private final ByteBuf source

Constructor Detail

CompositeMetadataback to summary
public CompositeMetadata(ByteBuf source, boolean retainSlices)

Method Detail

iteratorback to summary
public Iterator<CompositeMetadata.Entry> iterator()

Implements java.lang.Iterable.iterator.

An Iterator that lazily decodes Entry in this composite metadata.

Returns:Iterator<CompositeMetadata.Entry>

the composite metadata Iterator

Annotations
@Override
streamback to summary
public Stream<CompositeMetadata.Entry> stream()

Turn this CompositeMetadata into a sequential Stream.

Returns:Stream<CompositeMetadata.Entry>

the composite metadata sequential Stream

io.rsocket.metadata back to summary

public Interface CompositeMetadata.Entry

Known Direct Implementers
io.rsocket.metadata.CompositeMetadata.ExplicitMimeTimeEntry, io.rsocket.metadata.CompositeMetadata.ReservedMimeTypeEntry, io.rsocket.metadata.CompositeMetadata.WellKnownMimeTypeEntry, io.rsocket.metadata.TaggingMetadata

An entry in the CompositeMetadata.

Method Summary

Modifier and TypeMethod and Description
public ByteBuf

Returns:

the un-decoded content of the Entry
getContent
()

Returns the un-decoded content of the Entry.

public String

Returns:

the MIME type of the entry, if it can be decoded, otherwise null.
getMimeType
()

Returns the MIME type of the entry, if it can be decoded.

Method Detail

getContentback to summary
public ByteBuf getContent()

Returns the un-decoded content of the Entry.

Returns:ByteBuf

the un-decoded content of the Entry

getMimeTypeback to summary
public String getMimeType()

Returns the MIME type of the entry, if it can be decoded.

Returns:String

the MIME type of the entry, if it can be decoded, otherwise null.

Annotations
@Nullable
io.rsocket.metadata back to summary

public final Class CompositeMetadata.ExplicitMimeTimeEntry

extends Object
implements Entry
Class Inheritance
All Implemented Interfaces
io.rsocket.metadata.CompositeMetadata.Entry

An Entry backed by an explicitly declared MIME type.

Field Summary

Modifier and TypeField and Description
private final ByteBuf
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ByteBuf
getContent()

Implements io.rsocket.metadata.CompositeMetadata.Entry.getContent.

Returns the un-decoded content of the Entry.
public String
getMimeType()

Implements io.rsocket.metadata.CompositeMetadata.Entry.getMimeType.

Returns the MIME type of the entry, if it can be decoded.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentback to summary
private final ByteBuf content
typeback to summary
private final String type

Constructor Detail

ExplicitMimeTimeEntryback to summary
public ExplicitMimeTimeEntry(ByteBuf content, String type)

Method Detail

getContentback to summary
public ByteBuf getContent()

Implements io.rsocket.metadata.CompositeMetadata.Entry.getContent.

Doc from io.rsocket.metadata.CompositeMetadata.Entry.getContent.

Returns the un-decoded content of the Entry.

Returns:ByteBuf

the un-decoded content of the Entry

Annotations
@Override
getMimeTypeback to summary
public String getMimeType()

Implements io.rsocket.metadata.CompositeMetadata.Entry.getMimeType.

Doc from io.rsocket.metadata.CompositeMetadata.Entry.getMimeType.

Returns the MIME type of the entry, if it can be decoded.

Returns:String

the MIME type of the entry, if it can be decoded, otherwise null.

Annotations
@Override
io.rsocket.metadata back to summary

public final Class CompositeMetadata.ReservedMimeTypeEntry

extends Object
implements Entry
Class Inheritance
All Implemented Interfaces
io.rsocket.metadata.CompositeMetadata.Entry

An Entry backed by a WellKnownMimeType entry, but one that is not understood by this implementation.

Field Summary

Modifier and TypeField and Description
private final ByteBuf
private final int

Constructor Summary

AccessConstructor and Description
public
ReservedMimeTypeEntry(ByteBuf content, int type)

Method Summary

Modifier and TypeMethod and Description
public ByteBuf
getContent()

Implements io.rsocket.metadata.CompositeMetadata.Entry.getContent.

Returns the un-decoded content of the Entry.
public String
getMimeType()

Implements io.rsocket.metadata.CompositeMetadata.Entry.getMimeType.

Returns the MIME type of the entry, if it can be decoded.
public int

Returns:

the reserved, but unknown WellKnownMimeType for this entry
getType
()

Returns the reserved, but unknown WellKnownMimeType for this entry.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentback to summary
private final ByteBuf content
typeback to summary
private final int type

Constructor Detail

ReservedMimeTypeEntryback to summary
public ReservedMimeTypeEntry(ByteBuf content, int type)

Method Detail

getContentback to summary
public ByteBuf getContent()

Implements io.rsocket.metadata.CompositeMetadata.Entry.getContent.

Doc from io.rsocket.metadata.CompositeMetadata.Entry.getContent.

Returns the un-decoded content of the Entry.

Returns:ByteBuf

the un-decoded content of the Entry

Annotations
@Override
getMimeTypeback to summary
public String getMimeType()

Implements io.rsocket.metadata.CompositeMetadata.Entry.getMimeType.

Doc from io.rsocket.metadata.CompositeMetadata.Entry.getMimeType.

Returns the MIME type of the entry, if it can be decoded. Since this entry represents a compressed id that couldn't be decoded, this is always null.

Returns:String

the MIME type of the entry, if it can be decoded, otherwise null.

Annotations
@Override
getTypeback to summary
public int getType()

Returns the reserved, but unknown WellKnownMimeType for this entry. Range is 0-127 (inclusive).

Returns:int

the reserved, but unknown WellKnownMimeType for this entry

io.rsocket.metadata back to summary

public final Class CompositeMetadata.WellKnownMimeTypeEntry

extends Object
implements Entry
Class Inheritance
All Implemented Interfaces
io.rsocket.metadata.CompositeMetadata.Entry

An Entry backed by a WellKnownMimeType.

Field Summary

Modifier and TypeField and Description
private final ByteBuf
private final WellKnownMimeType

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ByteBuf
getContent()

Implements io.rsocket.metadata.CompositeMetadata.Entry.getContent.

Returns the un-decoded content of the Entry.
public String
getMimeType()

Implements io.rsocket.metadata.CompositeMetadata.Entry.getMimeType.

Returns the MIME type of the entry, if it can be decoded.
public WellKnownMimeType

Returns:

the WellKnownMimeType for this entry
getType
()

Returns the WellKnownMimeType for this entry.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentback to summary
private final ByteBuf content
typeback to summary
private final WellKnownMimeType type

Constructor Detail

WellKnownMimeTypeEntryback to summary
public WellKnownMimeTypeEntry(ByteBuf content, WellKnownMimeType type)

Method Detail

getContentback to summary
public ByteBuf getContent()

Implements io.rsocket.metadata.CompositeMetadata.Entry.getContent.

Doc from io.rsocket.metadata.CompositeMetadata.Entry.getContent.

Returns the un-decoded content of the Entry.

Returns:ByteBuf

the un-decoded content of the Entry

Annotations
@Override
getMimeTypeback to summary
public String getMimeType()

Implements io.rsocket.metadata.CompositeMetadata.Entry.getMimeType.

Doc from io.rsocket.metadata.CompositeMetadata.Entry.getMimeType.

Returns the MIME type of the entry, if it can be decoded.

Returns:String

the MIME type of the entry, if it can be decoded, otherwise null.

Annotations
@Override
getTypeback to summary
public WellKnownMimeType getType()

Returns the WellKnownMimeType for this entry.

Returns:WellKnownMimeType

the WellKnownMimeType for this entry