|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.codec.language.Metaphone
Encodes a string into a metaphone value.
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.
Field Summary | |
private String |
frontv
Variable used in Metaphone algorithm |
private int |
maxCodeLen
The max code length for metaphone is 4 |
private String |
varson
Variable used in Metaphone algorithm |
private String |
vowels
Five values in the English language |
Constructor Summary | |
Metaphone()
Creates an instance of the Metaphone encoder |
Method Summary | |
Object |
encode(Object pObject)
Encodes an Object using the metaphone algorithm. |
String |
encode(String pString)
Encodes a String using the Metaphone algorithm. |
int |
getMaxCodeLen()
Returns the maxCodeLen. |
private boolean |
isLastChar(int wdsz,
int n)
|
boolean |
isMetaphoneEqual(String str1,
String str2)
Tests is the metaphones of two strings are identical. |
private boolean |
isNextChar(StringBuffer string,
int index,
char c)
|
private boolean |
isPreviousChar(StringBuffer string,
int index,
char c)
|
private boolean |
isVowel(StringBuffer string,
int index)
|
String |
metaphone(String txt)
Find the metaphone value of a String. |
private boolean |
regionMatch(StringBuffer string,
int index,
String test)
|
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 |
Field Detail |
private String vowels
private String frontv
private String varson
private int maxCodeLen
Constructor Detail |
public Metaphone()
Method Detail |
public String metaphone(String txt)
txt
- String to find the metaphone code for
private boolean isVowel(StringBuffer string, int index)
private boolean isPreviousChar(StringBuffer string, int index, char c)
private boolean isNextChar(StringBuffer string, int index, char c)
private boolean regionMatch(StringBuffer string, int index, String test)
private boolean isLastChar(int wdsz, int n)
public Object encode(Object pObject) throws EncoderException
encode
in interface Encoder
pObject
- Object to encode
EncoderException
- if the parameter supplied is not
of type java.lang.Stringpublic String encode(String pString)
encode
in interface StringEncoder
pString
- String object to encode
public boolean isMetaphoneEqual(String str1, String str2)
str1
- First of two strings to comparestr2
- Second of two strings to compare
public int getMaxCodeLen()
public void setMaxCodeLen(int maxCodeLen)
maxCodeLen
- The maxCodeLen to set
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |