Hi Moustafa,

To parse the FileDescriptor:
1. create an ExtensionRegistry using ExtensionRegistry.newInstance,
2. Use YourProtoFile.registerAllExtensions(registry)  (look for that
generated method)
3. Parse using parseFrom(data, registry)
4. Access using result.getExtension(TestProto.myOption)  // look for the
exact location in the generated code.

There's more documentation on this here:
https://developers.google.com/protocol-buffers/docs/reference/java-generated


On Wed, Jul 22, 2020 at 1:41 PM Moustafa Nassar <[email protected]> wrote:

> The file I have is:
>
> test.proto
>
> syntax = "proto3"
> import "google/protobuf/descriptor.proto"
> extend google.protobuf.FileOptions{
>     string myOption = 50000;
> }
> option (myOption) = "foo";
>
> I create a descriptor file by using: protoc --include_imports
> --descriptor_set_out="test.desc" test.proto
>
> I then get the FileDescriptor from test.desc and do
> System.out.println(FileDescriptor.getOptions()). It prints out 50000: "foo"
> but I don't know how to get that in a string or something that I can work
> with.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/04cb2072-ce76-450e-a9fc-601de703b683n%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/04cb2072-ce76-450e-a9fc-601de703b683n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
-Nadav

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CANZcNEp%2B65RqkgTbK6jmSzw-N-vnDaWe8cBGU8Ktqa3FXnrU3w%40mail.gmail.com.

Reply via email to