class Utils {

    public static String urlEncodeQueryParams(String params, boolean urlEncode) throws UrlEncodeException {
        String encodedParams = params;
        if (!urlEncode) {
            try {
                encodedParams = URLDecoder.decode(params, DEFAULT_CHARACTER_SET);
            } catch (UnsupportedEncodingException e) {
//                never happens
                throw new RuntimeException(e);
            } catch (IllegalArgumentException ie) {
                throw new UrlEncodeException(ie.getMessage(), ie);
            }
        }
        return encodedParams;
    }

}