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