diff options
author | Nicholas Seckar <seckar@google.com> | 2013-11-09 16:12:17 -0800 |
---|---|---|
committer | Nicholas Seckar <seckar@google.com> | 2013-11-15 07:54:07 -0800 |
commit | 62a22a732fb134e5f34dd3e01920933ca5b16346 (patch) | |
tree | 408f11eb68a020bfbe59bc81fc4088b608d6779b /java/src/main/java/com/google/protobuf/nano/MessageNano.java | |
parent | 8a15121c1077fe883f428bd27dee6b99e06e48b6 (diff) | |
download | external_protobuf-62a22a732fb134e5f34dd3e01920933ca5b16346.zip external_protobuf-62a22a732fb134e5f34dd3e01920933ca5b16346.tar.gz external_protobuf-62a22a732fb134e5f34dd3e01920933ca5b16346.tar.bz2 |
Update MessageNano#toString() to return mostly valid TextFormat.
The output of toString is now aligned with that used by non-nano and C++
runtimes, with the exception of groups. Groups should be serialized using a
camelized name (e.g. "FooBar" rather than "foo_bar") however the nano runtime
does not have information on which fields are groups.
Changes are:
- bytes fields are output within double-quotes, non-printable characters are
output as octal escape sequences (i.e. \NNN);
- field identifiers are output in underscored format;
- unset fields are not output (rather than printing "null");
- the type name of the root message is not output.
With these changes the nano toString, normal toString, and C++'s DebugString all
produce equivalent output when given the same message. (Provided that message
uses no deprecated features.)
Change-Id: Id4791d73822846db29344db9f7bc3781c3e183a6
Diffstat (limited to 'java/src/main/java/com/google/protobuf/nano/MessageNano.java')
-rw-r--r-- | java/src/main/java/com/google/protobuf/nano/MessageNano.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/java/src/main/java/com/google/protobuf/nano/MessageNano.java b/java/src/main/java/com/google/protobuf/nano/MessageNano.java index 8d4ec39..0885cdb 100644 --- a/java/src/main/java/com/google/protobuf/nano/MessageNano.java +++ b/java/src/main/java/com/google/protobuf/nano/MessageNano.java @@ -127,7 +127,10 @@ public abstract class MessageNano { } /** - * Intended for debugging purposes only. It does not use ASCII protobuf formatting. + * Returns a string that is (mostly) compatible with ProtoBuffer's TextFormat. Note that groups + * (which are deprecated) are not serialized with the correct field name. + * + * <p>This is implemented using reflection, so it is not especially fast. */ @Override public String toString() { |