diff options
Diffstat (limited to 'java/src/main/java/com/google/protobuf/WireFormat.java')
-rw-r--r-- | java/src/main/java/com/google/protobuf/WireFormat.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/java/src/main/java/com/google/protobuf/WireFormat.java b/java/src/main/java/com/google/protobuf/WireFormat.java index ff042c05..2faf2448 100644 --- a/java/src/main/java/com/google/protobuf/WireFormat.java +++ b/java/src/main/java/com/google/protobuf/WireFormat.java @@ -96,6 +96,16 @@ public final class WireFormat { "There is no way to get here, but the compiler thinks otherwise."); } + /** Given a field descriptor, returns the wire type. This differs from + * getWireFormatForFieldType for packed repeated fields. */ + static int getWireFormatForField(Descriptors.FieldDescriptor descriptor) { + if (descriptor.getOptions().getPacked()) { + return WIRETYPE_LENGTH_DELIMITED; + } else { + return getWireFormatForFieldType(descriptor.getType()); + } + } + // Field numbers for feilds in MessageSet wire format. static final int MESSAGE_SET_ITEM = 1; static final int MESSAGE_SET_TYPE_ID = 2; |