[protobuf] Re: Java and generic conversion

2009-11-01 Thread Kenton Varda
What you want to do is create a MapDescriptor, Message which maps from descriptors to default instances of each of your generated classes. For example: MapDescriptor, Message myMap = new ...; myMap.put(FooMessage.getDescriptor(), FooMessage.getDefaultInstance());

[protobuf] Re: Java and generic conversion

2009-11-01 Thread Martin Gilday
Hi Kenton, That seems to be working well. I used mergeFrom(inputStream) on the builder as below which looks the simplest way (I will add in an isInitialized check) defaultInstance.newBuilderForType().mergeFrom(inputStream).build(); Thanks for the help, Martin. On Nov 1, 8:55 pm, Kenton Varda

[protobuf] Re: Java and generic conversion

2009-10-31 Thread Evan Jones
On Oct 31, 2009, at 11:57 , Martin Gilday wrote: I would like have a generic method which takes a Descriptor and a stream which gives back an instance of message which I can later cast to my desired type. I have tried DynamicMessage from = DynamicMessage.parseFrom(descriptor, inputStream);

[protobuf] Re: Java and generic conversion

2009-10-31 Thread Martin Gilday
Hi Evan, Thanks for your reply. I am trying to do more along the lines of a). I am trying to write a DataFormat for use with Apache Camel. In Camel there is the notion of data transformations performed by the framework before and after they are sent over transports. So you say for example