|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.codec.language.Soundex
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.
Field Summary | |
private int |
maxLength
Deprecated. This feature is not needed since the encoding size must be constant. |
private char[] |
soundexMapping
Every letter of the alphabet is "mapped" to a numerical value. |
static Soundex |
US_ENGLISH
This static variable contains an instance of the Soundex using the US_ENGLISH mapping. |
static char[] |
US_ENGLISH_MAPPING
This is a default mapping of the 26 letters used in US english. |
Constructor Summary | |
Soundex()
Creates an instance of the Soundex object using the default US_ENGLISH mapping. |
|
Soundex(char[] mapping)
Creates a soundex instance using a custom mapping. |
Method Summary | |
private String |
clean(String str)
Cleans up the input string before Soundex processing by only returning upper case letters. |
Object |
encode(Object pObject)
Encodes an Object using the soundex algorithm. |
String |
encode(String pString)
Encodes a String using the soundex algorithm. |
private char |
getMappingCode(String str,
int index)
Used internally by the SoundEx algorithm. |
int |
getMaxLength()
Deprecated. This feature is not needed since the encoding size must be constant. |
private char[] |
getSoundexMapping()
|
private char |
map(char c)
Maps the given upper-case character to it's Soudex code. |
void |
setMaxLength(int maxLength)
Deprecated. This feature is not needed since the encoding size must be constant. |
private void |
setSoundexMapping(char[] soundexMapping)
|
String |
soundex(String str)
Retreives the Soundex code for a given String object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final Soundex US_ENGLISH
public static final char[] US_ENGLISH_MAPPING
0
for a letter position means do not encode.
private int maxLength
private char[] soundexMapping
Constructor Detail |
public Soundex()
public Soundex(char[] mapping)
mapping
- Mapping array to use when finding the corresponding code for
a given characterMethod Detail |
private String clean(String str)
public Object encode(Object pObject) throws EncoderException
encode
in interface Encoder
pObject
- Object to encode
EncoderException
- if the parameter supplied is not of type java.lang.Stringpublic String encode(String pString)
encode
in interface StringEncoder
pString
- A String object to encode
private char getMappingCode(String str, int index)
str
- the cleaned working string to encode (in upper case).index
- the character position to encode
public int getMaxLength()
private char[] getSoundexMapping()
private char map(char c)
public void setMaxLength(int maxLength)
maxLength
- The maxLength to setprivate void setSoundexMapping(char[] soundexMapping)
soundexMapping
- The soundexMapping to set.public String soundex(String str)
str
- String to encode using the Soundex algorithm
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |