站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 4.1.0

WeakListener (NetBeans APIs) - NetBeans API Javadoc 4.1.0


org.openide.util
Class WeakListener

java.lang.Object
  extended byorg.openide.util.WeakListener
All Implemented Interfaces:
EventListener
Direct Known Subclasses:
WeakListener.Change, WeakListener.Document, WeakListener.FileChange, WeakListener.FileStatus, WeakListener.Focus, WeakListener.PropertyChange, WeakListener.Repository, WeakListener.VetoableChange

Deprecated. Use WeakListeners class.

public abstract class WeakListener
extends Object
implements EventListener


Nested Class Summary
static class WeakListener.Change
          Deprecated. use appropriate method instead
static class WeakListener.Document
          Deprecated. use appropriate method instead
static class WeakListener.FileChange
          Deprecated. use appropriate method instead
static class WeakListener.FileStatus
          Deprecated. use appropriate method instead
static class WeakListener.Focus
          Deprecated. use appropriate method instead
static class WeakListener.Node
          Deprecated. use appropriate method instead
static class WeakListener.PropertyChange
          Deprecated. use appropriate method instead
static class WeakListener.Repository
          Deprecated. use appropriate method instead
static class WeakListener.VetoableChange
          Deprecated. use appropriate method instead
 
Constructor Summary
protected WeakListener(Class listenerClass, EventListener l)
          Deprecated.  
 
Method Summary
static ChangeListener change(ChangeListener l, Object source)
          Deprecated. Use WeakListeners.change(javax.swing.event.ChangeListener, java.lang.Object)
static EventListener create(Class lType, EventListener l, Object source)
          Deprecated. Use WeakListeners.create(java.lang.Class, java.util.EventListener, java.lang.Object)
static DocumentListener document(DocumentListener l, Object source)
          Deprecated. Use WeakListeners.document(javax.swing.event.DocumentListener, java.lang.Object)
static FileChangeListener fileChange(FileChangeListener l, Object source)
          Deprecated. Use FileUtil.weakFileChangeListener(org.openide.filesystems.FileChangeListener, java.lang.Object) or WeakListeners.create(java.lang.Class, java.util.EventListener, java.lang.Object)
static FileStatusListener fileStatus(FileStatusListener l, Object source)
          Deprecated. Use FileUtil.weakFileStatusListener(org.openide.filesystems.FileStatusListener, java.lang.Object) or WeakListeners.create(java.lang.Class, java.util.EventListener, java.lang.Object)
static FocusListener focus(FocusListener l, Object source)
          Deprecated. Use WeakListeners.create(java.lang.Class, java.util.EventListener, java.lang.Object)
protected  EventListener get(EventObject ev)
          Deprecated. Getter for the target listener.
static NodeListener node(NodeListener l, Object source)
          Deprecated. Use NodeOp.weakNodeListener(org.openide.nodes.NodeListener, java.lang.Object) or WeakListeners.create(java.lang.Class, java.util.EventListener, java.lang.Object)
static PropertyChangeListener propertyChange(PropertyChangeListener l, Object source)
          Deprecated. Use WeakListeners.propertyChange(java.beans.PropertyChangeListener, java.lang.Object)
protected abstract  String removeMethodName()
          Deprecated. Method name to use for removing the listener.
static RepositoryListener repository(RepositoryListener l, Object source)
          Deprecated. Creates a weak implementation of RepositoryListener.
protected  void setSource(Object source)
          Deprecated. Setter for the source field.
 String toString()
          Deprecated.  
static VetoableChangeListener vetoableChange(VetoableChangeListener l, Object source)
          Deprecated. Use WeakListeners.vetoableChange(java.beans.VetoableChangeListener, java.lang.Object)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WeakListener

protected WeakListener(Class listenerClass,
                       EventListener l)
Deprecated. 
Parameters:
listenerClass - class/interface of the listener
l - listener to delegate to, l must be an instance of listenerClass
Method Detail

setSource

protected final void setSource(Object source)
Deprecated. 
Setter for the source field. If a WeakReference to an underlying listener is cleared and enqueued, that is, the original listener is garbage collected, then the source field is used for deregistration of this WeakListener, thus making it eligible for garbage collection if no more references exist. This method is particularly useful in cases where the underlying listener was garbage collected and the event source, on which this listener is listening on, is quiet, i.e. does not fire any events for long periods. In this case, this listener is not removed from the event source until an event is fired. If the source field is set however, org.openide.util.WeakListeners that lost their underlying listeners are removed as soon as the ReferenceQueue notifies the WeakListener.

Parameters:
source - is any Object or null, though only setting an object that has an appropriate remove*listenerClass*Listener method and on which this listener is listening on, is useful.

removeMethodName

