本文整理了Java中com.google.protobuf.ByteString.copyFromUtf8()
方法的一些代码示例,展示了ByteString.copyFromUtf8()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteString.copyFromUtf8()
方法的具体详情如下:
包路径:com.google.protobuf.ByteString
类名称:ByteString
方法名:copyFromUtf8
[英]Encodes text into a sequence of UTF-8 bytes and returns the result as a ByteString.
[中]将文本编码为UTF-8字节序列,并将结果作为ByteString返回。
代码示例来源:origin: bazelbuild/bazel
/**
* <code>optional string default_string = 5;</code>
*/
public com.google.protobuf.ByteString
getDefaultStringBytes() {
java.lang.Object ref = defaultString_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
defaultString_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
代码示例来源:origin: bazelbuild/bazel
/**
* <code>optional string default_string = 5;</code>
*/
public com.google.protobuf.ByteString
getDefaultStringBytes() {
java.lang.Object ref = defaultString_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
defaultString_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
代码示例来源:origin: alibaba/canal
/**
* <code>string destination = 5;</code>
*/
public com.google.protobuf.ByteString
getDestinationBytes() {
java.lang.Object ref = destination_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
destination_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
代码示例来源:origin: alibaba/canal
/**
* <code>string client_id = 2;</code>
*/
public com.google.protobuf.ByteString
getClientIdBytes() {
java.lang.Object ref = clientId_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
clientId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
代码示例来源:origin: alibaba/canal
/**
* <code>string filter = 7;</code>
*/
public com.google.protobuf.ByteString
getFilterBytes() {
java.lang.Object ref = filter_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
filter_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
代码示例来源:origin: alibaba/canal
/**
* <code>string client_id = 2;</code>
*/
public com.google.protobuf.ByteString
getClientIdBytes() {
java.lang.Object ref = clientId_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
clientId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
代码示例来源:origin: alibaba/canal
/**
* <code>string journal = 1;</code>
*/
public com.google.protobuf.ByteString
getJournalBytes() {
java.lang.Object ref = journal_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
journal_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
代码示例来源:origin: alibaba/canal
/**
* <code>string client_id = 2;</code>
*/
public com.google.protobuf.ByteString
getClientIdBytes() {
java.lang.Object ref = clientId_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
clientId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
代码示例来源:origin: alibaba/canal
/**
* <code>string destination = 1;</code>
*/
public com.google.protobuf.ByteString
getDestinationBytes() {
java.lang.Object ref = destination_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
destination_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
代码示例来源:origin: alibaba/canal
/**
* <code>string filter = 7;</code>
*/
public com.google.protobuf.ByteString
getFilterBytes() {
java.lang.Object ref = filter_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
filter_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
代码示例来源:origin: alibaba/canal
/**
* <code>string destination = 1;</code>
*/
public com.google.protobuf.ByteString
getDestinationBytes() {
java.lang.Object ref = destination_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
destination_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
代码示例来源:origin: alibaba/canal
/**
* <code>string client_id = 2;</code>
*/
public com.google.protobuf.ByteString
getClientIdBytes() {
java.lang.Object ref = clientId_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
clientId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* <code>optional string foo = 1;</code>
*/
public com.google.protobuf.ByteString
getFooBytes() {
Object ref = foo_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
foo_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* <code>optional string foo = 1;</code>
*/
public com.google.protobuf.ByteString
getFooBytes() {
java.lang.Object ref = foo_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
foo_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* <code>optional string foo = 1;</code>
*/
public com.google.protobuf.ByteString
getFooBytes() {
Object ref = foo_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
foo_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
代码示例来源:origin: spring-projects/spring-framework
/**
* <code>optional string foo = 1;</code>
*/
public com.google.protobuf.ByteString
getFooBytes() {
java.lang.Object ref = foo_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
foo_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
代码示例来源:origin: apache/incubator-shardingsphere
@Override
public void persist(final String key, final String value) {
final PutRequest request = PutRequest.newBuilder().setPrevKv(true).setKey(ByteString.copyFromUtf8(key)).setValue(ByteString.copyFromUtf8(value)).build();
etcdRetryEngine.execute(new Callable<Void>() {
@Override
public Void call() throws InterruptedException, ExecutionException, TimeoutException {
kvStub.put(request).get(config.getOperationTimeoutMilliseconds(), TimeUnit.MILLISECONDS);
return null;
}
});
}
代码示例来源:origin: apache/incubator-shardingsphere
@Override
public String get(final String key) {
final RangeRequest request = RangeRequest.newBuilder().setKey(ByteString.copyFromUtf8(key)).build();
return etcdRetryEngine.execute(new Callable<String>() {
@Override
public String call() throws InterruptedException, ExecutionException, TimeoutException {
RangeResponse response = kvStub.range(request).get(config.getOperationTimeoutMilliseconds(), TimeUnit.MILLISECONDS);
return response.getKvsCount() > 0 ? response.getKvs(0).getValue().toStringUtf8() : null;
}
}).orNull();
}
代码示例来源:origin: apache/incubator-shardingsphere
@Override
public void persistEphemeral(final String key, final String value) {
final Optional<Long> leaseId = lease();
if (!leaseId.isPresent()) {
throw new RegistryCenterException("Unable to set up heat beat for key %s", key);
}
final PutRequest request = PutRequest.newBuilder().setPrevKv(true).setLease(leaseId.get()).setKey(ByteString.copyFromUtf8(key)).setValue(ByteString.copyFromUtf8(value)).build();
etcdRetryEngine.execute(new Callable<Void>() {
@Override
public Void call() throws InterruptedException, ExecutionException, TimeoutException {
kvStub.put(request).get(config.getOperationTimeoutMilliseconds(), TimeUnit.MILLISECONDS);
return null;
}
});
}
代码示例来源:origin: apache/incubator-shardingsphere
@Override
public void watch(final String key, final DataChangedEventListener dataChangedEventListener) {
WatchCreateRequest createWatchRequest = WatchCreateRequest.newBuilder().setKey(ByteString.copyFromUtf8(key)).setRangeEnd(getRangeEnd(key)).build();
final WatchRequest request = WatchRequest.newBuilder().setCreateRequest(createWatchRequest).build();
etcdRetryEngine.execute(new Callable<Void>() {
@Override
public Void call() {
watchStub.watch(new EtcdWatchStreamObserver(dataChangedEventListener)).onNext(request);
return null;
}
});
}
内容来源于网络,如有侵权,请联系作者删除!