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

Encodes a string into a metaphone value. More...

Inheritance diagram for Metaphone:
StringEncoder Encoder

Description

Initial Java implementation by William B. Brogden. December, 1997. Permission given by wbrogden for code to be used anywhere.

Hanging on the Metaphone by Lawrence Philips in Computer Language of Dec. 1990, p 39.

Author
Apache Software Foundation
Version
Id
Metaphone.java,v 1.20 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

 Metaphone ()
 Creates an instance of the Metaphone encoder.
 
String metaphone (String txt)
 Find the metaphone value of a String. More...
 
Object encode (Object pObject) throws EncoderException
 Encodes an Object using the metaphone algorithm. More...
 
String encode (String pString)
 Encodes a String using the Metaphone algorithm. More...
 
boolean isMetaphoneEqual (String str1, String str2)
 Tests is the metaphones of two strings are identical. More...
 
int getMaxCodeLen ()
 Returns the maxCodeLen. More...
 
void setMaxCodeLen (int maxCodeLen)
 Sets the maxCodeLen. More...
 

Member Function Documentation

◆ metaphone()

String metaphone ( String  txt)

This is similar to the soundex algorithm, but better at finding similar sounding words. All input is converted to upper case. Limitations: Input format is expected to be a single ASCII word with only characters in the A - Z range, no punctuation or numbers.

Parameters
txtString to find the metaphone code for
Returns
A metaphone code corresponding to the String supplied

◆ 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 metaphone 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
pStringString object to encode
Returns
The metaphone code corresponding to the String supplied

Implements StringEncoder.

◆ isMetaphoneEqual()

boolean isMetaphoneEqual ( String  str1,
String  str2 
)
Parameters
str1First of two strings to compare
str2Second of two strings to compare
Returns
true if the metaphones of these strings are identical, false otherwise.

◆ getMaxCodeLen()

int getMaxCodeLen ( )
Returns
int

◆ setMaxCodeLen()

void setMaxCodeLen ( int  maxCodeLen)
Parameters
maxCodeLenThe maxCodeLen to set