protected abstract String removeMethodName()
Deprecated. 
Method name to use for removing the listener.

Returns:
name of method of the source object that should be used to remove the listener from listening on source of events

get

protected final EventListener get(EventObject ev)
Deprecated. 
Getter for the target listener.

Parameters:
ev - the event the we want to distribute
Returns:
null if there is no listener because it has been finalized

toString

public String toString()
Deprecated. 

node

public static NodeListener node(NodeListener l,
                                Object source)
Deprecated. Use NodeOp.weakNodeListener(org.openide.nodes.NodeListener, java.lang.Object) or WeakListeners.create(java.lang.Class, java.util.EventListener, java.lang.Object)

Creates a weak implementation of NodeListener.

Parameters:
l - the listener to delegate to
source - the source that the listener should detach from when listener l is freed, can be null
Returns:
a NodeListener delegating to l.

propertyChange

public static PropertyChangeListener propertyChange(PropertyChangeListener l,
                                                    Object source)
Deprecated. Use WeakListeners.propertyChange(java.beans.PropertyChangeListener, java.lang.Object)

Creates a weak implementation of PropertyChangeListener.

Parameters:
l - the listener to delegate to
source - the source that the listener should detach from when listener l is freed, can be null
Returns:
a PropertyChangeListener delegating to l.

vetoableChange

public static VetoableChangeListener vetoableChange(VetoableChangeListener l,
                                                    Object source)
Deprecated. Use WeakListeners.vetoableChange(java.beans.VetoableChangeListener, java.lang.Object)

Creates a weak implementation of VetoableChangeListener.

Parameters:
l - the listener to delegate to
source - the source that the listener should detach from when listener l is freed, can be null
Returns:
a VetoableChangeListener delegating to l.

fileChange

public static FileChangeListener fileChange(FileChangeListener l,
                                            Object source)
Deprecated. Use FileUtil.weakFileChangeListener(org.openide.filesystems.FileChangeListener, java.lang.Object) or WeakListeners.create(java.lang.Class, java.util.EventListener, java.lang.Object)

Creates a weak implementation of FileChangeListener.

Parameters:
l - the listener to delegate to
source - the source that the listener should detach from when listener l is freed, can be null
Returns:
a FileChangeListener delegating to l.

fileStatus

public static FileStatusListener fileStatus(FileStatusListener l,
                                            Object source)
Deprecated. Use FileUtil.weakFileStatusListener(org.openide.filesystems.FileStatusListener, java.lang.Object) or WeakListeners.create(java.lang.Class, java.util.EventListener, java.lang.Object)

Creates a weak implementation of FileStatusListener.

Parameters:
l - the listener to delegate to
source - the source that the listener should detach from when listener l is freed, can be null
Returns:
a FileStatusListener delegating to l.

repository

public static RepositoryListener repository(RepositoryListener l,
                                            Object source)
Deprecated. 
Creates a weak implementation of RepositoryListener.

Parameters:
l - the listener to delegate to
source - the source that the listener should detach from when listener l is freed, can be null
Returns:
a RepositoryListener delegating to l.

document

public static DocumentListener document(DocumentListener l,
                                        Object source)
Deprecated. Use WeakListeners.document(javax.swing.event.DocumentListener, java.lang.Object)

Creates a weak implementation of DocumentListener.

Parameters:
l - the listener to delegate to
source - the source that the listener should detach from when listener l is freed, can be null
Returns:
a DocumentListener delegating to l.

change

public static ChangeListener change(ChangeListener l,
                                    Object source)
Deprecated. Use WeakListeners.change(javax.swing.event.ChangeListener, java.lang.Object)

Creates a weak implementation of ChangeListener.

Parameters:
l - the listener to delegate to
source - the source that the listener should detach from when listener l is freed, can be null
Returns:
a ChangeListener delegating to l.

focus

public static FocusListener focus(FocusListener l,
                                  Object source)
Deprecated. Use WeakListeners.create(java.lang.Class, java.util.EventListener, java.lang.Object)

Creates a weak implementation of FocusListener.

Parameters:
l - the listener to delegate to
source - the source that the listener should detach from when listener l is freed, can be null
Returns:
a FocusListener delegating to l.

create

public static EventListener create(Class lType,
                                   EventListener l,
                                   Object source)
Deprecated. Use WeakListeners.create(java.lang.Class, java.util.EventListener, java.lang.Object)

A generic WeakListener factory. Creates a weak implementation of a listener of type lType.

Parameters:
lType - the type of listener to create. It can be any interface, but only interfaces are allowed.
l - the listener to delegate to, l must be an instance of lType
source - the source that the listener should detach from when listener l is freed, can be null
Returns:
an instance of lType delegating all the interface calls to l.


Built on May 4 2005.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.