本文整理汇总了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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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());
}
示例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);
}
}
示例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);
}
示例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.");
}
示例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;
}