Take a look at the buildFrom() method. You need to provide an array of
FileDescriptor as dependencies. If one of your message field is a complex
type, you should build that complex type first, and pass the built
FileDescriptor object to the buildFrom() in the dependencies array.

On Wed, Jul 27, 2011 at 7:36 AM, Giancarlo Frison <gfri...@chelab.com>wrote:

> if I call setTypeName(messageName), how protobuf match the name with
> related Descriptor?
> How can I map messageName and the descriptor of the type?
>
> On Jul 27, 3:56 pm, Robert <robert.panzer...@googlemail.com> wrote:
> > Hi,
> >
> > you either call setType() for primitive types or setTypeName(String)
> > for referenced messages.
> > You pass in the name of the message.
> >
> > Kind regards,
> > Robert
> >
> > On 27 Jul., 10:35, Giancarlo Frison <gfri...@chelab.com> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Thank you very much Pherl!
> >
> > > An another question. What about not-primitive fields, or message
> > > fields?
> >
> > > when I add fields I do:
> >
> > >     DescriptorProtos.DescriptorProto.Builder desBuilder
> > >     ....
> > >     DescriptorProtos.FieldDescriptorProto.Builder fd1Builder =
> > > DescriptorProtos.FieldDescriptorProto.newBuilder()
> > >         .setName(fieldName).setNumber(i+
> > > +).setType(type).setLabel(label);
> > >     desBuilder.addField(fd1Builder.build());
> >
> > > with message typed field I set type as
> > > 'DescriptorProtos.FieldDescriptorProto.Type.TYPE_MESSAGE'. How do I
> > > describe the field type?
> > > I mean, I suppose to describe the field with a inner
> > > 'DescriptorProtos.DescriptorProto.Builder', is it correct? How I can
> > > do to describe a complex type field?
> >
> > > Thanks!
> >
> > > On Jul 26, 8:21 pm, Pherl Liu <liuj...@google.com> wrote:
> >
> > > > Not sure if I understand your question correctly. You can set the
> label in
> > > > FieldDescriptorProto:
> >
> > > > LABEL_OPTIONAL = 1;
> >
> > > > LABEL_REQUIRED      = 2;LABEL_REPEATED      = 3;
> >
> > > > On Tue, Jul 26, 2011 at 12:21 AM, Giancarlo Frison <
> gfri...@chelab.com>wrote:
> >
> > > > > There is this example that I'm approaching to re-implement
> > > > >
> http://flori.posterous.com/dynamically-creating-protocol-buffer-objects
> >
> > > > > a question:
> >
> > > > > How to handle repeated fields? How can you describe them in the
> > > > > fieldDescriptor?
> >
> > > > > On Jul 18, 5:20 pm, yoave <einavy...@gmail.com> wrote:
> > > > > > Hi all,
> >
> > > > > > I've got 2 questions:
> >
> > > > > > 1. how do I generate a Descriptor from a FileDescriptorProto in
> Java?
> > > > > >    In cpp, I'm using DescriptorPool class's 'BuildFile()'
> > > > > > functionality.
> >
> > > > > > 2. how do I generate a Dynamic Message from a Descriptor in Java?
> > > > > >    In cpp, I'm using DynamicMessageFactory class's
> 'GetPrototype()'
> > > > > > functionality.
> >
> > > > > > thanks
> >
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> Groups
> > > > > "Protocol Buffers" group.
> > > > > To post to this group, send email to protobuf@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.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to protobuf@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@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.

Reply via email to