本文整理汇总了Java中com.google.protobuf.ByteString.toStringUtf8方法的典型用法代码示例。如果您正苦于以下问题:Java ByteString.toStringUtf8方法的具体用法?Java ByteString.toStringUtf8怎么用?Java ByteString.toStringUtf8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protobuf.ByteString
的用法示例。
在下文中一共展示了ByteString.toStringUtf8方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLogin
import com.google.protobuf.ByteString; //导入方法依赖的package包/类
@Override
public CompletableFuture<Long> onLogin(ChannelHandlerContext ctx, SocketASK ask) {
// 整个消息就是 token
ByteString tokenArg = ask.getBody().getArgs(0);
if (tokenArg == null) {
logger.info("Token arg must be input.");
return null;
}
String token = tokenArg.toStringUtf8();
if (Strings.isNullOrEmpty(token)) {
logger.info("Token arg must be input.");
return null;
}
return CompletableFuture.supplyAsync(() -> {
String parseToken = new String(BaseEncoding.base64Url().decode(token));
List<String> tokenChars = Splitter.on('|').splitToList(parseToken);
return Long.valueOf(tokenArg.toStringUtf8());
});
}
示例2: onLogin
import com.google.protobuf.ByteString; //导入方法依赖的package包/类
@Override
public CompletableFuture<Long> onLogin(ChannelHandlerContext ctx, SocketASK ask) {
// 整个消息就是 token
ByteString tokenArg = ask.getBody().getArgs(0);
if (tokenArg == null) {
logger.info("Token arg must be input.");
return null;
}
String token = tokenArg.toStringUtf8();
if (Strings.isNullOrEmpty(token)) {
logger.info("Token arg must be input.");
return null;
}
return CompletableFuture.supplyAsync(() -> {
String parseToken = new String(BaseEncoding.base64Url().decode(token));
List<String> tokenChars = Splitter.on('|').splitToList(parseToken);
Long userId = Long.valueOf(tokenArg.toStringUtf8());
RoomGroup.getRoomManger().onOnline(ctx, userId);
return userId;
});
}
示例3: collectFileData
import com.google.protobuf.ByteString; //导入方法依赖的package包/类
@Override
protected List<String> collectFileData() {
String sourePackageName = super.getSourcePackageName();
String className = super.getClassName();
String packageName = sourePackageName.toLowerCase();
List<String> packageData = Lists.newArrayList();
packageData.add("package " + packageName + ";");
packageData.add("");
List<String> importData = Lists.newArrayList();
importData.add("import com.quancheng.saluki.serializer.ProtobufAttribute;");
importData.add("import com.quancheng.saluki.serializer.ProtobufEntity;");
List<String> classAnnotationData = Lists.newArrayList();
classAnnotationData.add("");
classAnnotationData.add("@ProtobufEntity(" + sourePackageName + "." + className + ".class)");
boolean validator = false;
List<String> fileData = Lists.newArrayList();
fileData.add("public class " + className + "{");
for (int i = 0; i < messageFields.size(); i++) {
FieldDescriptorProto messageField = messageFields.get(i);
String javaType = findJavaType(packageName, sourceMessageDesc, messageField);
if (messageField.getLabel() == Label.LABEL_REPEATED && javaType != null) {
if (!javaType.contains("java.util.Map")) {
javaType = "java.util.ArrayList<" + javaType + ">";
}
}
fileData.add("");
String fieldName = messageField.getName();
UnknownFieldSet unknownFields = messageField.getOptions().getUnknownFields();
if (unknownFields != null) {
for (Map.Entry<Integer, UnknownFieldSet.Field> integerFieldEntry : unknownFields.asMap()
.entrySet()) {
for (ByteString byteString : integerFieldEntry.getValue().getLengthDelimitedList()) {
validator = true;
String validateMsg = byteString.toStringUtf8();
fileData.add(" " + validateMsg);
}
}
}
fileData.add(" @ProtobufAttribute");
fileData.add(" private " + javaType + " " + fieldName + ";");
fileData.add("");
fileData.add(" public " + javaType + " get" + captureName(fieldName) + "() {");
fileData.add(" return this." + fieldName + ";");
fileData.add(" }");
fileData.add("");
fileData.add(" public void set" + captureName(fieldName) + "(" + javaType + " " + fieldName
+ ") {");
fileData.add(" this." + fieldName + "=" + fieldName + ";");
fileData.add(" }");
fileData.add("");
}
fileData.add("}");
if (validator) {
importData.add("import com.quancheng.saluki.core.grpc.annotation.ArgValidator;");
classAnnotationData.add("@ArgValidator");
}
packageData.addAll(importData);
packageData.addAll(classAnnotationData);
packageData.addAll(fileData);
return packageData;
}