aboutsummaryrefslogtreecommitdiffhomepage
path: root/javanano
diff options
context:
space:
mode:
authorGravatar Jisi Liu <jisi.liu@gmail.com>2015-02-02 21:06:04 -0800
committerGravatar Jisi Liu <jisi.liu@gmail.com>2015-02-02 21:06:04 -0800
commit0f2a7d3feaaa9f570911a9c68c1c4fc53ffe92e2 (patch)
treeb91fbde079a5ffaf9c08f9f8ca3100552e044b1b /javanano
parent60bccb60069550b6c6971dc254b506a4f02ee8e7 (diff)
Add readData(int) to read primitive value.
Diffstat (limited to 'javanano')
-rw-r--r--javanano/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/javanano/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java b/javanano/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java
index b147f69d..58112c9a 100644
--- a/javanano/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java
+++ b/javanano/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java
@@ -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);
+ }
+ }
}