@Test public void testMapToString() { Map map = new LinkedHashMap(); map.put("ui", "Annette"); map.put("eng", "Risa"); String expected = "ui=Annette\neng=Risa\n"; String result = Utility.mapToString(map,false,0); assertEquals(expected,result); map = new LinkedHashMap(); map.put("_has_escapes", "0"); map.put("ui", "Annette & Risa"); result = Utility.mapToString(map,false,0); expected = "_has_escapes=0\nui=Annette &amp; Risa\n"; assertEquals(expected,result); map = new LinkedHashMap(); map.put("_has_escapes", "1"); map.put("ui", "Annette &amp; Risa"); result = Utility.mapToString(map,false,0); expected = "_has_escapes=1\nui=Annette &amp; Risa\n"; assertEquals(expected,result); map = new LinkedHashMap(); map.put("_has_escapes", "true"); map.put("ui", "Annette &amp; Risa"); result = Utility.mapToString(map,false,0); expected = "_has_escapes=true\nui=Annette &amp; Risa\n"; assertEquals(expected,result); map = new LinkedHashMap(); map.put("requestMessage_randomField", "12345"); result = Utility.mapToString(map,true,0); expected = "requestMessage_randomField=xxxxx\n"; assertEquals(expected,result); }
public static String mapToString(Map src, boolean mask, int type) { StringBuilder dest = new StringBuilder(); if (src != null && !src.isEmpty()) { Iterator iter = src.keySet().iterator(); String key, val; while (iter.hasNext()) { key = (String) iter.next(); val = mask ? PCI.maskIfNotSafe(type, key, (String) src.get(key)) : (String) src.get(key); dest.append(key).append("=").append(val).append("\n"); } } else { return dest.toString(); } String hasEscapes = (String) src.get(HAS_ESCAPES); return (("1".equals(hasEscapes) || "true".equalsIgnoreCase(hasEscapes)) ? dest.toString() : StringEscapeUtils.escapeXml11((dest.toString()))); }
Utility { public static String mapToString(Map src, boolean mask, int type) { StringBuilder dest = new StringBuilder(); if (src != null && !src.isEmpty()) { Iterator iter = src.keySet().iterator(); String key, val; while (iter.hasNext()) { key = (String) iter.next(); val = mask ? PCI.maskIfNotSafe(type, key, (String) src.get(key)) : (String) src.get(key); dest.append(key).append("=").append(val).append("\n"); } } else { return dest.toString(); } String hasEscapes = (String) src.get(HAS_ESCAPES); return (("1".equals(hasEscapes) || "true".equalsIgnoreCase(hasEscapes)) ? dest.toString() : StringEscapeUtils.escapeXml11((dest.toString()))); } }
Utility { public static String mapToString(Map src, boolean mask, int type) { StringBuilder dest = new StringBuilder(); if (src != null && !src.isEmpty()) { Iterator iter = src.keySet().iterator(); String key, val; while (iter.hasNext()) { key = (String) iter.next(); val = mask ? PCI.maskIfNotSafe(type, key, (String) src.get(key)) : (String) src.get(key); dest.append(key).append("=").append(val).append("\n"); } } else { return dest.toString(); } String hasEscapes = (String) src.get(HAS_ESCAPES); return (("1".equals(hasEscapes) || "true".equalsIgnoreCase(hasEscapes)) ? dest.toString() : StringEscapeUtils.escapeXml11((dest.toString()))); } private  Utility(); }
Utility { public static String mapToString(Map src, boolean mask, int type) { StringBuilder dest = new StringBuilder(); if (src != null && !src.isEmpty()) { Iterator iter = src.keySet().iterator(); String key, val; while (iter.hasNext()) { key = (String) iter.next(); val = mask ? PCI.maskIfNotSafe(type, key, (String) src.get(key)) : (String) src.get(key); dest.append(key).append("=").append(val).append("\n"); } } else { return dest.toString(); } String hasEscapes = (String) src.get(HAS_ESCAPES); return (("1".equals(hasEscapes) || "true".equalsIgnoreCase(hasEscapes)) ? dest.toString() : StringEscapeUtils.escapeXml11((dest.toString()))); } private  Utility(); static String nodeToString(Node node, int type); static String nodeToString(Node node); static Properties readProperties(String[] commandLineArgs); static byte[] read(String filename); static byte[] read(File file); static byte[] read(InputStream in); static DocumentBuilder newDocumentBuilder(); static Element getElement(
            Document owner, String elementName, String nsURI); static String getElementText(
            Document owner, String elementName, String nsURI); static String getStackTrace(Exception e); static HashMap<String, String> stringToMap(String src); static String mapToString(Map src, boolean mask, int type); static Document readRequest(Properties props, String filename); static Document readRequest(Properties props, String filename, String merchantId); static Element createElement(
            Document owner, String nsURI, String elementName, String textValue); static long getResponseIssuedAtTime(String responseTime); static long getResponseTransitTime(long resIssuedAtTime); static String checkIfMTIFiledExist(Document request, String nsURI); static String checkIfAuthServiceFieldExist(Document request, String nsURI); }
Utility { public static String mapToString(Map src, boolean mask, int type) { StringBuilder dest = new StringBuilder(); if (src != null && !src.isEmpty()) { Iterator iter = src.keySet().iterator(); String key, val; while (iter.hasNext()) { key = (String) iter.next(); val = mask ? PCI.maskIfNotSafe(type, key, (String) src.get(key)) : (String) src.get(key); dest.append(key).append("=").append(val).append("\n"); } } else { return dest.toString(); } String hasEscapes = (String) src.get(HAS_ESCAPES); return (("1".equals(hasEscapes) || "true".equalsIgnoreCase(hasEscapes)) ? dest.toString() : StringEscapeUtils.escapeXml11((dest.toString()))); } private  Utility(); static String nodeToString(Node node, int type); static String nodeToString(Node node); static Properties readProperties(String[] commandLineArgs); static byte[] read(String filename); static byte[] read(File file); static byte[] read(InputStream in); static DocumentBuilder newDocumentBuilder(); static Element getElement(
            Document owner, String elementName, String nsURI); static String getElementText(
            Document owner, String elementName, String nsURI); static String getStackTrace(Exception e); static HashMap<String, String> stringToMap(String src); static String mapToString(Map src, boolean mask, int type); static Document readRequest(Properties props, String filename); static Document readRequest(Properties props, String filename, String merchantId); static Element createElement(
            Document owner, String nsURI, String elementName, String textValue); static long getResponseIssuedAtTime(String responseTime); static long getResponseTransitTime(long resIssuedAtTime); static String checkIfMTIFiledExist(Document request, String nsURI); static String checkIfAuthServiceFieldExist(Document request, String nsURI); static final String VERSION; static final String ORIGIN_TIMESTAMP; static final String SDK_ELAPSED_TIMESTAMP; static final String RESPONSE_TIME_REPLY; static final String MERCHANT_TRANSACTION_IDENTIFIER; static final String AUTH_SERVICE; static final String AUTH_SERVICE_XML_RUN_ATT; static final String AUTH_SERVICE_NVP; static final String ELEM_MERCHANT_ID; static final String KEY_ALIAS; static final String ELEM_MERCHANT_REFERENCE_CODE; static final String ELEM_CLIENT_LIBRARY; static final String ELEM_CLIENT_LIBRARY_VERSION; static final String ELEM_CLIENT_ENVIRONMENT; static final int HTTP_BAD_REQUEST; static final String MTI_FIELD_ERR_MSG; static final String NVP_LIBRARY; static final String XML_LIBRARY; static final String ENVIRONMENT; }