@Test public void testStringToMap() { String nvp = "ui=Fred\n" + "eng=Steve"; HashMap result = Utility.stringToMap(nvp); assertEquals(result.get("ui"), "Fred"); assertEquals(result.get("eng"), "Steve"); }
public static HashMap<String, String> stringToMap(String src) { HashMap<String, String> dest = new HashMap<String, String>(); if (src == null) { return (dest); } String line, key, val; int equalsPos, newLinePos, startPos = 0, len = src.length(); while (startPos < len) { newLinePos = src.indexOf('\n', startPos); if (newLinePos == -1) { newLinePos = len; } line = src.substring(startPos, newLinePos); equalsPos = line.indexOf('='); if (equalsPos != -1) { key = line.substring(0, equalsPos); val = line.substring(equalsPos + 1); } else { key = line; val = null; } dest.put(key, val); startPos = newLinePos + 1; } return (dest); }
Utility { public static HashMap<String, String> stringToMap(String src) { HashMap<String, String> dest = new HashMap<String, String>(); if (src == null) { return (dest); } String line, key, val; int equalsPos, newLinePos, startPos = 0, len = src.length(); while (startPos < len) { newLinePos = src.indexOf('\n', startPos); if (newLinePos == -1) { newLinePos = len; } line = src.substring(startPos, newLinePos); equalsPos = line.indexOf('='); if (equalsPos != -1) { key = line.substring(0, equalsPos); val = line.substring(equalsPos + 1); } else { key = line; val = null; } dest.put(key, val); startPos = newLinePos + 1; } return (dest); } }
Utility { public static HashMap<String, String> stringToMap(String src) { HashMap<String, String> dest = new HashMap<String, String>(); if (src == null) { return (dest); } String line, key, val; int equalsPos, newLinePos, startPos = 0, len = src.length(); while (startPos < len) { newLinePos = src.indexOf('\n', startPos); if (newLinePos == -1) { newLinePos = len; } line = src.substring(startPos, newLinePos); equalsPos = line.indexOf('='); if (equalsPos != -1) { key = line.substring(0, equalsPos); val = line.substring(equalsPos + 1); } else { key = line; val = null; } dest.put(key, val); startPos = newLinePos + 1; } return (dest); } private  Utility(); }
Utility { public static HashMap<String, String> stringToMap(String src) { HashMap<String, String> dest = new HashMap<String, String>(); if (src == null) { return (dest); } String line, key, val; int equalsPos, newLinePos, startPos = 0, len = src.length(); while (startPos < len) { newLinePos = src.indexOf('\n', startPos); if (newLinePos == -1) { newLinePos = len; } line = src.substring(startPos, newLinePos); equalsPos = line.indexOf('='); if (equalsPos != -1) { key = line.substring(0, equalsPos); val = line.substring(equalsPos + 1); } else { key = line; val = null; } dest.put(key, val); startPos = newLinePos + 1; } return (dest); } 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 HashMap<String, String> stringToMap(String src) { HashMap<String, String> dest = new HashMap<String, String>(); if (src == null) { return (dest); } String line, key, val; int equalsPos, newLinePos, startPos = 0, len = src.length(); while (startPos < len) { newLinePos = src.indexOf('\n', startPos); if (newLinePos == -1) { newLinePos = len; } line = src.substring(startPos, newLinePos); equalsPos = line.indexOf('='); if (equalsPos != -1) { key = line.substring(0, equalsPos); val = line.substring(equalsPos + 1); } else { key = line; val = null; } dest.put(key, val); startPos = newLinePos + 1; } return (dest); } 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; }