Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.mdm.index.phonetic.impl
Class DoubleMetaphone

    java.lang.Object
      com.sun.mdm.index.phonetic.impl.DoubleMetaphone

All Implemented Interfaces:
  PhoneticEncoder

public class DoubleMetaphone
extends java.lang.Object
implements PhoneticEncoder

Encodes a string into a double metaphone value. This Implementation is based on the algorithm by Lawrence Philips.

- Original Article: http://www.cuj.com/documents/s=8038/cuj0006philips/
- Original Source Code: ftp://ftp.cuj.com/pub/2000/1806/philips.zip

Nested Class Summary
`class` | `DoubleMetaphone.DoubleMetaphoneResult` Inner class for storing results, since there is the optional alternate encoding.

Field Summary
`static java.lang.String` | `ENCODING_TYPE` informative String about the encoding type this encoder does
`protected int` | `maxCodeLen` Maximum length of an encoding, default is 4

Constructor Summary
`DoubleMetaphone()` Creates an instance of this DoubleMetaphone encoder

Method Summary
`protected char` | `charAt(java.lang.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(java.lang.String value, int start, int length, java.lang.String[] criteria)` Determines whether `value` contains any of the criteria starting at index `start` and matching up to length `length`
`java.lang.String` | `doubleMetaphone(java.lang.String value)` Encode a value with Double Metaphone
`java.lang.String` | `doubleMetaphone(java.lang.String value, boolean alternate)` Encode a value with Double Metaphone, optionally using the alternate encoding.
`java.lang.Object` | `encode(java.lang.Object obj)` Encode the value using DoubleMetaphone.
`java.lang.String` | `encode(java.lang.String value)` Encode the value using DoubleMetaphone.
`java.lang.String` | `encode(java.lang.String value, java.lang.String domain)` Encode the value using DoubleMetaphone.
`java.lang.String` | `getEncodingType()`
`int` | `getMaxCodeLen()` Returns the maxCodeLen.
`boolean` | `isDoubleMetaphoneEqual(java.lang.String value1, java.lang.String value2)` Check if the Double Metaphone values of two `String` values are equal
`boolean` | `isDoubleMetaphoneEqual(java.lang.String value1, java.lang.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`

Field Detail

### ENCODING_TYPE

    public static final java.lang.String ENCODING_TYPE

  informative String about the encoding type this encoder does

  See Also:
    Constant Field Values

### maxCodeLen

    protected int maxCodeLen

  Maximum length of an encoding, default is 4

Constructor Detail

### DoubleMetaphone

    public DoubleMetaphone()

  Creates an instance of this DoubleMetaphone encoder

Method Detail

### charAt

    protected char charAt(java.lang.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

### contains

    protected static boolean contains(java.lang.String value,
                                      int start,
                                      int length,
                                      java.lang.String[] criteria)

  Determines whether `value` contains any of the criteria starting at index `start` and matching up to length `length`

### doubleMetaphone

    public java.lang.String doubleMetaphone(java.lang.String value)

  Encode a value with Double Metaphone

  Parameters:
    `value` - String to encode
  Returns:
    an encoded string

### doubleMetaphone

    public java.lang.String doubleMetaphone(java.lang.String value,
                                            boolean alternate)

  Encode a value with Double Metaphone, optionally using the alternate encoding.

  Parameters:
    `value` - String to encode
    `alternate` - use alternate encode
  Returns:
    an encoded string

### encode

    public java.lang.Object encode(java.lang.Object obj)
                            throws PhoneticEncoderException

  Encode the value using DoubleMetaphone. It will only work if `obj` is a `String` (like `Metaphone`).

  Parameters:
    `obj` - Object to encode (should be of type String)
  Returns:
    An encoded Object (will be of type String)
  Throws:
    `PhoneticEncoderException`

### encode

    public java.lang.String encode(java.lang.String value)

  Encode the value using DoubleMetaphone.

  Specified by:
    `encode` in interface `PhoneticEncoder`
  Parameters:
    `value` - String to encode
  Returns:
    An encoded String
  Throws:
    `PhoneticEncoderException` - thrown if there is an exception during the encoding process.

### encode

    public java.lang.String encode(java.lang.String value,
                                   java.lang.String domain)

  Encode the value using DoubleMetaphone.

  Specified by:
    `encode` in interface `PhoneticEncoder`
  Parameters:
    `value` - String to encode
    `domain` - locality
  Returns:
    An encoded String
  Throws:
    `PhoneticEncoderException` - thrown if there is an exception during the encoding process.

### getEncodingType

    public java.lang.String getEncodingType()

  Description copied from interface: `PhoneticEncoder`
  Getter for the encoding type

  Specified by:
    `getEncodingType` in interface `PhoneticEncoder`
  Returns:
    the encoding type the Phonetic Encoder implements (such as NYSIIS or Soundex) This value is for information purposes and is not enforced to be of the same value as the 'encoding type' listed in the PhoneticEncodersConfiguration for the encoder class instance. As a result it should not be used for calls to the Phoneticizer.

### getMaxCodeLen

    public int getMaxCodeLen()

  Returns the maxCodeLen.

  Returns:
    int

### isDoubleMetaphoneEqual

    public boolean isDoubleMetaphoneEqual(java.lang.String value1,
                                          java.lang.String value2)

  Check if the Double Metaphone values of two `String` values are equal

### isDoubleMetaphoneEqual

    public boolean isDoubleMetaphoneEqual(java.lang.String value1,
                                          java.lang.String value2,
                                          boolean alternate)

  Check if the Double Metaphone values of two `String` values are equal, optionally using the alternate value

### setMaxCodeLen

    public void setMaxCodeLen(int maxCodeLen)

  Sets the maxCodeLen.

  Parameters:
    `maxCodeLen` - The maxCodeLen to set

Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Sun Microsystems, Inc.