public static Descriptors . Descriptor getDescriptor ( DescriptorProtos . FileDescriptorSet set , Map < String , Descriptors . FileDescriptor > fileDescriptorMap , String descriptorFile , String qualifiedMessageType ) throws StageException { // find the FileDescriptorProto which contains the message type // IF cannot find, then bail out String packageName = null ; String messageType = qualifiedMessageType ; int lastIndex = qualifiedMessageType . lastIndexOf ( ' ' ) ; if ( lastIndex != - 1 ) { packageName = qualifiedMessageType . substring ( 0 , lastIndex ) ; messageType = qualifiedMessageType . substring ( lastIndex + 1 ) ; } DescriptorProtos . FileDescriptorProto file = getFileDescProtoForMsgType ( packageName , messageType , set ) ; if ( file == null ) { // could not find the message type from all the proto files contained in the descriptor file throw new StageException ( Errors . PROTOBUF_00 , qualifiedMessageType , descriptorFile ) ; } // finally get the FileDescriptor for the message type Descriptors . FileDescriptor fileDescriptor = fileDescriptorMap . get ( file . getName ( ) ) ; // create builder using the FileDescriptor // this can only find the top level message types return fileDescriptor . findMessageTypeByName ( messageType ) ; }
Generates a protobuf descriptor instance from a FileDescriptor set .