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

Class StringMarshaller

api/src/testFixtures/java/io/grpc/StringMarshaller.java:27–43  ·  view source on GitHub ↗

Marshalls UTF-8 encoded strings.

Source from the content-addressed store, hash-verified

25
26/** Marshalls UTF-8 encoded strings. */
27public class StringMarshaller implements MethodDescriptor.Marshaller<String> {
28 public static StringMarshaller INSTANCE = new StringMarshaller();
29
30 @Override
31 public InputStream stream(String value) {
32 return new ByteArrayInputStream(value.getBytes(UTF_8));
33 }
34
35 @Override
36 public String parse(InputStream stream) {
37 try {
38 return new String(ByteStreams.toByteArray(stream), UTF_8);
39 } catch (IOException ex) {
40 throw new RuntimeException(ex);
41 }
42 }
43}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected