aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java
Commit message (Collapse)AuthorAgeFilesLines
* Exclude cachedSize when printing fields.Brian Duff2015-01-221-0/+4
| | | | Change-Id: I85563b74237d38c1e447b7286f5f6e62d57e3d63
* Fixed octal printing of bytearraysLinus Tufvesson2014-08-291-1/+1
| | | | | | - Now with 50% less '&' and 100% fewer build breakages! Change-Id: Icf0283220f75cd14b8564b51bd55973e5b7da56b
* Revert "Fixed octal printing of bytearrays"Max Cai2014-08-281-1/+1
| | | | | | This reverts commit 8b8481868877c9db407d04bdf4843e50d8920806. Change-Id: I0876235b79cd7745312879d0f1b00c6d1c1a1b7a
* Fixed octal printing of bytearraysLinus Tufvesson2014-08-281-1/+1
| | | | Change-Id: Ia848d7fae9aeab89e65b00f05cee6c1e6d649d94
* Fix MessageNanoPrinter for accessorsAndrew Flynn2013-12-121-22/+63
| | | | | | | | | accessors mode switches proto fields away from being public fields (which is how MessageNanoPrinter found which fields to print via reflection). Add a pass through the methods looking for generated accessor methods to print those as well. Change-Id: I7c47853ecbd5534086f44b25a89dbbe56f63ed03
* Avoid class initializers to help ProGuard.Max Cai2013-12-101-18/+17
| | | | | | | | | | | | | | | | | | | Class initializers prevent ProGuard from inlining any methods because it thinks the class initializer may have side effects. This is true for static methods, but instance methods can still be inlined, because to have an instance you will have touched the class and any class initializers would have run. But ProGuard only starts inlining instance methods of classes with class initializers from v4.11b6, and Android uses v4.4 now. This change tries to avoid the class initializers as much as possible, by delaying the initialization of the empty array and some fields' saved defaults until when they're needed. However, if the message hosts any extensions, they must be public static final and therefore introducing the class initializer. In that case we won't bother with lazy initialization. Change-Id: I00d8296f6eb0023112b93ee135cdb28dbd52b0b8
* Update MessageNano#toString() to return mostly valid TextFormat.Nicholas Seckar2013-11-151-17/+55
| | | | | | | | | | | | | | | | | | | | 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
* Protect against null repeated fields.Brian Duff2013-10-141-1/+1
| | | | | | | | | There's no distinction between a repeated field being null and being empty. In both cases, nothing is sent on the wire. Clients might for whatever reason inadvertently set a repeated field to null, so protect against that and treat it just as if the field was empty. Change-Id: Ic3846f7f2189d6cfff6f8ef3ca217daecc3c8be7
* Add toString() method to MessageNano.Andrew Flynn2013-06-041-0/+179
- All of the real work for printing the proto is actually done in MessageNanoPrinter. - Uses reflection to find proto-defined fields and prints those. - Prints all fields, even defaults and nulls. - Also added a simple test to make sure it handles all proto types well. Tried not to make the test too brittle (but hey it's testing a toString() so how flexible can it be) Change-Id: I3e360ef8b0561041e010c1f3445ec45ecdcd2559