MCPcopy Create free account
hub / github.com/grpc/grpc-java / serialize

Method serialize

api/src/main/java/io/grpc/Metadata.java:466–478  ·  view source on GitHub ↗

Serialize all the metadata entries. It produces serialized names and values interleaved. result[i 2] are names, while result[i 2+1] are values. Names are ASCII string bytes that contains only the characters listed in the class comment of Key. If the name ends with "-bin", the

()

Source from the content-addressed store, hash-verified

464 * <p>This method is intended for transport use only.
465 */
466 @Nullable
467 byte[][] serialize() {
468 byte[][] serialized = new byte[len()][];
469 if (namesAndValues instanceof byte[][]) {
470 System.arraycopy(namesAndValues, 0, serialized, 0, len());
471 } else {
472 for (int i = 0; i < size; i++) {
473 serialized[i * 2] = name(i);
474 serialized[i * 2 + 1] = valueAsBytes(i);
475 }
476 }
477 return serialized;
478 }
479
480 /**
481 * Serializes all metadata entries, leaving some values as {@link InputStream}s.

Callers 5

testWriteParsedMethod · 0.95
testSerializeRawMethod · 0.95
testKeyCaseHandlingMethod · 0.95

Calls 3

lenMethod · 0.95
nameMethod · 0.95
valueAsBytesMethod · 0.95

Tested by 5

testWriteParsedMethod · 0.76
testSerializeRawMethod · 0.76
testKeyCaseHandlingMethod · 0.76