code: @Override
  	public HierarchicalUriComponents encode(String encoding) throws UnsupportedEncodingException {
  		Assert.hasLength(encoding, "Encoding must not be empty");
  		if (this.encoded) {
  			return this;
  		}
  		String encodedScheme = encodeUriComponent(getScheme(), encoding, Type.SCHEME);
  		String encodedUserInfo = encodeUriComponent(this.userInfo, encoding, Type.USER_INFO);
  		String encodedHost = encodeUriComponent(this.host, encoding, getHostType());
  
  		PathComponent encodedPath = this.path.encode(encoding);
  		MultiValueMap<String, String> encodedQueryParams =
  				new LinkedMultiValueMap<String, String>(this.queryParams.size());
  		for (Map.Entry<String, List<String>> entry : this.queryParams.entrySet()) {
  			String encodedName = encodeUriComponent(entry.getKey(), encoding, Type.QUERY_PARAM);
  			List<String> encodedValues = new ArrayList<String>(entry.getValue().size());
  			for (String value : entry.getValue()) {
  				String encodedValue = encodeUriComponent(value, encoding, Type.QUERY_PARAM);
  				encodedValues.add(encodedValue);
  			}
  			encodedQueryParams.put(encodedName, encodedValues);
  		}
  		String encodedFragment = encodeUriComponent(this.getFragment(), encoding, Type.FRAGMENT);
  		return new HierarchicalUriComponents(encodedScheme, encodedUserInfo, encodedHost, this.port, encodedPath,
  				encodedQueryParams, encodedFragment, true, false);
  	}
docs: Encodes all URI components using their specific encoding rules, and returns the result as a new
  {@code UriComponents} instance.
  @param encoding the encoding of the values contained in this map
  @return the encoded uri components
  @throws UnsupportedEncodingException if the given encoding is not supported