| |
|
| java.lang.Object org.apache.commons.codec.language.Soundex
Soundex | public class Soundex implements StringEncoder(Code) | | Encodes a string into a Soundex value. Soundex is an encoding used to relate similar names, but can also be used as a
general purpose scheme to find word with similar phonemes.
author: Apache Software Foundation version: $Id: Soundex.java,v 1.26 2004/07/07 23:15:24 ggregory Exp $ |
Field Summary | |
final public static Soundex | US_ENGLISH An instance of Soundex using the US_ENGLISH_MAPPING mapping. | final public static char[] | US_ENGLISH_MAPPING This is a default mapping of the 26 letters used in US English. | final public static String | US_ENGLISH_MAPPING_STRING This is a default mapping of the 26 letters used in US English. |
Constructor Summary | |
public | Soundex() | public | Soundex(char[] mapping) Creates a soundex instance using the given mapping. |
Method Summary | |
public int | difference(String s1, String s2) Encodes the Strings and returns the number of characters in the two encoded Strings that are the same. | public Object | encode(Object pObject) Encodes an Object using the soundex algorithm. | public String | encode(String pString) Encodes a String using the soundex algorithm. | public int | getMaxLength() Returns the maxLength. | public void | setMaxLength(int maxLength) Sets the maxLength. | public String | soundex(String str) Retreives the Soundex code for a given String object. |
US_ENGLISH_MAPPING | final public static char[] US_ENGLISH_MAPPING(Code) | | This is a default mapping of the 26 letters used in US English. A value of 0 for a letter position
means do not encode.
See Also: Soundex.Soundex(char[]) |
US_ENGLISH_MAPPING_STRING | final public static String US_ENGLISH_MAPPING_STRING(Code) | | This is a default mapping of the 26 letters used in US English. A value of 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: Soundex.US_ENGLISH_MAPPING |
Soundex | public Soundex(char[] mapping)(Code) | | Creates a soundex instance using the given mapping. This constructor can be used to provide an internationalized
mapping for a non-Western character set.
Every letter of the alphabet is "mapped" to a numerical value. This char array holds the values to which each
letter is mapped. This implementation contains a default map for US_ENGLISH
Parameters: mapping - Mapping array to use when finding the corresponding code for a given character |
difference | public int difference(String s1, String s2) throws EncoderException(Code) | | Encodes the Strings and returns the number of characters in the two encoded Strings that are the same. This
return value ranges from 0 through 4: 0 indicates little or no similarity, and 4 indicates strong similarity or
identical values.
Parameters: s1 - A String that will be encoded and compared. Parameters: s2 - A String that will be encoded and compared. The number of characters in the two encoded Strings that are the same from 0 to 4. See Also: SoundexUtils.difference(StringEncoderStringString) See Also: MS
* T-SQL DIFFERENCE throws: EncoderException - if an error occurs encoding one of the strings since: 1.3 |
encode | public Object encode(Object pObject) throws EncoderException(Code) | | Encodes an Object using the 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.
Parameters: pObject - Object to encode An object (or type java.lang.String) containing the soundex code which corresponds to the Stringsupplied. throws: EncoderException - if the parameter supplied is not of type java.lang.String throws: IllegalArgumentException - if a character is not mapped |
encode | public String encode(String pString)(Code) | | Encodes a String using the soundex algorithm.
Parameters: pString - A String object to encode A Soundex code corresponding to the String supplied throws: IllegalArgumentException - if a character is not mapped |
getMaxLength | public int getMaxLength()(Code) | | Returns the maxLength. Standard Soundex
int |
setMaxLength | public void setMaxLength(int maxLength)(Code) | | Sets the maxLength.
Parameters: maxLength - The maxLength to set |
soundex | public String soundex(String str)(Code) | | Retreives the Soundex code for a given String object.
Parameters: str - String to encode using the Soundex algorithm A soundex code for the String supplied throws: IllegalArgumentException - if a character is not mapped |
|
|
|