public class Soundex extends Object implements StringEncoder
maxLength
field is not actually used.Modifier and Type | Field and Description |
---|---|
static Soundex |
US_ENGLISH
An instance of Soundex using the US_ENGLISH_MAPPING mapping.
|
static String |
US_ENGLISH_MAPPING_STRING
This is a default mapping of the 26 letters used in US English.
|
Constructor and Description |
---|
Soundex()
Creates an instance using US_ENGLISH_MAPPING
|
Soundex(char[] mapping)
Creates a soundex instance using the given mapping.
|
Soundex(String mapping)
Creates a refined soundex instance using a custom mapping.
|
Modifier and Type | Method and Description |
---|---|
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 obj)
Encodes an Object using the soundex algorithm.
|
String |
encode(String str)
Encodes a String using the soundex algorithm.
|
int |
getMaxLength()
Deprecated.
This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
|
void |
setMaxLength(int maxLength)
Deprecated.
This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
|
String |
soundex(String str)
Retrieves the Soundex code for a given String object.
|
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 Soundex US_ENGLISH
US_ENGLISH_MAPPING
public Soundex()
Soundex(char[])
,
US_ENGLISH_MAPPING
public Soundex(char[] mapping)
mapping
- Mapping array to use when finding the corresponding code for a given characterpublic Soundex(String mapping)
mapping
- Mapping string to use when finding the corresponding code for a given characterpublic 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 obj) throws EncoderException
encode
in interface Encoder
obj
- Object to encodeEncoderException
- if the parameter supplied is not of type java.lang.StringIllegalArgumentException
- if a character is not mappedpublic String encode(String str)
encode
in interface StringEncoder
str
- A String object to encodeIllegalArgumentException
- if a character is not mapped@Deprecated public int getMaxLength()
@Deprecated public void setMaxLength(int maxLength)
maxLength
- The maxLength to setpublic String soundex(String str)
str
- String to encode using the Soundex algorithmIllegalArgumentException
- if a character is not mappedCopyright © 2002–2014 The Apache Software Foundation. All rights reserved.