commonlib/src/main/java/com/streamsets/pipeline/lib/util/ProtobufTypeUtil.java
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);

  }
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);

  }
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.

@param set               set of file descriptors
@param fileDescriptorMap map of message types to file descriptors
@param descriptorFile    descriptor file for message to be decoded
@param qualifiedMessageType       the name of the message to be decoded
@return protobuf descriptor instance
@throws StageException
Generates a protobuf descriptor instance from a FileDescriptor set .