當前位置: 首頁>>代碼示例>>Java>>正文


Java ByteString.toStringUtf8方法代碼示例

本文整理匯總了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());
    });
}
 
開發者ID:freedompy,項目名稱:commelina,代碼行數:20,代碼來源:NioSocketEventHandlerForAkka.java

示例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;
    });
}
 
開發者ID:freedompy,項目名稱:commelina,代碼行數:23,代碼來源:NioSocketEventHandler.java

示例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;
}
 
開發者ID:venus-boot,項目名稱:saluki,代碼行數:66,代碼來源:PrintMessageFile.java


注:本文中的com.google.protobuf.ByteString.toStringUtf8方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。