⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fingerprintconfig.java

📁 dump3 morpheus 0.2.9 src
💻 JAVA
字号:
/**
 * DuMP3 version morpheus_0.2.9 - a duplicate/similar file finder in Java<BR>
 * Copyright 2005 Alexander Gr&auml;sser<BR>
 * All Rights Reserved, http://dump3.sourceforge.net/<BR>
 * <BR>
 * This file is part of DuMP3.<BR>
 * <BR>
 * DuMP3 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later version.<BR>
 * <BR>
 * DuMP3 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.<BR>
 * <BR>
 * You should have received a copy of the GNU General Public License along with DuMP3; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
 * Fifth Floor, Boston, MA 02110-1301 USA
 */
package net.za.grasser.duplicate.fingerprint.configure;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import java.beans.VetoableChangeSupport;
import java.io.Serializable;

/**
 * This class is the superclass for all Fingerprint Configuration classes. It is a JavaBean.
 * 
 * @author <a href="http://sourceforge.net/sendmessage.php?touser=733840">pyropunk at sourceforge dot net</a>
 * @version $Revision: 1.5 $
 */
public abstract class FingerprintConfig implements Serializable, VetoableChangeListener {
  /**
   * <code>SIM_THRESH</code> FingerprintConfig -
   */
  public static final String SIM_THRESH = "similarityThreshhold";
  /**
   * <code>serialVersionUID</code> FingerprintConfig -
   */
  private static final long serialVersionUID = -1482367141553092147L;
  /**
   * <code>similarityThreshhold</code> FingerprintConfig - threshhold above which files are considered equal
   */
  protected float similarityThreshhold = 100.0f;
  /**
   * <code>changes</code> FingerprintConfig.java - change control listeners
   */
  protected final PropertyChangeSupport changes = new PropertyChangeSupport(this);
  /**
   * <code>vetos</code> FingerprintConfig.java - veto change listeners
   */
  protected final VetoableChangeSupport vetos = new VetoableChangeSupport(this);

  /**
   * Constructor
   */
  protected FingerprintConfig() {
    addVetoableChangeListener(this);
  }

  /**
   * This method gets the similarity theshhold that is configured for this Fingerprint algorithm.
   * 
   * @return float
   */
  public float getSimilarityThreshhold() {
    return similarityThreshhold;
  }

  /**
   * This method gives a proper name to the fingerprint algorithm.
   * 
   * @return String
   */
  public abstract String getFingerprintName();

  /**
   * This method gives a description for the fingerprint algorithm.
   * 
   * @return String
   */
  public abstract String getFingerprintDescription();

  /**
   * Sets the similarityThreshhold to the value of pSimilarityThreshhold.
   * 
   * @param pSimilarityThreshhold float - The new value.
   * @throws PropertyVetoException
   */
  public void setSimilarityThreshhold(final float pSimilarityThreshhold) throws PropertyVetoException {
    final float oldSimilarityThreshhold = similarityThreshhold;
    // First tell the vetoers about the change.
    // If anyone objects, we don't catch the exception
    // but just let if pass on to our caller.
    vetos.fireVetoableChange(SIM_THRESH, new Float(oldSimilarityThreshhold), new Float(pSimilarityThreshhold));
    // No-one vetoed, so go ahead and make the change.
    similarityThreshhold = pSimilarityThreshhold;
    changes.firePropertyChange(SIM_THRESH, new Float(oldSimilarityThreshhold), new Float(pSimilarityThreshhold));
  }

  /**
   * This method registers a <code>PropertyChangeListener</code>.
   * 
   * @param l
   */
  public void addPropertyChangeListener(final PropertyChangeListener l) {
    changes.addPropertyChangeListener(l);
  }

  /**
   * This method removes a registered <code>PropertyChangeListener</code>.
   * 
   * @param l
   */
  public void removePropertyChangeListener(final PropertyChangeListener l) {
    changes.removePropertyChangeListener(l);
  }

  /**
   * This method registers a <code>VetoableChangeListener</code>.
   * 
   * @param l
   */
  public void addVetoableChangeListener(final VetoableChangeListener l) {
    vetos.addVetoableChangeListener(l);
  }

  /**
   * This method removes a registered <code>VetoableChangeListener</code>.
   * 
   * @param l
   */
  public void removeVetoableChangeListener(final VetoableChangeListener l) {
    vetos.removeVetoableChangeListener(l);
  }

  /**
   * @see java.beans.VetoableChangeListener#vetoableChange(java.beans.PropertyChangeEvent)
   */
  public void vetoableChange(final PropertyChangeEvent evt) throws PropertyVetoException {
    if (evt.getPropertyName().equals(SIM_THRESH)) {
      if (((Float)evt.getNewValue()).floatValue() <= 0.0f) {
        throw new PropertyVetoException(evt.getPropertyName() + " must be bigger than 0.0%.", evt);
      }
      if (((Float)evt.getNewValue()).floatValue() > 100.0) {
        throw new PropertyVetoException(evt.getPropertyName() + " must be smaller or equal to 100.0%.", evt);
      }
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -