Package com.linecorp.armeria.common
Enum Class ByteBufAccessMode
- All Implemented Interfaces:
Serializable
,Comparable<ByteBufAccessMode>
,java.lang.constant.Constable
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ByteBufAccessMode
Returns the enum constant of this class with the specified name.static ByteBufAccessMode[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
DUPLICATE
Gets the duplicate (or slice) of the underlyingByteBuf
. This mode is useful when you access theByteBuf
within the life cycle of theBytes
, such asHttpData
orWebSocketFrame
:try (HttpData content = ...) { ByteBuf buf = content.byteBuf(ByteBufAccessMode.DUPLICATE); // Read something from 'buf' here. } // WebSocket frame. try (WebSocketFrame frame = ...) { ByteBuf buf = frame.byteBuf(ByteBufAccessMode.DUPLICATE); // Read something from 'buf' here. }
- See Also:
-
RETAINED_DUPLICATE
Gets the retained duplicate (or slice) of the underlyingByteBuf
. This mode is useful when you access theByteBuf
beyond the life cycle of theBytes
, such asHttpData
orWebSocketFrame
, by creating anotherBytes
that shares theByteBuf
's memory region:HttpData data1 = HttpData.wrap(byteBuf); HttpData data2 = HttpData.wrap(data1.byteBuf(ByteBufAccessMode.RETAINED_DUPLICATE)); WebSocketFrame binaryFrame1 = WebSocketFrame.ofPooledBinary(byteBuf); WebSocketFrame binaryFrame2 = WebSocketFrame.ofPooledBinary( binaryFrame1.byteBuf(ByteBufAccessMode.RETAINED_DUPLICATE));
-
FOR_IO
Converts the underlyingByteBuf
into a directByteBuf
if necessary. If the underlyingByteBuf
is already direct, it behaves same withRETAINED_DUPLICATE
. Otherwise, a new directByteBuf
is allocated and the content of the underlyingByteBuf
is copied into it. This access mode is useful when you perform direct I/O or send data to a NettyChannel
.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-