com.google.protobuf.ByteString.newCodedBuilder()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中com.google.protobuf.ByteString.newCodedBuilder()方法的一些代码示例,展示了ByteString.newCodedBuilder()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteString.newCodedBuilder()方法的具体详情如下:
包路径:com.google.protobuf.ByteString
类名称:ByteString
方法名:newCodedBuilder

ByteString.newCodedBuilder介绍

[英]Constructs a new ByteString builder, which allows you to efficiently construct a ByteString by writing to a CodedOutputStream. Using this is much more efficient than calling newOutput() and wrapping that in a CodedOutputStream.

This is package-private because it's a somewhat confusing interface. Users can call Message#toByteString() instead of calling this directly.
[中]构造一个新的ByteString生成器,它允许您通过写入CodedOutputStream来高效地构造ByteString。使用它比调用newOutput()并将其包装到CodeDoutpStream中要高效得多。
这是包私有的,因为它是一个有点混乱的接口。用户可以调用Message#toByteString(),而不是直接调用它。

代码示例

代码示例来源:origin: osmandapp/Osmand

/**
 * Serializes the message to a {@code ByteString} and returns it. This is
 * just a trivial wrapper around {@link #writeTo(CodedOutputStream)}.
 */
public ByteString toByteString() {
 try {
  final ByteString.CodedBuilder out =
   ByteString.newCodedBuilder(getSerializedSize());
  writeTo(out.getCodedOutput());
  return out.build();
 } catch (final IOException e) {
  throw new RuntimeException(
   "Serializing to a ByteString threw an IOException (should " +
   "never happen).", e);
 }
}

代码示例来源:origin: com.google.protobuf/protobuf-java

/**
 * Serializes the message to a {@code ByteString} and returns it. This is
 * just a trivial wrapper around {@link #writeTo(CodedOutputStream)}.
 */
@Override
public ByteString toByteString() {
 try {
  final ByteString.CodedBuilder out =
   ByteString.newCodedBuilder(getSerializedSize());
  writeTo(out.getCodedOutput());
  return out.build();
 } catch (final IOException e) {
  throw new RuntimeException(
   "Serializing to a ByteString threw an IOException (should " +
   "never happen).", e);
 }
}

代码示例来源:origin: osmandapp/Osmand

public ByteString toByteString() {
 try {
  final ByteString.CodedBuilder out =
   ByteString.newCodedBuilder(getSerializedSize());
  writeTo(out.getCodedOutput());
  return out.build();
 } catch (IOException e) {
  throw new RuntimeException(
   "Serializing to a ByteString threw an IOException (should " +
   "never happen).", e);
 }
}

代码示例来源:origin: com.google.protobuf/protobuf-java

@Override
public ByteString toByteString() {
 try {
  final ByteString.CodedBuilder out =
   ByteString.newCodedBuilder(getSerializedSize());
  writeTo(out.getCodedOutput());
  return out.build();
 } catch (IOException e) {
  throw new RuntimeException(getSerializingExceptionMessage("ByteString"), e);
 }
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

/**
 * Serializes the message to a {@code ByteString} and returns it. This is
 * just a trivial wrapper around {@link #writeTo(CodedOutputStream)}.
 */
public ByteString toByteString() {
 try {
  final ByteString.CodedBuilder out =
   ByteString.newCodedBuilder(getSerializedSize());
  writeTo(out.getCodedOutput());
  return out.build();
 } catch (final IOException e) {
  throw new RuntimeException(
   "Serializing to a ByteString threw an IOException (should " +
   "never happen).", e);
 }
}

代码示例来源:origin: yeriomin/play-store-api

/**
 * Serializes the message to a {@code ByteString} and returns it. This is
 * just a trivial wrapper around {@link #writeTo(CodedOutputStream)}.
 */
@Override
public ByteString toByteString() {
 try {
  final ByteString.CodedBuilder out =
   ByteString.newCodedBuilder(getSerializedSize());
  writeTo(out.getCodedOutput());
  return out.build();
 } catch (final IOException e) {
  throw new RuntimeException(
   "Serializing to a ByteString threw an IOException (should " +
   "never happen).", e);
 }
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

public ByteString toByteString() {
 try {
  final ByteString.CodedBuilder out =
   ByteString.newCodedBuilder(getSerializedSize());
  writeTo(out.getCodedOutput());
  return out.build();
 } catch (IOException e) {
  throw new RuntimeException(
   "Serializing to a ByteString threw an IOException (should " +
   "never happen).", e);
 }
}

代码示例来源:origin: com.google.protobuf/protobuf-lite

@Override
public ByteString toByteString() {
 try {
  final ByteString.CodedBuilder out =
   ByteString.newCodedBuilder(getSerializedSize());
  writeTo(out.getCodedOutput());
  return out.build();
 } catch (IOException e) {
  throw new RuntimeException(getSerializingExceptionMessage("ByteString"), e);
 }
}

代码示例来源:origin: yeriomin/play-store-api

@Override
public ByteString toByteString() {
 try {
  final ByteString.CodedBuilder out =
   ByteString.newCodedBuilder(getSerializedSize());
  writeTo(out.getCodedOutput());
  return out.build();
 } catch (IOException e) {
  throw new RuntimeException(getSerializingExceptionMessage("ByteString"), e);
 }
}

相关文章