Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
io.flutter.plugin.common.StringCodec Class Reference
Inheritance diagram for io.flutter.plugin.common.StringCodec:
io.flutter.plugin.common.MessageCodec< String >

Public Member Functions

ByteBuffer encodeMessage (@Nullable String message)
 
String decodeMessage (@Nullable ByteBuffer message)
 
- Public Member Functions inherited from io.flutter.plugin.common.MessageCodec< String >
ByteBuffer encodeMessage ( @Nullable T message)
 
T decodeMessage ( @Nullable ByteBuffer message)
 

Static Public Attributes

static final StringCodec INSTANCE = new StringCodec()
 

Detailed Description

A MessageCodec using UTF-8 encoded String messages.

This codec is guaranteed to be compatible with the corresponding StringCodec on the Dart side. These parts of the Flutter SDK are evolved synchronously.

Definition at line 18 of file StringCodec.java.

Member Function Documentation

◆ decodeMessage()

String io.flutter.plugin.common.StringCodec.decodeMessage ( @Nullable ByteBuffer  message)
inline

Definition at line 39 of file StringCodec.java.

39 {
40 if (message == null) {
41 return null;
42 }
43 final byte[] bytes;
44 final int offset;
45 final int length = message.remaining();
46 if (message.hasArray()) {
47 bytes = message.array();
48 offset = message.arrayOffset();
49 } else {
50 // TODO(mravn): Avoid the extra copy below.
51 bytes = new byte[length];
52 message.get(bytes);
53 offset = 0;
54 }
55 return new String(bytes, offset, length, UTF8);
56 }
size_t length
Win32Message message
Point offset

◆ encodeMessage()

ByteBuffer io.flutter.plugin.common.StringCodec.encodeMessage ( @Nullable String  message)
inline

Definition at line 26 of file StringCodec.java.

26 {
27 if (message == null) {
28 return null;
29 }
30 // TODO(mravn): Avoid the extra copy below.
31 final byte[] bytes = message.getBytes(UTF8);
32 final ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.length);
33 buffer.put(bytes);
34 return buffer;
35 }
static const uint8_t buffer[]

Member Data Documentation

◆ INSTANCE

final StringCodec io.flutter.plugin.common.StringCodec.INSTANCE = new StringCodec()
static

Definition at line 20 of file StringCodec.java.


The documentation for this class was generated from the following file: