当前位置: 首页>>代码示例>>Java>>正文


Java VetoableChangeListener.equals方法代码示例

本文整理汇总了Java中java.beans.VetoableChangeListener.equals方法的典型用法代码示例。如果您正苦于以下问题:Java VetoableChangeListener.equals方法的具体用法?Java VetoableChangeListener.equals怎么用?Java VetoableChangeListener.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.beans.VetoableChangeListener的用法示例。


在下文中一共展示了VetoableChangeListener.equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addVetoableChangeListenerIfAbsent

import java.beans.VetoableChangeListener; //导入方法依赖的package包/类
/**
  * Add a PropertyChangeListener to the listener list if it is 
  * not already present.
  * The listener is registered for all properties.
  * The operation maintains Set semantics: If the listener is already 
  * registered, the operation has no effect.
  *
  * @param listener  The PropertyChangeListener to be added
  * @exception NullPointerException If listener is null
  */
 
 public synchronized void addVetoableChangeListenerIfAbsent(VetoableChangeListener listener) {

   if (listener == null) throw new NullPointerException();

   // Copy while checking if already present.
   int len = listeners.length; 
   VetoableChangeListener[] newArray = new VetoableChangeListener[len + 1];
   for (int i = 0; i < len; ++i) {
     newArray[i] = listeners[i];
     if (listener.equals(listeners[i]))
return; // already present -- throw away copy
   }
   newArray[len] = listener;
   listeners = newArray;
 }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:VetoableChangeMulticaster.java

示例2: removeVetoableChangeListener

import java.beans.VetoableChangeListener; //导入方法依赖的package包/类
/**
 * Remove an occurrence of a VetoableChangeListener from the listener list.
 * It removes at most one occurrence of the given listener.
 * If the listener was added multiple times it must be removed
 * mulitple times.
 * This removes a VetoableChangeListener that was registered
 * for all properties, and has no effect if registered for only
 * one or more specified properties.
 *
 * @param listener  The VetoableChangeListener to be removed
 */

public synchronized void removeVetoableChangeListener(VetoableChangeListener listener) {

  int newlen = listeners.length-1;
  if (newlen < 0 || listener == null) return;

  // Copy while searching for element to remove

  VetoableChangeListener[] newArray = new VetoableChangeListener[newlen];

  for (int i = 0; i < newlen; ++i) { 
    if (listener.equals(listeners[i])) {
      //  copy remaining and exit
      for (int k = i + 1; k <= newlen; ++k) newArray[k-1] = listeners[k];
      listeners = newArray;
      return;
    }
    else
      newArray[i] = listeners[i];
  }
  
  // special-case last cell
  if (listener.equals(listeners[newlen]))
    listeners = newArray;

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:38,代码来源:VetoableChangeMulticaster.java


注:本文中的java.beans.VetoableChangeListener.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。