org.apache.commons.codec.language
Class Metaphone

java.lang.Object
  |
  +--org.apache.commons.codec.language.Metaphone
All Implemented Interfaces:
Encoder, StringEncoder

public class Metaphone
extends java.lang.Object
implements StringEncoder

A class to generate phonetic code. The initial Java implementation, William B. Brogden. December, 1997 Permission given by wbrogden for code to be used anywhere. "Hanging on the Metaphone" by Lawrence Philips Computer Language of Dec. 1990, p 39

Version:
$Revision: 1.1 $ $Date: 2003/04/25 17:50:56 $
Author:
wbrogden@bga.com, bayard@generationjava.com, tobrien@transolutions.net

Constructor Summary
Metaphone()
           
 
Method Summary
 java.lang.Object encode(java.lang.Object pObject)
          All encoders allow a library-user to pass an Object and get an Object in return.
 java.lang.String encode(java.lang.String pString)
          Encode a String and produce a String.
 int getMaxCodeLen()
          Returns the maxCodeLen.
 boolean isMetaphoneEqual(java.lang.String str1, java.lang.String str2)
          Are the metaphones of two strings the same.
 java.lang.String metaphone(java.lang.String txt)
          Find the metaphone value of a String.
 void setMaxCodeLen(int maxCodeLen)
          Sets the maxCodeLen.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Metaphone

public Metaphone()
Method Detail

metaphone

public java.lang.String metaphone(java.lang.String txt)
Find the metaphone value of a String. 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.


encode

public java.lang.Object encode(java.lang.Object pObject)
                        throws EncoderException
Description copied from interface: Encoder
All encoders allow a library-user to pass an Object and get an Object in return. This function encodes an "Object" - returning the encoded content as an Object. The Objects here may just be byte[] or Strings depending on the implementation used.

Specified by:
encode in interface Encoder
Parameters:
pObject - An object ot encode
Returns:
An "encoded" Object
Throws:
EncoderException - an encoder exception is thrown if the encoder experiences a failure condition during the encoding process.

encode

public java.lang.String encode(java.lang.String pString)
                        throws EncoderException
Description copied from interface: StringEncoder
Encode a String and produce a String.

Specified by:
encode in interface StringEncoder
Parameters:
pString - a String to encode
Returns:
the encoded String
Throws:
EncoderException - thrown if there is an error conidition during the Encoding process.

isMetaphoneEqual

public boolean isMetaphoneEqual(java.lang.String str1,
                                java.lang.String str2)
Are the metaphones of two strings the same.


getMaxCodeLen

public int getMaxCodeLen()
Returns the maxCodeLen.

Returns:
int

setMaxCodeLen

public void setMaxCodeLen(int maxCodeLen)
Sets the maxCodeLen.

Parameters:
maxCodeLen - The maxCodeLen to set


Copyright © 2002-2003 Apache Software Foundation. All Rights Reserved.