public static String format(
			final Collection<? extends Map.Entry<String, String>> parameters,
			final String encoding)
	{
		final StringBuilder result = new StringBuilder();
		for (final Map.Entry<String, String> parameter : parameters)
		{
			String value = parameter.getValue() == null ? null : String
					.valueOf(parameter.getValue());
			if (!isEmpty(parameter.getKey()) && !isEmpty(value))
			{
				final String encodedName = encode(parameter.getKey(), encoding);
				final String encodedValue = value != null ? encode(value,
						encoding) : "";
				if (result.length() > 0)
				{
					result.append(PARAMETER_SEPARATOR);
				}
				result.append(encodedName);
				result.append(NAME_VALUE_SEPARATOR);
				result.append(encodedValue);
			}
		}
		return result.toString();
	}