@Test public void encodeContext() throws Exception { Map context = ObjectUtils.asMap("caption", "different = caption", "alt2", "alt|alternative"); String result = Util.encodeContext(context); assertTrue("caption=different \\= caption|alt2=alt\\|alternative".equals(result) || "alt2=alt\\|alternative|caption=different \\= caption".equals(result)); }
protected static String encodeContext(Object context) { if (context instanceof Map) { Map<String, Object> mapArg = (Map<String, Object>) context; HashSet out = new HashSet(); for (Map.Entry<String, Object> entry : mapArg.entrySet()) { final String value; if (entry.getValue() instanceof List) { value = encodeList(((List) entry.getValue()).toArray()); } else if (entry.getValue() instanceof String[]) { value = encodeList((String[]) entry.getValue()); } else { value = entry.getValue().toString(); } out.add(entry.getKey() + "=" + encodeSingleContextString(value)); } return StringUtils.join(out.toArray(), "|"); } else if (context == null) { return null; } else { return context.toString(); } }
Util { protected static String encodeContext(Object context) { if (context instanceof Map) { Map<String, Object> mapArg = (Map<String, Object>) context; HashSet out = new HashSet(); for (Map.Entry<String, Object> entry : mapArg.entrySet()) { final String value; if (entry.getValue() instanceof List) { value = encodeList(((List) entry.getValue()).toArray()); } else if (entry.getValue() instanceof String[]) { value = encodeList((String[]) entry.getValue()); } else { value = entry.getValue().toString(); } out.add(entry.getKey() + "=" + encodeSingleContextString(value)); } return StringUtils.join(out.toArray(), "|"); } else if (context == null) { return null; } else { return context.toString(); } } }
Util { protected static String encodeContext(Object context) { if (context instanceof Map) { Map<String, Object> mapArg = (Map<String, Object>) context; HashSet out = new HashSet(); for (Map.Entry<String, Object> entry : mapArg.entrySet()) { final String value; if (entry.getValue() instanceof List) { value = encodeList(((List) entry.getValue()).toArray()); } else if (entry.getValue() instanceof String[]) { value = encodeList((String[]) entry.getValue()); } else { value = entry.getValue().toString(); } out.add(entry.getKey() + "=" + encodeSingleContextString(value)); } return StringUtils.join(out.toArray(), "|"); } else if (context == null) { return null; } else { return context.toString(); } }  }
Util { protected static String encodeContext(Object context) { if (context instanceof Map) { Map<String, Object> mapArg = (Map<String, Object>) context; HashSet out = new HashSet(); for (Map.Entry<String, Object> entry : mapArg.entrySet()) { final String value; if (entry.getValue() instanceof List) { value = encodeList(((List) entry.getValue()).toArray()); } else if (entry.getValue() instanceof String[]) { value = encodeList((String[]) entry.getValue()); } else { value = entry.getValue().toString(); } out.add(entry.getKey() + "=" + encodeSingleContextString(value)); } return StringUtils.join(out.toArray(), "|"); } else if (context == null) { return null; } else { return context.toString(); } }  @SuppressWarnings({"rawtypes", "unchecked"}) static final Map<String, Object> buildUploadParams(Map options); static Map buildMultiParams(Map options); static Map<String, Object> buildGenerateSpriteParams(Map options); @SuppressWarnings("unchecked") static final void processWriteParameters(Map<String, Object> options, Map<String, Object> params); @SuppressWarnings("rawtypes") static void clearEmpty(Map params); @SuppressWarnings({"rawtypes", "unchecked"}) static final Map<String, Object> buildArchiveParams(Map options, String targetFormat); static byte[] getUTF8Bytes(String string); static String produceSignature(Map<String, Object> paramsToSign, String apiSecret); static String produceSignature(Map<String, Object> paramsToSign, String apiSecret, SignatureAlgorithm signatureAlgorithm); static byte[] hash(String input, SignatureAlgorithm signatureAlgorithm); }
Util { protected static String encodeContext(Object context) { if (context instanceof Map) { Map<String, Object> mapArg = (Map<String, Object>) context; HashSet out = new HashSet(); for (Map.Entry<String, Object> entry : mapArg.entrySet()) { final String value; if (entry.getValue() instanceof List) { value = encodeList(((List) entry.getValue()).toArray()); } else if (entry.getValue() instanceof String[]) { value = encodeList((String[]) entry.getValue()); } else { value = entry.getValue().toString(); } out.add(entry.getKey() + "=" + encodeSingleContextString(value)); } return StringUtils.join(out.toArray(), "|"); } else if (context == null) { return null; } else { return context.toString(); } }  @SuppressWarnings({"rawtypes", "unchecked"}) static final Map<String, Object> buildUploadParams(Map options); static Map buildMultiParams(Map options); static Map<String, Object> buildGenerateSpriteParams(Map options); @SuppressWarnings("unchecked") static final void processWriteParameters(Map<String, Object> options, Map<String, Object> params); @SuppressWarnings("rawtypes") static void clearEmpty(Map params); @SuppressWarnings({"rawtypes", "unchecked"}) static final Map<String, Object> buildArchiveParams(Map options, String targetFormat); static byte[] getUTF8Bytes(String string); static String produceSignature(Map<String, Object> paramsToSign, String apiSecret); static String produceSignature(Map<String, Object> paramsToSign, String apiSecret, SignatureAlgorithm signatureAlgorithm); static byte[] hash(String input, SignatureAlgorithm signatureAlgorithm);  }