com.pietschy.command.delegate
Class AbstractDelegateMediator

java.lang.Object
  extended by com.pietschy.command.delegate.AbstractDelegateMediator
All Implemented Interfaces:
DelegateMediator
Direct Known Subclasses:
DefaultDelegateMediator, FocusTrackingDelegateMediator

public abstract class AbstractDelegateMediator
extends java.lang.Object
implements DelegateMediator

Provides a base implementation of DelegateMediator that manages DelegateMediatorListeners and provides convenience methods for finding an ActionCommandExecutor from a list of DelegateProviders.


Field Summary
static DelegateProvider[] EMPTY_PROVIDER_ARRAY
          Empty container array.
 
Constructor Summary
AbstractDelegateMediator()
           
 
Method Summary
 void addDelegateMediatorListener(DelegateMediatorListener listener)
          Adds the specified listner.
protected  void fireDelegatesChanged()
          Notifies all listeners that the current list of delegates has changed.
protected  ActionCommandExecutor getExecutor(java.lang.String id, DelegateProvider[] delegateContainers)
          Convenience method that traverses the specified container list for the first executor with the specified id.
protected  DelegateProvider[] nullSafeArray(DelegateProvider container)
          Returns the specified array or and empty array if the container was null.
protected  DelegateProvider[] nullSafeArray(DelegateProvider[] containers)
          Returns the specified array or and empty array if containers was null.
 void removeDelegateMediatorListener(DelegateMediatorListener listener)
          Removes the specified listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.pietschy.command.delegate.DelegateMediator
getExecutor
 

Field Detail

EMPTY_PROVIDER_ARRAY

public static final DelegateProvider[] EMPTY_PROVIDER_ARRAY
Empty container array.

Constructor Detail

AbstractDelegateMediator

public AbstractDelegateMediator()
Method Detail

addDelegateMediatorListener

public void addDelegateMediatorListener(DelegateMediatorListener listener)
Adds the specified listner.

Specified by:
addDelegateMediatorListener in interface DelegateMediator
Parameters:
listener - the listener to add.

removeDelegateMediatorListener

public void removeDelegateMediatorListener(DelegateMediatorListener listener)
Removes the specified listener.

Specified by:
removeDelegateMediatorListener in interface DelegateMediator
Parameters:
listener - the listener to remove.

getExecutor

protected ActionCommandExecutor getExecutor(java.lang.String id,
                                            DelegateProvider[] delegateContainers)
Convenience method that traverses the specified container list for the first executor with the specified id.

Parameters:
id - the executor id.
delegateContainers - the containers to search.
Returns:
the executor with the specified id, or null if none were found.

nullSafeArray

protected DelegateProvider[] nullSafeArray(DelegateProvider[] containers)
Returns the specified array or and empty array if containers was null.

Parameters:
containers - the DelegateProviders to use. May be null.
Returns:
the specified array or and empty array if containers was null.

nullSafeArray

protected DelegateProvider[] nullSafeArray(DelegateProvider container)
Returns the specified array or and empty array if the container was null.

Parameters:
container - the DelegateProvider to use.
Returns:
the specified array or and empty array if the container was null.

fireDelegatesChanged

protected void fireDelegatesChanged()
Notifies all listeners that the current list of delegates has changed.



Copyright © 2006 - 2007 Andrew Pietsch