@Test public void testFormat() throws Exception { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("movie", "Kiler"); parameters.put("director", "Machulski"); String format = OAuthUtils.format(parameters.entrySet(), "UTF-8"); assertEquals("movie=Kiler&director=Machulski", format); }
public static String format( final Collection<? extends Map.Entry<String, Object>> parameters, final String encoding) { final StringBuilder result = new StringBuilder(); for (final Map.Entry<String, Object> parameter : parameters) { String value = parameter.getValue() == null? null : String.valueOf(parameter.getValue()); if (!OAuthUtils.isEmpty(parameter.getKey()) && !OAuthUtils.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(); }
OAuthUtils { public static String format( final Collection<? extends Map.Entry<String, Object>> parameters, final String encoding) { final StringBuilder result = new StringBuilder(); for (final Map.Entry<String, Object> parameter : parameters) { String value = parameter.getValue() == null? null : String.valueOf(parameter.getValue()); if (!OAuthUtils.isEmpty(parameter.getKey()) && !OAuthUtils.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(); } }
OAuthUtils { public static String format( final Collection<? extends Map.Entry<String, Object>> parameters, final String encoding) { final StringBuilder result = new StringBuilder(); for (final Map.Entry<String, Object> parameter : parameters) { String value = parameter.getValue() == null? null : String.valueOf(parameter.getValue()); if (!OAuthUtils.isEmpty(parameter.getKey()) && !OAuthUtils.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(); }  }
OAuthUtils { public static String format( final Collection<? extends Map.Entry<String, Object>> parameters, final String encoding) { final StringBuilder result = new StringBuilder(); for (final Map.Entry<String, Object> parameter : parameters) { String value = parameter.getValue() == null? null : String.valueOf(parameter.getValue()); if (!OAuthUtils.isEmpty(parameter.getKey()) && !OAuthUtils.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(); }  static String format(
        final Collection<? extends Map.Entry<String, Object>> parameters,
        final String encoding); static String saveStreamAsString(InputStream is); static String toString(
        final InputStream is, final String defaultCharset); static OAuthProblemException handleOAuthProblemException(String message); static OAuthProblemException handleMissingParameters(Set<String> missingParams); static OAuthProblemException handleBadContentTypeException(String expectedContentType); static OAuthProblemException handleNotAllowedParametersOAuthException(
        List<String> notAllowedParams); static Map<String, Object> decodeForm(String form); static boolean isFormEncoded(String contentType); static String decodePercent(String s); static String percentEncode(String s); static T instantiateClass(Class<T> clazz); static T instantiateClassWithParameters(Class<T> clazz, Class<?>[] paramsTypes,
                                                       Object[] paramValues); static String getAuthHeaderField(String authHeader); static Map<String, String> decodeOAuthHeader(String header); static String[] decodeClientAuthenticationHeader(String authenticationHeader); static String encodeOAuthHeader(Map<String, Object> entries); static String encodeAuthorizationBearerHeader(Map<String, Object> entries); static boolean isEmpty(String value); static boolean hasEmptyValues(String[] array); static String getAuthzMethod(String header); static Set<String> decodeScopes(String s); static String encodeScopes(Set<String> s); static boolean isMultipart(HttpServletRequest request); static boolean hasContentType(String requestContentType, String requiredContentType); }
OAuthUtils { public static String format( final Collection<? extends Map.Entry<String, Object>> parameters, final String encoding) { final StringBuilder result = new StringBuilder(); for (final Map.Entry<String, Object> parameter : parameters) { String value = parameter.getValue() == null? null : String.valueOf(parameter.getValue()); if (!OAuthUtils.isEmpty(parameter.getKey()) && !OAuthUtils.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(); }  static String format(
        final Collection<? extends Map.Entry<String, Object>> parameters,
        final String encoding); static String saveStreamAsString(InputStream is); static String toString(
        final InputStream is, final String defaultCharset); static OAuthProblemException handleOAuthProblemException(String message); static OAuthProblemException handleMissingParameters(Set<String> missingParams); static OAuthProblemException handleBadContentTypeException(String expectedContentType); static OAuthProblemException handleNotAllowedParametersOAuthException(
        List<String> notAllowedParams); static Map<String, Object> decodeForm(String form); static boolean isFormEncoded(String contentType); static String decodePercent(String s); static String percentEncode(String s); static T instantiateClass(Class<T> clazz); static T instantiateClassWithParameters(Class<T> clazz, Class<?>[] paramsTypes,
                                                       Object[] paramValues); static String getAuthHeaderField(String authHeader); static Map<String, String> decodeOAuthHeader(String header); static String[] decodeClientAuthenticationHeader(String authenticationHeader); static String encodeOAuthHeader(Map<String, Object> entries); static String encodeAuthorizationBearerHeader(Map<String, Object> entries); static boolean isEmpty(String value); static boolean hasEmptyValues(String[] array); static String getAuthzMethod(String header); static Set<String> decodeScopes(String s); static String encodeScopes(Set<String> s); static boolean isMultipart(HttpServletRequest request); static boolean hasContentType(String requestContentType, String requiredContentType); static final String AUTH_SCHEME; static final String MULTIPART; }