org.opends.server.schema
Class DoubleMetaphoneApproximateMatchingRule

java.lang.Object
  extended by org.opends.server.api.MatchingRule<ApproximateMatchingRuleCfg>
      extended by org.opends.server.api.ApproximateMatchingRule
          extended by org.opends.server.schema.DoubleMetaphoneApproximateMatchingRule

public class DoubleMetaphoneApproximateMatchingRule
extends ApproximateMatchingRule

This class defines an approximate matching rule based on the Double Metaphone algorithm. The Metaphone and Double Metaphone algorithms were originally devised by Lawrence Philips (published in the December 1990 issue of Computer Language and the June 2000 issue of C/C++ Users Journal, respectively), and this version of the algorithm is based on a version modified by Kevin Atkinson to include bugfixes and additional functionality (source is available here and additional Metaphone and Double Metaphone information is available at http://aspell.net/metaphone/). This implementation is largely the same as the one provided by Kevin Atkinson, but it has been re-written for better readability, for more efficiency, to get rid of checks for conditions that can't possibly happen, and to get rid of redundant checks that aren't needed. It has also been updated to always only generate a single value rather than one or possibly two values.


Constructor Summary
DoubleMetaphoneApproximateMatchingRule()
          Creates a new instance of this double metaphone approximate matching rule.
 
Method Summary
 boolean approximatelyMatch(ByteString value1, ByteString value2)
          Indicates whether the two provided normalized values are approximately equal to each other.
 java.lang.String getDescription()
          Retrieves the description for this matching rule.
 java.lang.String getName()
          Retrieves the common name for this matching rule.
 java.lang.String getOID()
          Retrieves the OID for this matching rule.
 java.lang.String getSyntaxOID()
          Retrieves the OID of the syntax with which this matching rule is associated.
 void initializeMatchingRule(ApproximateMatchingRuleCfg configuration)
          Initializes this matching rule based on the information in the provided configuration entry.
 ByteString normalizeValue(ByteString value)
          Retrieves the normalized form of the provided value, which is best suited for efficiently performing matching operations on that value.
 
Methods inherited from class org.opends.server.api.ApproximateMatchingRule
valuesMatch
 
Methods inherited from class org.opends.server.api.MatchingRule
equals, finalizeMatchingRule, getNameOrOID, hashCode, isConfigurationAcceptable, isObsolete, toString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DoubleMetaphoneApproximateMatchingRule

public DoubleMetaphoneApproximateMatchingRule()
Creates a new instance of this double metaphone approximate matching rule.

Method Detail

initializeMatchingRule

public void initializeMatchingRule(ApproximateMatchingRuleCfg configuration)
                            throws ConfigException,
                                   InitializationException
Initializes this matching rule based on the information in the provided configuration entry.

Specified by:
initializeMatchingRule in class MatchingRule<ApproximateMatchingRuleCfg>
Parameters:
configuration - The configuration to use to intialize this matching rule.
Throws:
ConfigException - If an unrecoverable problem arises in the process of performing the initialization.
InitializationException - If a problem that is not configuration-related occurs during initialization.

getName

public java.lang.String getName()
Retrieves the common name for this matching rule.

Specified by:
getName in class MatchingRule<ApproximateMatchingRuleCfg>
Returns:
The common name for this matching rule, or null if it does not have a name.

getOID

public java.lang.String getOID()
Retrieves the OID for this matching rule.

Specified by:
getOID in class MatchingRule<ApproximateMatchingRuleCfg>
Returns:
The OID for this matching rule.

getDescription

public java.lang.String getDescription()
Retrieves the description for this matching rule.

Specified by:
getDescription in class MatchingRule<ApproximateMatchingRuleCfg>
Returns:
The description for this matching rule, or null if there is none.

getSyntaxOID

public java.lang.String getSyntaxOID()
Retrieves the OID of the syntax with which this matching rule is associated.

Specified by:
getSyntaxOID in class MatchingRule<ApproximateMatchingRuleCfg>
Returns:
The OID of the syntax with which this matching rule is associated.

normalizeValue

public ByteString normalizeValue(ByteString value)
                          throws DirectoryException
Retrieves the normalized form of the provided value, which is best suited for efficiently performing matching operations on that value.

Specified by:
normalizeValue in class MatchingRule<ApproximateMatchingRuleCfg>
Parameters:
value - The value to be normalized.
Returns:
The normalized version of the provided value.
Throws:
DirectoryException - If the provided value is invalid according to the associated attribute syntax.

approximatelyMatch

public boolean approximatelyMatch(ByteString value1,
                                  ByteString value2)
Indicates whether the two provided normalized values are approximately equal to each other.

Specified by:
approximatelyMatch in class ApproximateMatchingRule
Parameters:
value1 - The normalized form of the first value to compare.
value2 - The normalized form of the second value to compare.
Returns:
true if the provided values are approximately equal, or false if not.