本文整理汇总了Java中com.google.protobuf.ByteString.newOutput方法的典型用法代码示例。如果您正苦于以下问题:Java ByteString.newOutput方法的具体用法?Java ByteString.newOutput怎么用?Java ByteString.newOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protobuf.ByteString
的用法示例。
在下文中一共展示了ByteString.newOutput方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeMessageList
import com.google.protobuf.ByteString; //导入方法依赖的package包/类
/**
* Creates a {@link ByteString} by serializing the list of protos. Use
* {@link #readMessageList(ByteString, Parser)} to deserialize.
*/
public static <T extends MessageLite> ByteString writeMessageList(List<T> protos) {
Output output = ByteString.newOutput();
try {
writeMessageListTo(output, protos);
} catch (IOException ex) {
throw new IllegalStateException("Unable to write protobufs to memory");
}
return output.toByteString();
}
示例2: Builder
import com.google.protobuf.ByteString; //导入方法依赖的package包/类
Builder() {
out = ByteString.newOutput(64*1024);
cos = CodedOutputStream.newInstance(out);
}
示例3: convert
import com.google.protobuf.ByteString; //导入方法依赖的package包/类
/**
* Helper to convert the procedure to protobuf.
* Used by ProcedureStore implementations.
*/
@InterfaceAudience.Private
public static ProcedureProtos.Procedure convert(final Procedure proc)
throws IOException {
Preconditions.checkArgument(proc != null);
validateClass(proc);
ProcedureProtos.Procedure.Builder builder = ProcedureProtos.Procedure.newBuilder()
.setClassName(proc.getClass().getName())
.setProcId(proc.getProcId())
.setState(proc.getState())
.setStartTime(proc.getStartTime())
.setLastUpdate(proc.getLastUpdate());
if (proc.hasParent()) {
builder.setParentId(proc.getParentProcId());
}
if (proc.hasTimeout()) {
builder.setTimeout(proc.getTimeout());
}
if (proc.hasOwner()) {
builder.setOwner(proc.getOwner());
}
int[] stackIds = proc.getStackIndexes();
if (stackIds != null) {
for (int i = 0; i < stackIds.length; ++i) {
builder.addStackId(stackIds[i]);
}
}
if (proc.hasException()) {
RemoteProcedureException exception = proc.getException();
builder.setException(
RemoteProcedureException.toProto(exception.getSource(), exception.getCause()));
}
byte[] result = proc.getResult();
if (result != null) {
builder.setResult(ByteStringer.wrap(result));
}
ByteString.Output stateStream = ByteString.newOutput();
proc.serializeStateData(stateStream);
if (stateStream.size() > 0) {
builder.setStateData(stateStream.toByteString());
}
if (proc.getNonceKey() != null) {
builder.setNonceGroup(proc.getNonceKey().getNonceGroup());
builder.setNonce(proc.getNonceKey().getNonce());
}
return builder.build();
}