Commit 0f2a7d3f authored by Jisi Liu's avatar Jisi Liu

Add readData(int) to read primitive value.

parent 60bccb60
......@@ -638,4 +638,44 @@ public final class CodedInputByteBufferNano {
throw InvalidProtocolBufferNanoException.truncatedMessage();
}
}
// Read a primitive type.
Object readData(int type) throws IOException {
switch (type) {
case InternalNano.TYPE_DOUBLE:
return readDouble();
case InternalNano.TYPE_FLOAT:
return readFloat();
case InternalNano.TYPE_INT64:
return readInt64();
case InternalNano.TYPE_UINT64:
return readUInt64();
case InternalNano.TYPE_INT32:
return readInt32();
case InternalNano.TYPE_FIXED64:
return readFixed64();
case InternalNano.TYPE_FIXED32:
return readFixed32();
case InternalNano.TYPE_BOOL:
return readBool();
case InternalNano.TYPE_STRING:
return readString();
case InternalNano.TYPE_BYTES:
return readBytes();
case InternalNano.TYPE_UINT32:
return readUInt32();
case InternalNano.TYPE_ENUM:
return readEnum();
case InternalNano.TYPE_SFIXED32:
return readSFixed32();
case InternalNano.TYPE_SFIXED64:
return readSFixed64();
case InternalNano.TYPE_SINT32:
return readSInt32();
case InternalNano.TYPE_SINT64:
return readSInt64();
default:
throw new IllegalArgumentException("Unknown type " + type);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment