com.google.protobuf.Internal.toStringUtf8()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(172)

本文整理了Java中com.google.protobuf.Internal.toStringUtf8()方法的一些代码示例,展示了Internal.toStringUtf8()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Internal.toStringUtf8()方法的具体详情如下:
包路径:com.google.protobuf.Internal
类名称:Internal
方法名:toStringUtf8

Internal.toStringUtf8介绍

[英]Helper method to convert a byte array to a string using UTF-8 encoding.
[中]使用UTF-8编码将字节数组转换为字符串的帮助器方法。

代码示例

代码示例来源:origin: com.google.protobuf/protobuf-java

  1. private static String asString(Object o) {
  2. if (o instanceof String) {
  3. return (String) o;
  4. } else if (o instanceof ByteString) {
  5. return ((ByteString) o).toStringUtf8();
  6. } else {
  7. return Internal.toStringUtf8((byte[]) o);
  8. }
  9. }

代码示例来源:origin: com.google.protobuf/protobuf-java

  1. @Override
  2. public String get(int index) {
  3. Object o = list.get(index);
  4. if (o instanceof String) {
  5. return (String) o;
  6. } else if (o instanceof ByteString) {
  7. ByteString bs = (ByteString) o;
  8. String s = bs.toStringUtf8();
  9. if (bs.isValidUtf8()) {
  10. list.set(index, s);
  11. }
  12. return s;
  13. } else {
  14. byte[] ba = (byte[]) o;
  15. String s = Internal.toStringUtf8(ba);
  16. if (Internal.isValidUtf8(ba)) {
  17. list.set(index, s);
  18. }
  19. return s;
  20. }
  21. }

代码示例来源:origin: WeAreFairphone/FP2-Launcher

  1. private static String asString(Object o) {
  2. if (o instanceof String) {
  3. return (String) o;
  4. } else if (o instanceof ByteString) {
  5. return ((ByteString) o).toStringUtf8();
  6. } else {
  7. return Internal.toStringUtf8((byte[]) o);
  8. }
  9. }

代码示例来源:origin: com.google.protobuf/protobuf-lite

  1. private static String asString(Object o) {
  2. if (o instanceof String) {
  3. return (String) o;
  4. } else if (o instanceof ByteString) {
  5. return ((ByteString) o).toStringUtf8();
  6. } else {
  7. return Internal.toStringUtf8((byte[]) o);
  8. }
  9. }

代码示例来源:origin: yeriomin/play-store-api

  1. private static String asString(Object o) {
  2. if (o instanceof String) {
  3. return (String) o;
  4. } else if (o instanceof ByteString) {
  5. return ((ByteString) o).toStringUtf8();
  6. } else {
  7. return Internal.toStringUtf8((byte[]) o);
  8. }
  9. }

代码示例来源:origin: WeAreFairphone/FP2-Launcher

  1. @Override
  2. public String get(int index) {
  3. Object o = list.get(index);
  4. if (o instanceof String) {
  5. return (String) o;
  6. } else if (o instanceof ByteString) {
  7. ByteString bs = (ByteString) o;
  8. String s = bs.toStringUtf8();
  9. if (bs.isValidUtf8()) {
  10. list.set(index, s);
  11. }
  12. return s;
  13. } else {
  14. byte[] ba = (byte[]) o;
  15. String s = Internal.toStringUtf8(ba);
  16. if (Internal.isValidUtf8(ba)) {
  17. list.set(index, s);
  18. }
  19. return s;
  20. }
  21. }

代码示例来源:origin: com.google.protobuf/protobuf-lite

  1. @Override
  2. public String get(int index) {
  3. Object o = list.get(index);
  4. if (o instanceof String) {
  5. return (String) o;
  6. } else if (o instanceof ByteString) {
  7. ByteString bs = (ByteString) o;
  8. String s = bs.toStringUtf8();
  9. if (bs.isValidUtf8()) {
  10. list.set(index, s);
  11. }
  12. return s;
  13. } else {
  14. byte[] ba = (byte[]) o;
  15. String s = Internal.toStringUtf8(ba);
  16. if (Internal.isValidUtf8(ba)) {
  17. list.set(index, s);
  18. }
  19. return s;
  20. }
  21. }

代码示例来源:origin: yeriomin/play-store-api

  1. @Override
  2. public String get(int index) {
  3. Object o = list.get(index);
  4. if (o instanceof String) {
  5. return (String) o;
  6. } else if (o instanceof ByteString) {
  7. ByteString bs = (ByteString) o;
  8. String s = bs.toStringUtf8();
  9. if (bs.isValidUtf8()) {
  10. list.set(index, s);
  11. }
  12. return s;
  13. } else {
  14. byte[] ba = (byte[]) o;
  15. String s = Internal.toStringUtf8(ba);
  16. if (Internal.isValidUtf8(ba)) {
  17. list.set(index, s);
  18. }
  19. return s;
  20. }
  21. }

相关文章