Methods Summary |
---|
public int | difference(java.lang.String s1, java.lang.String s2)Returns the number of characters in the two encoded Strings that are the
same. This return value ranges from 0 to the length of the shortest
encoded String: 0 indicates little or no similarity, and 4 out of 4 (for
example) indicates strong similarity or identical values. For refined
Soundex, the return value can be greater than 4.
return SoundexUtils.difference(this, s1, s2);
|
public java.lang.Object | encode(java.lang.Object pObject)Encodes an Object using the refined soundex algorithm. This method is
provided in order to satisfy the requirements of the Encoder interface,
and will throw an EncoderException if the supplied object is not of type
java.lang.String.
if (!(pObject instanceof java.lang.String)) {
throw new EncoderException("Parameter supplied to RefinedSoundex encode is not of type java.lang.String");
}
return soundex((String) pObject);
|
public java.lang.String | encode(java.lang.String pString)Encodes a String using the refined soundex algorithm.
return soundex(pString);
|
char | getMappingCode(char c)Returns the mapping code for a given character. The mapping codes are
maintained in an internal char array named soundexMapping, and the
default values of these mappings are US English.
if (!Character.isLetter(c)) {
return 0;
}
return this.soundexMapping[Character.toUpperCase(c) - 'A"];
|
public java.lang.String | soundex(java.lang.String str)Retreives the Refined Soundex code for a given String object.
if (str == null) {
return null;
}
str = SoundexUtils.clean(str);
if (str.length() == 0) {
return str;
}
StringBuffer sBuf = new StringBuffer();
sBuf.append(str.charAt(0));
char last, current;
last = '*";
for (int i = 0; i < str.length(); i++) {
current = getMappingCode(str.charAt(i));
if (current == last) {
continue;
} else if (current != 0) {
sBuf.append(current);
}
last = current;
}
return sBuf.toString();
|