Example usage for com.amazonaws.transform MapEntry setValue

List of usage examples for com.amazonaws.transform MapEntry setValue

Introduction

In this page you can find the example usage for com.amazonaws.transform MapEntry setValue.

Prototype

public V setValue(V value) 

Source Link

Usage

From source file:com.erudika.para.utils.OAuth1HmacSigner.java

License:Apache License

private static String normalizeRequestParameters(Map<String, String[]> params) throws IOException {
    if (params == null) {
        return "";
    }// www  .jav  a  2  s .c o m

    List<ComparableParameter> paramz = new ArrayList<ComparableParameter>(params.size());
    for (Map.Entry<String, String[]> param : params.entrySet()) {
        if (!"oauth_signature".equals(param.getKey()) || "realm".equals(param.getKey())) {
            for (String val : param.getValue()) {
                MapEntry<String, String> me = new MapEntry<String, String>();
                me.setKey(param.getKey());
                me.setValue(val);
                paramz.add(new ComparableParameter(me));
            }
        }
    }
    Collections.sort(paramz);

    StringBuilder sb = new StringBuilder();
    Iterator<ComparableParameter> iter = paramz.iterator();
    for (int i = 0; iter.hasNext(); i++) {
        ComparableParameter p = iter.next();
        String param = p.key;
        String value = p.value;
        if (i > 0) {
            sb.append("&");
        }
        if (value == null) {
            sb.append(param.concat("="));
        } else {
            sb.append(param.concat("=").concat(value));
        }
    }
    String s = sb.toString();
    return s;
}