本文整理汇总了Java中com.google.protobuf.ByteString.Output方法的典型用法代码示例。如果您正苦于以下问题:Java ByteString.Output方法的具体用法?Java ByteString.Output怎么用?Java ByteString.Output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protobuf.ByteString
的用法示例。
在下文中一共展示了ByteString.Output方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}