• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.0.1.79
Soundex Class Reference

Encodes a string into a Soundex value. More...

Inheritance diagram for Soundex:
StringEncoder Encoder

Description

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

Notice

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...
 

Constructor & Destructor Documentation

◆ Soundex() [1/2]

◆ Soundex() [2/2]

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

Parameters
mappingMapping array to use when finding the corresponding code for a given character

Member Function Documentation

◆ difference()

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.

Parameters
s1A String that will be encoded and compared.
s2A String that will be encoded and compared.
Returns
The number of characters in the two encoded Strings that are the same from 0 to 4.
See also
MS T-SQL DIFFERENCE
Exceptions
EncoderExceptionif an error occurs encoding one of the strings
Since
1.3

◆ encode() [1/2]

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.

Parameters
pObjectObject to encode
Returns
An object (or type java.lang.String) containing the soundex code which corresponds to the String supplied.
Exceptions
EncoderExceptionif the parameter supplied is not of type java.lang.String
IllegalArgumentExceptionif a character is not mapped

Implements Encoder.

◆ encode() [2/2]

String encode ( String  pString)
Parameters
pStringA String object to encode
Returns
A Soundex code corresponding to the String supplied
Exceptions
IllegalArgumentExceptionif a character is not mapped

Implements StringEncoder.

◆ getMaxLength()

int getMaxLength ( )

Standard Soundex

Deprecated:
This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
Returns
int

◆ setMaxLength()

void setMaxLength ( int  maxLength)
Deprecated:
This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
Parameters
maxLengthThe maxLength to set

◆ soundex()

String soundex ( String  str)
Parameters
strString to encode using the Soundex algorithm
Returns
A soundex code for the String supplied
Exceptions
IllegalArgumentExceptionif a character is not mapped

Member Data Documentation

◆ US_ENGLISH

final Soundex US_ENGLISH = new Soundex()
static

◆ US_ENGLISH_MAPPING_STRING

final String US_ENGLISH_MAPPING_STRING = "01230120022455012623010202"
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.)

See also
US_ENGLISH_MAPPING

◆ US_ENGLISH_MAPPING

final char [] US_ENGLISH_MAPPING = US_ENGLISH_MAPPING_STRING.toCharArray()
static

A value of 0 for a letter position means do not encode.

See also
Soundex::Soundex(char[])