/** * Retreives the Soundex code for a given String object. * * @param str String to encode using the Soundex algorithm * @return A soundex code for the String supplied * @throws IllegalArgumentException if a character is not mapped */ @DSGenerator( tool_name = "Doppelganger", tool_version = "2.0", generated_on = "2014-09-03 14:59:48.718 -0400", hash_original_method = "0EBBB65C00DFAFB7B6E0400F5755712C", hash_generated_method = "94B188BA634D9793A5790601BA8B7F45") public String soundex(String str) { if (str == null) { return null; } str = SoundexUtils.clean(str); if (str.length() == 0) { return str; } char out[] = {'0', '0', '0', '0'}; char last, mapped; int incount = 1, count = 1; out[0] = str.charAt(0); last = getMappingCode(str, 0); while ((incount < str.length()) && (count < out.length)) { mapped = getMappingCode(str, incount++); if (mapped != 0) { if ((mapped != '0') && (mapped != last)) { out[count++] = mapped; } last = mapped; } } return new String(out); }