code: protected static String urlEncode(String value, boolean path) {
          try {
              value = URLEncoder.encode(value, DEFAULT_ENCODING);
          } catch (Exception e) {
              throw wrap(e);
          }
          value = replaceAll(value, plusPtn, "%20");
          value = replaceAll(value, asteriskPtn, "%2A");
          value = replaceAll(value, pct7EPtn, "~");
          if (path) {
              value = replaceAll(value, pct2FPtn, "/");
          }
          return value;
      }
docs: URL encode a value.
  
  @param value
  
  @param path
  true if is a path and '/' should not be encoded.
  
  @return The encoded string.