code: private static String[] harvestApplicationWithArguments(String arg)
      {
          List<String> args = new ArrayList<>();
  
          if (arg.trim().length() >= 0)
          {
              String appl = "", data = "";
  
              /* Find the first occurrence of either '(' or ',' */
              int firstc = arg.indexOf(',');
              int firstp = arg.indexOf('(');
  
              if (firstc != -1 && (firstp == -1 || firstc < firstp))
              {
                  /* comma found, no parenthesis */
                  /* or both found, but comma found first */
                  String[] split = arg.split(",");
                  appl = split[0];
                  for (int i = 1; i < split.length; i++)
                      data += split[i] + (i + 1 < split.length ? "," : "");
              }
              else if (firstc == -1 && firstp == -1)
              {
                  /* Neither found */
                  data = "";
              }
              else
              {
                  /* Final remaining case is parenthesis found first */
                  String[] split = arg.split("\\(");
                  appl = split[0];
                  for (int i = 1; i < split.length; i++)
                      data += split[i] + (i + 1 < split.length ? "(" : "");
                  int end = data.lastIndexOf(')');
                  if (end == -1)
                  {
                      // ast_log(LOG_WARNING, "No closing parenthesis found?
                      // '%s(%s'\n", appl, data);
                  }
                  else if (end == data.length() - 1)
                  {
                      data = data.substring(0, end);
                  }
                  data = processQuotesAndSlashes(data, ',', '|');
              }
  
              if (!appl.trim().equals(""))
              {
                  args.add(appl.trim());
                  if (!data.trim().equals(""))
                  {
                      String[] dataSplit = data.split("\\|");
                      for (String aDataSplit : dataSplit)
                      {
                          args.add(aDataSplit.trim());
                      }
                  }
              }
          }
  
          return args.toArray(new String[args.size()]);
      }
docs: /* Roughly corresponds to pbx_config.c:2276