|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.codec.language.DoubleMetaphone
public class DoubleMetaphone
Encodes a string into a double metaphone value. This Implementation is based on the algorithm by Lawrence Philips.
This class is conditionally thread-safe. The instance field maxCodeLen
is mutable
setMaxCodeLen(int)
but is not volatile, and accesses are not synchronized. If an instance of the class is
shared between threads, the caller needs to ensure that suitable synchronization is used to ensure safe publication
of the value between threads, and must not invoke setMaxCodeLen(int)
after initial setup.
Nested Class Summary | |
---|---|
class |
DoubleMetaphone.DoubleMetaphoneResult
Inner class for storing results, since there is the optional alternate encoding. |
Constructor Summary | |
---|---|
DoubleMetaphone()
Creates an instance of this DoubleMetaphone encoder |
Method Summary | |
---|---|
protected char |
charAt(String value,
int index)
Gets the character at index index if available, otherwise
it returns Character.MIN_VALUE so that there is some sort
of a default. |
protected static boolean |
contains(String value,
int start,
int length,
String[] criteria)
Determines whether value contains any of the criteria starting at index start and
matching up to length length . |
String |
doubleMetaphone(String value)
Encode a value with Double Metaphone. |
String |
doubleMetaphone(String value,
boolean alternate)
Encode a value with Double Metaphone, optionally using the alternate encoding. |
Object |
encode(Object obj)
Encode the value using DoubleMetaphone. |
String |
encode(String value)
Encode the value using DoubleMetaphone. |
int |
getMaxCodeLen()
Returns the maxCodeLen. |
boolean |
isDoubleMetaphoneEqual(String value1,
String value2)
Check if the Double Metaphone values of two String values
are equal. |
boolean |
isDoubleMetaphoneEqual(String value1,
String value2,
boolean alternate)
Check if the Double Metaphone values of two String values
are equal, optionally using the alternate value. |
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 |
---|
public DoubleMetaphone()
Method Detail |
---|
public String doubleMetaphone(String value)
value
- String to encode
public String doubleMetaphone(String value, boolean alternate)
value
- String to encodealternate
- use alternate encode
public Object encode(Object obj) throws EncoderException
obj
is a String
(like Metaphone
).
encode
in interface Encoder
obj
- Object to encode (should be of type String)
EncoderException
- encode parameter is not of type Stringpublic String encode(String value)
encode
in interface StringEncoder
value
- String to encode
public boolean isDoubleMetaphoneEqual(String value1, String value2)
String
values
are equal.
value1
- The left-hand side of the encoded String.equals(Object)
.value2
- The right-hand side of the encoded String.equals(Object)
.
true
if the encoded String
s are equal;
false
otherwise.isDoubleMetaphoneEqual(String,String,boolean)
public boolean isDoubleMetaphoneEqual(String value1, String value2, boolean alternate)
String
values
are equal, optionally using the alternate value.
value1
- The left-hand side of the encoded String.equals(Object)
.value2
- The right-hand side of the encoded String.equals(Object)
.alternate
- use the alternate value if true
.
true
if the encoded String
s are equal;
false
otherwise.public int getMaxCodeLen()
public void setMaxCodeLen(int maxCodeLen)
maxCodeLen
- The maxCodeLen to setprotected char charAt(String value, int index)
index
if available, otherwise
it returns Character.MIN_VALUE
so that there is some sort
of a default.
protected static boolean contains(String value, int start, int length, String[] criteria)
value
contains any of the criteria starting at index start
and
matching up to length length
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |