Encodes a string into a Soundex value. More...
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.
The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.
/* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Public Member Functions | |
int | difference (String s1, String s2) throws EncoderException |
Encodes the Strings and returns the number of characters in the two encoded Strings that are the same. More... | |
Soundex () | |
Creates an instance using US_ENGLISH_MAPPING. More... | |
Soundex (char[] mapping) | |
Creates a soundex instance using the given mapping. More... | |
Object | encode (Object pObject) throws EncoderException |
Encodes an Object using the soundex algorithm. More... | |
String | encode (String pString) |
Encodes a String using the soundex algorithm. More... | |
int | getMaxLength () |
Returns the maxLength. More... | |
void | setMaxLength (int maxLength) |
Sets the maxLength. More... | |
String | soundex (String str) |
Retreives the Soundex code for a given String object. More... | |
Static Public Attributes | |
static final Soundex | US_ENGLISH = new Soundex() |
An instance of Soundex using the US_ENGLISH_MAPPING mapping. More... | |
static final String | US_ENGLISH_MAPPING_STRING = "01230120022455012623010202" |
This is a default mapping of the 26 letters used in US English. More... | |
static final char[] | US_ENGLISH_MAPPING = US_ENGLISH_MAPPING_STRING.toCharArray() |
This is a default mapping of the 26 letters used in US English. More... | |
Soundex | ( | char[] | 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
mapping | Mapping array to use when finding the corresponding code for a given character |
int difference | ( | String | s1, |
String | s2 | ||
) | throws EncoderException |
This return value ranges from 0 through 4: 0 indicates little or no similarity, and 4 indicates strong similarity or identical values.
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 strings |
Object encode | ( | Object | pObject | ) | throws EncoderException |
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.
pObject | Object to encode |
EncoderException | if the parameter supplied is not of type java.lang.String |
IllegalArgumentException | if a character is not mapped |
Implements Encoder.
String encode | ( | String | pString | ) |
pString | A String object to encode |
IllegalArgumentException | if a character is not mapped |
Implements StringEncoder.
int getMaxLength | ( | ) |
Standard Soundex
void setMaxLength | ( | int | maxLength | ) |
maxLength | The maxLength to set |
String soundex | ( | String | str | ) |
str | String to encode using the Soundex algorithm |
IllegalArgumentException | if a character is not mapped |
|
static |
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.)
|
static |
A value of 0
for a letter position means do not encode.