code: public static String encodeValue(String segment, String[] encoding) {
          ArrayList<String> params = new ArrayList<String>();
          boolean foundParam = false;
          StringBuffer newSegment = new StringBuffer();
          if (savePathParams(segment, newSegment, params)) {
              foundParam = true;
              segment = newSegment.toString();
          }
          String result = encodeFromArray(segment, encoding, false);
          result = encodeNonCodes(result);
          segment = result;
          if (foundParam) {
              segment = pathParamReplacement(segment, params);
          }
          return segment;
      }
docs: Keep encoded values "%..." and template parameters intact i.e. "{x}"
  
  @param segment
  @param encoding
  @return