本文整理了Java中com.google.protobuf.Message.toString()
方法的一些代码示例,展示了Message.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.toString()
方法的具体详情如下:
包路径:com.google.protobuf.Message
类名称:Message
方法名:toString
[英]Converts the message to a string in protocol buffer text format. This is just a trivial wrapper around TextFormat#printToString(MessageOrBuilder).
[中]将消息转换为协议缓冲区文本格式的字符串。这只是TextFormat#printToString(MessageOrBuilder)的一个简单包装。
代码示例来源:origin: googleapis/google-cloud-java
@Override
public void describeTo(Description description) {
description.appendText(expected.toString());
}
}
代码示例来源:origin: google/truth
static FieldScope createFromSetFields(Message message) {
return create(
FieldScopeLogic.partialScope(message),
Functions.constant(String.format("FieldScopes.fromSetFields({%s})", message.toString())));
}
代码示例来源:origin: apache/hbase
@Override
protected Message callExecService(final RpcController controller,
final Descriptors.MethodDescriptor method, final Message request,
final Message responsePrototype)
throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace("Call: " + method.getName() + ", " + request.toString());
}
// Try-with-resources so close gets called when we are done.
try (MasterCallable<CoprocessorServiceResponse> callable =
new MasterCallable<CoprocessorServiceResponse>(connection,
connection.getRpcControllerFactory()) {
@Override
protected CoprocessorServiceResponse rpcCall() throws Exception {
CoprocessorServiceRequest csr =
CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request);
return this.master.execMasterService(getRpcController(), csr);
}
}) {
// TODO: Are we retrying here? Does not seem so. We should use RetryingRpcCaller
callable.prepare(false);
int operationTimeout = connection.getConnectionConfiguration().getOperationTimeout();
CoprocessorServiceResponse result = callable.call(operationTimeout);
return CoprocessorRpcUtils.getResponse(result, responsePrototype);
}
}
};
代码示例来源:origin: apache/hbase
@Override
protected Message callExecService(final RpcController controller,
final Descriptors.MethodDescriptor method, final Message request,
final Message responsePrototype)
throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace("Call: " + method.getName() + ", " + request.toString());
}
if (row == null) {
throw new NullPointerException("Can't be null!");
}
ClientServiceCallable<CoprocessorServiceResponse> callable =
new ClientServiceCallable<CoprocessorServiceResponse>(this.conn,
this.table, this.row, this.conn.getRpcControllerFactory().newController(), HConstants.PRIORITY_UNSET) {
@Override
protected CoprocessorServiceResponse rpcCall() throws Exception {
byte [] regionName = getLocation().getRegionInfo().getRegionName();
CoprocessorServiceRequest csr =
CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request, row, regionName);
return getStub().execService(getRpcController(), csr);
}
};
CoprocessorServiceResponse result =
this.rpcCallerFactory.<CoprocessorServiceResponse> newCaller().callWithRetries(callable,
operationTimeout);
this.lastRegion = result.getRegion().getValue().toByteArray();
return CoprocessorRpcUtils.getResponse(result, responsePrototype);
}
代码示例来源:origin: apache/hbase
@Override
protected Message callExecService(RpcController controller,
Descriptors.MethodDescriptor method, Message request, Message responsePrototype)
throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace("Call: " + method.getName() + ", " + request.toString());
}
CoprocessorServiceRequest csr =
CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request);
// TODO: Are we retrying here? Does not seem so. We should use RetryingRpcCaller
// TODO: Make this same as RegionCoprocessorRpcChannel and MasterCoprocessorRpcChannel. They
// are all different though should do same thing; e.g. RpcChannel setup.
ClientProtos.ClientService.BlockingInterface stub = connection.getClient(serverName);
CoprocessorServiceResponse result;
try {
result = stub.
execRegionServerService(connection.getRpcControllerFactory().newController(), csr);
return CoprocessorRpcUtils.getResponse(result, responsePrototype);
} catch (ServiceException e) {
throw ProtobufUtil.handleRemoteException(e);
}
}
};
代码示例来源:origin: org.apache.hbase/hbase-client
@Override
protected Message callExecService(RpcController controller,
Descriptors.MethodDescriptor method, Message request, Message responsePrototype)
throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace("Call: " + method.getName() + ", " + request.toString());
}
CoprocessorServiceRequest csr =
CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request);
// TODO: Are we retrying here? Does not seem so. We should use RetryingRpcCaller
// TODO: Make this same as RegionCoprocessorRpcChannel and MasterCoprocessorRpcChannel. They
// are all different though should do same thing; e.g. RpcChannel setup.
ClientProtos.ClientService.BlockingInterface stub = connection.getClient(serverName);
CoprocessorServiceResponse result;
try {
result = stub.
execRegionServerService(connection.getRpcControllerFactory().newController(), csr);
return CoprocessorRpcUtils.getResponse(result, responsePrototype);
} catch (ServiceException e) {
throw ProtobufUtil.handleRemoteException(e);
}
}
};
代码示例来源:origin: org.apache.hbase/hbase-client
@Override
protected Message callExecService(final RpcController controller,
final Descriptors.MethodDescriptor method, final Message request,
final Message responsePrototype)
throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace("Call: " + method.getName() + ", " + request.toString());
}
// Try-with-resources so close gets called when we are done.
try (MasterCallable<CoprocessorServiceResponse> callable =
new MasterCallable<CoprocessorServiceResponse>(connection,
connection.getRpcControllerFactory()) {
@Override
protected CoprocessorServiceResponse rpcCall() throws Exception {
CoprocessorServiceRequest csr =
CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request);
return this.master.execMasterService(getRpcController(), csr);
}
}) {
// TODO: Are we retrying here? Does not seem so. We should use RetryingRpcCaller
callable.prepare(false);
int operationTimeout = connection.getConnectionConfiguration().getOperationTimeout();
CoprocessorServiceResponse result = callable.call(operationTimeout);
return CoprocessorRpcUtils.getResponse(result, responsePrototype);
}
}
};
代码示例来源:origin: org.apache.hbase/hbase-client
@Override
protected Message callExecService(final RpcController controller,
final Descriptors.MethodDescriptor method, final Message request,
final Message responsePrototype)
throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace("Call: " + method.getName() + ", " + request.toString());
}
if (row == null) {
throw new NullPointerException("Can't be null!");
}
ClientServiceCallable<CoprocessorServiceResponse> callable =
new ClientServiceCallable<CoprocessorServiceResponse>(this.conn,
this.table, this.row, this.conn.getRpcControllerFactory().newController(), HConstants.PRIORITY_UNSET) {
@Override
protected CoprocessorServiceResponse rpcCall() throws Exception {
byte [] regionName = getLocation().getRegionInfo().getRegionName();
CoprocessorServiceRequest csr =
CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request, row, regionName);
return getStub().execService(getRpcController(), csr);
}
};
CoprocessorServiceResponse result =
this.rpcCallerFactory.<CoprocessorServiceResponse> newCaller().callWithRetries(callable,
operationTimeout);
this.lastRegion = result.getRegion().getValue().toByteArray();
return CoprocessorRpcUtils.getResponse(result, responsePrototype);
}
代码示例来源:origin: google/closure-templates
@Override
public String coerceToString() {
// TODO(gboyer): Make this consistent with Javascript or AbstractMap.
// TODO(gboyer): Respect ProtoUtils.shouldJsIgnoreField(...)?
return proto.toString();
}
代码示例来源:origin: apache/tajo
@Override
public String toString() {
return value.toString();
}
}
代码示例来源:origin: com.google.template/soy
@Override
public String coerceToString() {
// TODO(gboyer): Make this consistent with Javascript or AbstractMap.
// TODO(gboyer): Respect ProtoUtils.shouldJsIgnoreField(...)?
return proto.toString();
}
代码示例来源:origin: org.apache.tajo/tajo-common
@Override
public String toString() {
return value.toString();
}
}
代码示例来源:origin: kubernetes-client/java
public String toString() {
if (object != null) {
return object.toString();
}
return status.toString();
}
}
代码示例来源:origin: io.kubernetes/client-java
public String toString() {
if (object != null) {
return object.toString();
}
return status.toString();
}
}
代码示例来源:origin: com.hubspot.jackson/jackson-datatype-protobuf
@Override
public void serialize(Message value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
jgen.writeStartObject();
jgen.writeStringField("toString", value.toString());
jgen.writeEndObject();
}
});
代码示例来源:origin: com.google.truth.extensions/truth-proto-extension
static FieldScope createFromSetFields(Message message) {
return create(
FieldScopeLogic.partialScope(message),
Functions.constant(String.format("FieldScopes.fromSetFields({%s})", message.toString())));
}
代码示例来源:origin: com.aliyun.hbase/alihbase-client
@Override
protected Message callExecService(RpcController controller,
Descriptors.MethodDescriptor method, Message request, Message responsePrototype)
throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace("Call: " + method.getName() + ", " + request.toString());
}
CoprocessorServiceRequest csr =
CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request);
// TODO: Are we retrying here? Does not seem so. We should use RetryingRpcCaller
// TODO: Make this same as RegionCoprocessorRpcChannel and MasterCoprocessorRpcChannel. They
// are all different though should do same thing; e.g. RpcChannel setup.
ClientProtos.ClientService.BlockingInterface stub = connection.getClient(serverName);
CoprocessorServiceResponse result;
try {
result = stub.
execRegionServerService(connection.getRpcControllerFactory().newController(), csr);
return CoprocessorRpcUtils.getResponse(result, responsePrototype);
} catch (ServiceException e) {
throw ProtobufUtil.handleRemoteException(e);
}
}
};
代码示例来源:origin: com.aliyun.openservices/tablestore
@Override
public Object getObject(ResponseMessage response)
throws ResultParseException {
Map<String, String> headers = response.getHeadersMap();
String requestId = headers.get(Constants.OTS_HEADER_REQUEST_ID);
if (requestId == null){
throw new ClientException("The required header is missing: " + Constants.OTS_HEADER_REQUEST_ID);
}
try {
Message result = message.newBuilderForType().mergeFrom(response.getContent()).buildPartial();
if (!result.isInitialized()) {
throw new UninitializedMessageException(
result).asInvalidProtocolBufferException();
}
if (logger.isDebugEnabled()) {
logger.debug("PBResponseMessage: {}, RequestId: {}, TraceId: {}", result.toString(), requestId, traceId);
}
return new ResponseContentWithMeta(
result,
new Response(requestId));
} catch(Exception e) {
throw new ResultParseException("Failed to parse response as protocol buffer message.", e);
}
}
代码示例来源:origin: FoundationDB/fdb-record-layer
@Test
public void asyncUniqueInserts() throws Exception {
List<TestRecords1Proto.MySimpleRecord> records = new ArrayList<>();
Random r = new Random(0xdeadc0deL);
for (int i = 0; i < 100; i++) {
records.add(TestRecords1Proto.MySimpleRecord.newBuilder()
.setRecNo(r.nextLong())
.setNumValueUnique(r.nextInt())
.build()
);
}
try (FDBRecordContext context = openContext()) {
openSimpleRecordStore(context);
CompletableFuture<?>[] futures = new CompletableFuture<?>[records.size()];
for (int i = 0; i < records.size(); i++) {
futures[i] = recordStore.saveRecordAsync(records.get(i));
}
CompletableFuture.allOf(futures).get();
commit(context);
}
try (FDBRecordContext context = openContext()) {
openSimpleRecordStore(context);
for (TestRecords1Proto.MySimpleRecord record : records) {
assertEquals(record.toString(), recordStore.loadRecord(Tuple.from(record.getRecNo())).getRecord().toString());
}
}
}
代码示例来源:origin: org.openbase.bco/dal.lib
String serviceAttributeRepresentation = StringProcessor.formatHumanReadable(serviceAttribute.toBuilder().clearField(ProtoBufFieldProcessor.getFieldDescriptor(serviceAttribute, Service.RESPONSIBLE_ACTION_FIELD_NAME)).build().toString());
description = description.replace(ActionDescriptionProcessor.SERVICE_ATTIBUTE_KEY, serviceAttributeRepresentation);
actionDescription.setLabel(actionDescription.getLabel().replace(ActionDescriptionProcessor.SERVICE_ATTIBUTE_KEY, serviceAttributeRepresentation));
内容来源于网络,如有侵权,请联系作者删除!