当前位置: 首页>>代码示例>>Java>>正文


Java CodedInputStream.readBool方法代码示例

本文整理汇总了Java中com.google.protobuf.CodedInputStream.readBool方法的典型用法代码示例。如果您正苦于以下问题:Java CodedInputStream.readBool方法的具体用法?Java CodedInputStream.readBool怎么用?Java CodedInputStream.readBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.protobuf.CodedInputStream的用法示例。


在下文中一共展示了CodedInputStream.readBool方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserializeMultipleItemChildArray

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
private Object deserializeMultipleItemChildArray(
    Map<ByteString, Object> digestToChild, CodedInputStream childCodedIn, int childCount)
    throws IOException, SerializationException {
  Object[] children = new Object[childCount];
  for (int i = 0; i < childCount; ++i) {
    boolean isTransitiveEntry = childCodedIn.readBool();
    if (isTransitiveEntry) {
      ByteString digest = childCodedIn.readBytes();
      children[i] =
          Preconditions.checkNotNull(digestToChild.get(digest), "Transitive nested set missing");
    } else {
      children[i] = objectCodec.deserialize(childCodedIn);
    }
  }
  return children;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:17,代码来源:NestedSetCodec.java

示例2: deserialize

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
@Override
public Root deserialize(FileSystemProvider dependency, CodedInputStream codedIn)
    throws SerializationException, IOException {
  boolean isAbsolute = codedIn.readBool();
  if (isAbsolute) {
    return dependency.getFileSystem().getAbsoluteRoot();
  } else {
    Path path = Path.CODEC.deserialize(dependency, codedIn);
    return new PathRoot(path);
  }
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:12,代码来源:Root.java

示例3: deserialize

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
@Override
public PathFragment deserialize(CodedInputStream codedIn)
    throws IOException, SerializationException {
  char driveLetter = (char) codedIn.readInt32();
  boolean isAbsolute = codedIn.readBool();
  int segmentCount = codedIn.readInt32();
  String[] segments = new String[segmentCount];
  for (int i = 0; i < segmentCount; i++) {
    segments[i] = stringCodec.deserialize(codedIn);
  }
  return PathFragment.create(driveLetter, isAbsolute, segments);
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:13,代码来源:PathFragment.java

示例4: deserialize

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
/**
 * Deserializes a polymorphic type.
 *
 * @param dependency if null, it means that the parent, polymorphic type, provides no dependency.
 *     It is valid for dependency to be non-null, with an enclosed null value. This means the
 *     dependency itself is null (as opposed to non-existent).
 */
@SuppressWarnings("unchecked")
public static Object deserialize(CodedInputStream codedIn, @Nullable Optional<?> dependency)
    throws IOException, SerializationException {
  Object deserialized = null;
  if (codedIn.readBool()) {
    String className = StringCodecs.asciiOptimized().deserialize(codedIn);
    try {
      Object codec = getCodec(Class.forName(className));
      if (codec instanceof ObjectCodec) {
        return ((ObjectCodec) codec).deserialize(codedIn);
      } else if (codec instanceof InjectingObjectCodec) {
        if (dependency == null) {
          throw new SerializationException(
              className + " deserialize parent class lacks required dependency.");
        }
        return ((InjectingObjectCodec) codec).deserialize(dependency.orElse(null), codedIn);
      } else {
        throw new SerializationException(
            className + ".CODEC has unexpected type " + codec.getClass().getCanonicalName());
      }
    } catch (ReflectiveOperationException e) {
      throw new SerializationException(className, e);
    }
  }
  return deserialized;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:34,代码来源:PolymorphicHelper.java

示例5: deserialize

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
@Override
public GlobDescriptor deserialize(CodedInputStream codedIn)
    throws SerializationException, IOException {
  PackageIdentifier packageId = packageIdCodec.deserialize(codedIn);
  Root packageRoot = rootCodec.deserialize(codedIn);
  PathFragment pathFragment = PathFragment.CODEC.deserialize(codedIn);
  String pattern = stringCodec.deserialize(codedIn);
  boolean excludeDirs = codedIn.readBool();
  return GlobDescriptor.create(packageId, packageRoot, pathFragment, pattern, excludeDirs);
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:11,代码来源:GlobDescriptor.java

示例6: deserialize

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
static Component deserialize(CodedInputStream in) throws IOException {
  String alphaSequence = null;
  if (in.readBool()) {
    alphaSequence = in.readString();
  }
  return new Component(in.readInt32(), alphaSequence, in.readInt32(), in.readString());
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:8,代码来源:DottedVersion.java

示例7: deserialize

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
@Override
public RepositoryName deserialize(CodedInputStream codedIn)
    throws SerializationException, IOException {
  boolean isMain = codedIn.readBool();
  if (isMain) {
    return RepositoryName.MAIN;
  }
  try {
    // We can read the string we wrote back as bytes to avoid string decoding/copying.
    return deserializeRepoName(codedIn.readBytes());
  } catch (LabelSyntaxException e) {
    throw new SerializationException("Failed to deserialize RepositoryName", e);
  }
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:15,代码来源:RepositoryNameCodec.java

示例8: readPoint

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
private void readPoint(Track track, CodedInputStream input) throws IOException {
    int latitudeE6 = 0;
    int longitudeE6 = 0;
    boolean continuous = true;
    float altitude = Float.NaN;
    float speed = Float.NaN;
    float bearing = Float.NaN;
    float accuracy = Float.NaN;
    long timestamp = 0L;

    boolean done = false;
    while (!done) {
        int tag = input.readTag();
        int field = WireFormat.getTagFieldNumber(tag);
        switch (field) {
            case 0:
                done = true;
                break;
            default: {
                throw new com.google.protobuf.InvalidProtocolBufferException("Unsupported proto field: " + tag);
            }
            case FIELD_POINT_LATITUDE: {
                latitudeE6 = input.readInt32();
                break;
            }
            case FIELD_POINT_LONGITUDE: {
                longitudeE6 = input.readInt32();
                break;
            }
            case FIELD_POINT_ALTITUDE: {
                altitude = input.readFloat();
                break;
            }
            case FIELD_POINT_SPEED: {
                speed = input.readFloat();
                break;
            }
            case FIELD_POINT_BEARING: {
                bearing = input.readFloat();
                break;
            }
            case FIELD_POINT_ACCURACY: {
                accuracy = input.readFloat();
                break;
            }
            case FIELD_POINT_TIMESTAMP: {
                timestamp = input.readUInt64();
                break;
            }
            case FIELD_POINT_CONTINUOUS: {
                continuous = input.readBool();
                break;
            }
        }
    }
    track.addPointFast(continuous, latitudeE6, longitudeE6, altitude, speed, bearing, accuracy, timestamp);
}
 
开发者ID:andreynovikov,项目名称:trekarta,代码行数:58,代码来源:TrackManager.java

示例9: readPrimitiveField

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
/**
 * Read a field of any primitive type for immutable messages from a CodedInputStream. Enums, groups, and embedded
 * messages are not handled by this method.
 *
 * @param input The stream from which to read.
 * @param type Declared type of the field.
 * @param checkUtf8 When true, check that the input is valid utf8.
 * @return An object representing the field's value, of the exact type which would be returned by
 *         {@link Message#getField(Descriptors.FieldDescriptor)} for this field.
 * @throws IOException Signals that an I/O exception has occurred.
 */
public static Object readPrimitiveField(CodedInputStream input, final WireFormat.FieldType type, boolean checkUtf8)
        throws IOException {
    switch (type) {
        case DOUBLE:
            return input.readDouble();
        case FLOAT:
            return input.readFloat();
        case INT64:
            return input.readInt64();
        case UINT64:
            return input.readUInt64();
        case INT32:
            return input.readInt32();
        case FIXED64:
            return input.readFixed64();
        case FIXED32:
            return input.readFixed32();
        case BOOL:
            return input.readBool();
        case STRING:
            if (checkUtf8) {
                return input.readStringRequireUtf8();
            } else {
                return input.readString();
            }
        case BYTES:
            return input.readBytes();
        case UINT32:
            return input.readUInt32();
        case SFIXED32:
            return input.readSFixed32();
        case SFIXED64:
            return input.readSFixed64();
        case SINT32:
            return input.readSInt32();
        case SINT64:
            return input.readSInt64();

        case GROUP:
            throw new IllegalArgumentException("readPrimitiveField() cannot handle nested groups.");
        case MESSAGE:
            throw new IllegalArgumentException("readPrimitiveField() cannot handle embedded messages.");
        case ENUM:
            // We don't handle enums because we don't know what to do if the
            // value is not recognized.
            throw new IllegalArgumentException("readPrimitiveField() cannot handle enums.");
    }

    throw new RuntimeException("There is no way to get here, but the compiler thinks otherwise.");
}
 
开发者ID:jhunters,项目名称:jprotobuf,代码行数:62,代码来源:CodedConstant.java

示例10: deserializeNullable

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
public static <T> T deserializeNullable(CodedInputStream in, ObjectCodec<T> codec)
    throws IOException, SerializationException {
  return in.readBool() ? codec.deserialize(in) : null;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:5,代码来源:SerializationCommonUtils.java


注:本文中的com.google.protobuf.CodedInputStream.readBool方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。