@Test public void testArrayToHashtableSuc() { String[] entries1 = { "a=A", "b=B" }; Map<String, String> res1 = new HashMap<String, String>(); res1.put("a", "A"); res1.put("b", "B"); AssertJUnit.assertEquals(res1, JNDIUtil.arrayToHashtable(entries1, null)); }
public static Hashtable<String, String> arrayToHashtable(String[] entries, ConnectorMessages messages) { Hashtable<String, String> result = new Hashtable<String, String>(); if (entries != null) { for (String entry : entries) { if (StringUtil.isNotBlank(entry)) { int firstEq = entry.indexOf('='); if (firstEq == -1) { throwFormatException(messages, entry, "Invalid value in JNDI entry"); } if (firstEq == 0) { throwFormatException(messages, entry, "First character cannot be ="); } final String key = entry.substring(0, firstEq); final String value = firstEq == entry.length() - 1 ? null : entry.substring(firstEq + 1); result.put(key, value); } } } return result; }
JNDIUtil { public static Hashtable<String, String> arrayToHashtable(String[] entries, ConnectorMessages messages) { Hashtable<String, String> result = new Hashtable<String, String>(); if (entries != null) { for (String entry : entries) { if (StringUtil.isNotBlank(entry)) { int firstEq = entry.indexOf('='); if (firstEq == -1) { throwFormatException(messages, entry, "Invalid value in JNDI entry"); } if (firstEq == 0) { throwFormatException(messages, entry, "First character cannot be ="); } final String key = entry.substring(0, firstEq); final String value = firstEq == entry.length() - 1 ? null : entry.substring(firstEq + 1); result.put(key, value); } } } return result; } }
JNDIUtil { public static Hashtable<String, String> arrayToHashtable(String[] entries, ConnectorMessages messages) { Hashtable<String, String> result = new Hashtable<String, String>(); if (entries != null) { for (String entry : entries) { if (StringUtil.isNotBlank(entry)) { int firstEq = entry.indexOf('='); if (firstEq == -1) { throwFormatException(messages, entry, "Invalid value in JNDI entry"); } if (firstEq == 0) { throwFormatException(messages, entry, "First character cannot be ="); } final String key = entry.substring(0, firstEq); final String value = firstEq == entry.length() - 1 ? null : entry.substring(firstEq + 1); result.put(key, value); } } } return result; } private  JNDIUtil(); }
JNDIUtil { public static Hashtable<String, String> arrayToHashtable(String[] entries, ConnectorMessages messages) { Hashtable<String, String> result = new Hashtable<String, String>(); if (entries != null) { for (String entry : entries) { if (StringUtil.isNotBlank(entry)) { int firstEq = entry.indexOf('='); if (firstEq == -1) { throwFormatException(messages, entry, "Invalid value in JNDI entry"); } if (firstEq == 0) { throwFormatException(messages, entry, "First character cannot be ="); } final String key = entry.substring(0, firstEq); final String value = firstEq == entry.length() - 1 ? null : entry.substring(firstEq + 1); result.put(key, value); } } } return result; } private  JNDIUtil(); static Hashtable<String, String> arrayToHashtable(String[] entries,
            ConnectorMessages messages); }
JNDIUtil { public static Hashtable<String, String> arrayToHashtable(String[] entries, ConnectorMessages messages) { Hashtable<String, String> result = new Hashtable<String, String>(); if (entries != null) { for (String entry : entries) { if (StringUtil.isNotBlank(entry)) { int firstEq = entry.indexOf('='); if (firstEq == -1) { throwFormatException(messages, entry, "Invalid value in JNDI entry"); } if (firstEq == 0) { throwFormatException(messages, entry, "First character cannot be ="); } final String key = entry.substring(0, firstEq); final String value = firstEq == entry.length() - 1 ? null : entry.substring(firstEq + 1); result.put(key, value); } } } return result; } private  JNDIUtil(); static Hashtable<String, String> arrayToHashtable(String[] entries,
            ConnectorMessages messages); static final String INVALID_JNDI_ENTRY; }