private static HashMap<String, String> getKeyValue(HashMap<String, String> map, int pos,
      String allNameValuePairs, String listDelimiter, String nameValueSeparator) {

    if (pos >= allNameValuePairs.length()) {
      // dp("end as "+pos+" >= "+allNameValuePairs.length() );
      return map;
    }

    int equalsPos = allNameValuePairs.indexOf(nameValueSeparator, pos);
    int delimPos = allNameValuePairs.indexOf(listDelimiter, pos);

    if (delimPos == -1) {
      delimPos = allNameValuePairs.length();
    }
    if (equalsPos == -1) {
      // dp("no more equals...");
      return map;
    }
    if (delimPos == (equalsPos + 1)) {
      // dp("Ignoring as nothing between delim and equals...
      // delim:"+delimPos+" eq:"+equalsPos);
      return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter,
          nameValueSeparator);
    }
    if (equalsPos > delimPos) {
      // there is a key without a value?
      String key = allNameValuePairs.substring(pos, delimPos);
      key = key.trim();
      if (key.length() > 0) {
        map.put(key, null);
      }
      return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter,
          nameValueSeparator);

    }
    String key = allNameValuePairs.substring(pos, equalsPos);

    if (delimPos > -1) {
      String value = allNameValuePairs.substring(equalsPos + 1, delimPos);
      // dp("cont "+key+","+value+" pos:"+pos+"
      // len:"+allNameValuePairs.length());
      key = key.trim();

      map.put(key, value);
      pos = delimPos + 1;

      // recurse the rest of the values...
      return getKeyValue(map, pos, allNameValuePairs, listDelimiter, nameValueSeparator);
    } else {
      // dp("ERROR: delimPos < 0 ???");
      return map;
    }
  }