Flutter Engine
The Flutter Engine
shell
platform
android
io
flutter
plugin
common
MessageCodec.java
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
package
io.flutter.plugin.common;
6
7
import
androidx.annotation.Nullable;
8
import
java.nio.ByteBuffer;
9
10
/**
11
* A message encoding/decoding mechanism.
12
*
13
* <p>Both operations throw {@link IllegalArgumentException}, if conversion fails.
14
*/
15
public
interface
MessageCodec
<
T
> {
16
/**
17
* Encodes the specified message into binary.
18
*
19
* @param message the T message, possibly null.
20
* @return a ByteBuffer containing the encoding between position 0 and the current position, or
21
* null, if message is null.
22
*/
23
@Nullable
24
ByteBuffer
encodeMessage
(@Nullable
T
message
);
25
26
/**
27
* Decodes the specified message from binary.
28
*
29
* <p><b>Warning:</b> The ByteBuffer is "direct" and it won't be valid beyond this call. Storing
30
* the ByteBuffer and using it later and will lead to a {@code java.nio.BufferUnderflowException}.
31
* If you want to retain the data you'll need to copy it.
32
*
33
* @param message the {@link ByteBuffer} message, possibly null.
34
* @return a T value representation of the bytes between the given buffer's current position and
35
* its limit, or null, if message is null.
36
*/
37
@Nullable
38
T
decodeMessage
(@Nullable ByteBuffer
message
);
39
}
io.flutter.plugin.common.MessageCodec
Definition:
MessageCodec.java:15
io.flutter.plugin.common.MessageCodec.decodeMessage
T decodeMessage(@Nullable ByteBuffer message)
io.flutter.plugin.common.MessageCodec.encodeMessage
ByteBuffer encodeMessage(@Nullable T message)
message
Win32Message message
Definition:
keyboard_unittests.cc:139
T
#define T
Definition:
precompiler.cc:65
Generated on Sun Jun 23 2024 21:55:09 for Flutter Engine by
1.9.4