org.apache.commons.codec.language
public class Soundex extends Object implements StringEncoder
Version: $Id: Soundex.java 130399 2004-07-07 23:15:24Z ggregory $
Field Summary | |
---|---|
int | maxLength
The maximum length of a Soundex code - Soundex codes are only four characters by definition.
|
char[] | soundexMapping
Every letter of the alphabet is "mapped" to a numerical value. |
static Soundex | US_ENGLISH
An instance of Soundex using the US_ENGLISH_MAPPING mapping.
|
static char[] | US_ENGLISH_MAPPING
This is a default mapping of the 26 letters used in US English. |
static String | US_ENGLISH_MAPPING_STRING
This is a default mapping of the 26 letters used in US English. |
Constructor Summary | |
---|---|
Soundex()
Creates an instance using US_ENGLISH_MAPPING
| |
Soundex(char[] mapping)
Creates a soundex instance using the given mapping. |
Method Summary | |
---|---|
int | difference(String s1, String s2)
Encodes the Strings and returns the number of characters in the two encoded Strings that are the same. |
Object | encode(Object pObject)
Encodes an Object using the soundex algorithm. |
String | encode(String pString)
Encodes a String using the soundex algorithm.
|
char | getMappingCode(String str, int index)
Used internally by the SoundEx algorithm.
|
int | getMaxLength()
Returns the maxLength. |
char[] | getSoundexMapping()
Returns the soundex mapping.
|
char | map(char ch)
Maps the given upper-case character to it's Soudex code.
|
void | setMaxLength(int maxLength)
Sets the maxLength.
|
void | setSoundexMapping(char[] soundexMapping)
Sets the soundexMapping.
|
String | soundex(String str)
Retreives the Soundex code for a given String object.
|
Deprecated: This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
The maximum length of a Soundex code - Soundex codes are only four characters by definition.See Also: US_ENGLISH_MAPPING
0
for a letter position
means do not encode.
See Also: (char[])
0
for a letter position
means do not encode.
(This constant is provided as both an implementation convenience and to allow Javadoc to pick up the value for the constant values page.)
See Also: US_ENGLISH_MAPPING
See Also: (char[])
US_ENGLISH_MAPPING
Parameters: mapping Mapping array to use when finding the corresponding code for a given character
Parameters: s1 A String that will be encoded and compared. s2 A String that will be encoded and compared.
Returns: The number of characters in the two encoded Strings that are the same from 0 to 4.
Throws: EncoderException if an error occurs encoding one of the strings
Since: 1.3
See Also: difference MS
T-SQL DIFFERENCE
Parameters: pObject Object to encode
Returns: An object (or type java.lang.String) containing the soundex code which corresponds to the String supplied.
Throws: EncoderException if the parameter supplied is not of type java.lang.String IllegalArgumentException if a character is not mapped
Parameters: pString A String object to encode
Returns: A Soundex code corresponding to the String supplied
Throws: IllegalArgumentException if a character is not mapped
Parameters: str the cleaned working string to encode (in upper case). index the character position to encode
Returns: Mapping code for a particular character
Throws: IllegalArgumentException if the character is not mapped
Deprecated: This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
Returns the maxLength. Standard SoundexReturns: int
Returns: soundexMapping.
Parameters: ch An upper-case character.
Returns: A Soundex code.
Throws: IllegalArgumentException
Thrown if ch
is not mapped.
Deprecated: This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
Sets the maxLength.Parameters: maxLength The maxLength to set
Parameters: soundexMapping The soundexMapping to set.
Parameters: str String to encode using the Soundex algorithm
Returns: A soundex code for the String supplied
Throws: IllegalArgumentException if a character is not mapped