|
|||||||||||
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. Will be removed in 2.0. |
private 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. |
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. Will be removed in 2.0. |
private char[] |
getSoundexMapping()
Returns the soundex mapping. |
private char |
map(char ch)
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. Will be removed in 2.0. |
private void |
setSoundexMapping(char[] soundexMapping)
Sets the 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
US_ENGLISH_MAPPING
public static final String US_ENGLISH_MAPPING_STRING
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.)
US_ENGLISH_MAPPING
,
Constant Field Valuespublic static final char[] US_ENGLISH_MAPPING
0
for a letter position
means do not encode.
Soundex(char[])
private int maxLength
private char[] soundexMapping
Constructor Detail |
public Soundex()
Soundex(char[])
,
US_ENGLISH_MAPPING
public Soundex(char[] mapping)
mapping
- Mapping array to use when finding the corresponding code for a given characterMethod Detail |
public int difference(String s1, String s2) throws EncoderException
s1
- A String that will be encoded and compared.s2
- A String that will be encoded and compared.
EncoderException
- if an error occurs encoding one of the stringsSoundexUtils.difference(StringEncoder,String,String)
,
MS
T-SQL DIFFERENCE 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.String
IllegalArgumentException
- if a character is not mappedpublic String encode(String pString)
encode
in interface StringEncoder
pString
- A String object to encode
IllegalArgumentException
- if a character is not mappedprivate char getMappingCode(String str, int index)
str
- the cleaned working string to encode (in upper case).index
- the character position to encode
IllegalArgumentException
- if the character is not mappedpublic int getMaxLength()
private char[] getSoundexMapping()
private char map(char ch)
ch
- An upper-case character.
IllegalArgumentException
- Thrown if ch
is not mapped.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
IllegalArgumentException
- if a character is not mapped
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |