Metric.java :  » Search » fuzzy-search-tools » ru » fuzzysearch » Java Open Source

Java Open Source » Search » fuzzy search tools 
fuzzy search tools » ru » fuzzysearch » Metric.java
package ru.fuzzysearch;

/**
 * 
 */
public abstract class Metric {

  /**
   *      .
   * 
   * @param first
   *             
   * @param second
   *             
   * @return   0    
   */
  public int getDistance(CharSequence first, CharSequence second) {
    return getDistance(first, second, -1);
  }

  /**
   *      .
   * 
   * @param first
   *             
   * @param second
   *             
   * @param max
   *             
   * @return   0  max .    max,    
   *            max.
   */
  public abstract int getDistance(CharSequence first, CharSequence second, int max);

  /**
   *       , ..     
   *   .
   * 
   * @param prefix
   *            
   * @param string
   *            
   * @return   0    .
   */
  public int getPrefixDistance(CharSequence string, CharSequence prefix) {
    return getPrefixDistance(string, prefix, -1);
  }

  /**
   *       , ..     
   *   .
   * 
   * @param prefix
   *            
   * @param string
   *            
   * @param max
   *             
   * @return   0  max .    max,    
   *            max.
   */
  public abstract int getPrefixDistance(CharSequence string, CharSequence prefix, int max);

  /**
   *      prefix    ,  .
   * 
   * @see #getDistance(CharSequence, CharSequence)
   * @see #getPrefixDistance(CharSequence, CharSequence)
   */
  public int getDistance(CharSequence first, CharSequence second, boolean prefix) {
    return prefix ? getPrefixDistance(first, second) : getDistance(first, second);
  }

  /**
   *      prefix    ,  .
   * 
   * @see #getDistance(CharSequence, CharSequence, int)
   * @see #getPrefixDistance(CharSequence, CharSequence, int)
   */
  public int getDistance(CharSequence first, CharSequence second, int max, boolean prefix) {
    return prefix ? getPrefixDistance(first, second, max) : getDistance(first, second, max);
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.