org.apache.commons.codec.language
Class Soundex

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

public class Soundex
extends java.lang.Object
implements StringEncoder

Encodes a string into a refined soundex value. A refined soundex code is optimized for spell checking word. "Soundex" method originally developed by Margaret Odell and Robert Russell http://www.bluepoof.com/Soundex/info2.html

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

Field Summary
private  int maxLength
           
private  char[] soundexMapping
           
static Soundex US_ENGLISH
           
static char[] US_ENGLISH_MAPPING
           
 
Constructor Summary
Soundex()
           
Soundex(char[] mapping)
           
 
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.
private  char getMappingCode(char c)
          Used internally by the SoundEx algorithm.
 int getMaxLength()
          Returns the maxLength.
 void setMaxLength(int maxLength)
          Sets the maxLength.
 java.lang.String soundex(java.lang.String str)
          Get the SoundEx value of a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

US_ENGLISH_MAPPING

public static final char[] US_ENGLISH_MAPPING

US_ENGLISH

public static final Soundex US_ENGLISH

soundexMapping

private char[] soundexMapping

maxLength

private int maxLength
Constructor Detail

Soundex

public Soundex()

Soundex

public Soundex(char[] mapping)
Method Detail

soundex

public java.lang.String soundex(java.lang.String str)
Get the SoundEx value of a string. This implementation is taken from the code-snippers on http://www.sourceforge.net/


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.

getMappingCode

private char getMappingCode(char c)
Used internally by the SoundEx algorithm.


getMaxLength

public int getMaxLength()
Returns the maxLength. Standard Soundex

Returns:
int

setMaxLength

public void setMaxLength(int maxLength)
Sets the maxLength.

Parameters:
maxLength - The maxLength to set


Copyright (c) 2003 - Apache Software Foundation