Messages are indeed immutable once built. getXXXList() for both the builder and the message should return unmodifiable lists: if you try to modify them you should get an exception. If you haven't already, take a look at the Java tutorial here: http://code.google.com/apis/protocolbuffers/docs/javatutorial.html
For your particular problem I think you'll need do a clearXXX() on the entire list, and add back all the elements except the entry you want to discard. On Wed, Mar 17, 2010 at 7:57 AM, Ron <tequila...@ymail.com> wrote: > i didn't see anything on this in the archives but i admit i didn't do > an exhaustive search. i'm using protobuf (2.3.0) to store objects in > a Voldemort cluster and am working on the code to modify these > objects. so i load the message fine, but it is composed of a list of > other messages and i'd like to modify the contents of that list and > then stream it back into the cluster. i assumed this is what > Type.newBuilder(Type) was for, but have run into an interesting > wrinkle trying to modify the list (once i've located the entry i want > to remove by index). Builder.getXXXList() returns an > unmodifiableList, but the actual message's getXXXList() returns a ref > to the actual list (i.e., i could modify the list in the message, but > not the list within the message within the builder). i haven't gone > through all the code yet but this seemed rather odd since i had > thought messages within builders were mutable until build() but once > built were considered immutable (tho perhaps that's just in my head). > > is there a doc showing best practices for modifying Protobuf messages > i should be reading? > > thanks, > .......................ron. > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To post to this group, send email to proto...@googlegroups.com. > To unsubscribe from this group, send email to > protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/protobuf?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.