/** * Get the specified value URL encoded using the specified encoding * * @param k the value to encode * @param contentEncoding the encoding to use when URL encoding * @return the value URL encoded using the specified encoding * @throws UnsupportedEncodingException if the specified encoding is not supported */ public String getEncoded(String k, String contentEncoding) throws UnsupportedEncodingException { String cacheKey = k + contentEncoding; // Check if we have it in the cache Object encodedValue = cache.getElement(cacheKey); if (encodedValue != null) { return (String) encodedValue; } // Perform the encoding encodedValue = URLEncoder.encode(k, contentEncoding); // Add to cache cache.addElement(cacheKey, encodedValue); return (String) encodedValue; } }