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

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

Inheritance diagram for RefinedSoundex:
StringEncoder Encoder

Description

A refined soundex code is optimized for spell checking words. Soundex method originally developed by Margaret Odell and Robert Russell.

Author
Apache Software Foundation
Version
Id
RefinedSoundex.java,v 1.21 2004/06/05 18:32:04 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

 RefinedSoundex ()
 Creates an instance of the RefinedSoundex object using the default US English mapping.
 
 RefinedSoundex (char[] mapping)
 Creates a refined soundex instance using a custom mapping. More...
 
int difference (String s1, String s2) throws EncoderException
 Returns the number of characters in the two encoded Strings that are the same. More...
 
Object encode (Object pObject) throws EncoderException
 Encodes an Object using the refined soundex algorithm. More...
 
String encode (String pString)
 Encodes a String using the refined soundex algorithm. More...
 
String soundex (String str)
 Retreives the Refined Soundex code for a given String object. More...
 

Static Public Attributes

static final RefinedSoundex US_ENGLISH = new RefinedSoundex()
 This static variable contains an instance of the RefinedSoundex using the US_ENGLISH mapping.
 
static final char[] US_ENGLISH_MAPPING = "01360240043788015936020505".toCharArray()
 RefinedSoundex is *refined* for a number of reasons one being that the mappings have been altered. More...
 

Constructor & Destructor Documentation

◆ RefinedSoundex()

RefinedSoundex ( char[]  mapping)

This constructor can be used to customize the mapping, and/or possibly provide an internationalized mapping for a non-Western character set.

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 to the length of the shortest encoded String: 0 indicates little or no similarity, and 4 out of 4 (for example) indicates strong similarity or identical values. For refined Soundex, the return value can be greater than 4.

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 to the length of the shortest encoded String.
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 refined soundex code which corresponds to the String supplied.
Exceptions
EncoderExceptionif the parameter supplied is not of type java.lang.String

Implements Encoder.

◆ encode() [2/2]

String encode ( String  pString)
Parameters
pStringA String object to encode
Returns
A Soundex code corresponding to the String supplied

Implements StringEncoder.

◆ soundex()

String soundex ( String  str)
Parameters
strString to encode using the Refined Soundex algorithm
Returns
A soundex code for the String supplied

Member Data Documentation

◆ US_ENGLISH_MAPPING

final char [] US_ENGLISH_MAPPING = "01360240043788015936020505".toCharArray()
static

This implementation contains default mappings for US English.