danger.util
Class ActiveObject.WeakDelegateList

java.lang.Object
  extended by danger.util.SimpleWeakList
      extended by danger.util.ActiveObject.WeakDelegateList
All Implemented Interfaces:
ActiveObject.Delegate
Enclosing interface:
ActiveObject


public static class ActiveObject.WeakDelegateList
extends SimpleWeakList
implements ActiveObject.Delegate

List of delegates which are held onto weakly. Instances of this class are used to hold multiple delegates that have been added to a single list instance. onUpdate(danger.util.ActiveObject) calls that same method with the same argument on each of the delegates in the list. Note that the SimpleWeakList.add(java.lang.Object) and SimpleWeakList.remove(java.lang.Object) methods are simply the inherited Object-accepting ones, but the guts of this class assume that the only things ever added are appropriate delegates.


Field Summary
protected  ActiveObject mUpdated
          used while iterating
 
Constructor Summary
ActiveObject.WeakDelegateList()
          Construct an instance with an initial capacity of 4.
ActiveObject.WeakDelegateList(int initialCapacity)
          Construct an instance.
 
Method Summary
protected  void accept(Object obj)
          Method called by SimpleWeakList.accept(Object,Object) in response to a call to SimpleWeakList.forEachAccept() or SimpleWeakList.forEachAccept(Object).
 ActiveObject.Delegate getDelegate(int n)
          Get the n delegate, which may turn out to be a reaped reference.
 void onUpdate(ActiveObject obj)
          Call onUpdate(danger.util.ActiveObject) on all instances in this list.
 
Methods inherited from class danger.util.SimpleWeakList
accept, add, contains, forEachAccept, forEachAccept, get, matchesTarget, remove, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mUpdated

protected ActiveObject mUpdated
used while iterating

Constructor Detail

ActiveObject.WeakDelegateList

public ActiveObject.WeakDelegateList(int initialCapacity)
Construct an instance.

Parameters:
initialCapacity - initial capacity of the list; it will expand as needed

ActiveObject.WeakDelegateList

public ActiveObject.WeakDelegateList()
Construct an instance with an initial capacity of 4.

Method Detail

getDelegate

public final ActiveObject.Delegate getDelegate(int n)
Get the n delegate, which may turn out to be a reaped reference.

Parameters:
n - which delegate to get
Returns:
null-ok; the nth delegate

onUpdate

public void onUpdate(ActiveObject obj)
Call onUpdate(danger.util.ActiveObject) on all instances in this list.

Specified by:
onUpdate in interface ActiveObject.Delegate
Parameters:
obj - non-null; the instance which was updated

accept

protected void accept(Object obj)
Description copied from class: SimpleWeakList
Method called by SimpleWeakList.accept(Object,Object) in response to a call to SimpleWeakList.forEachAccept() or SimpleWeakList.forEachAccept(Object). This implementation does nothing, but subclasses may override it to do something interesting, if need be.

You should override either this method, or SimpleWeakList.accept(Object,Object), but not both.

Overrides:
accept in class SimpleWeakList
Parameters:
obj - non-null; a live object from the list