Class Mediator

java.lang.Object
org.puremvc.java.patterns.observer.Notifier
org.puremvc.java.patterns.mediator.Mediator
All Implemented Interfaces:
IMediator, INotifier

public class Mediator
extends Notifier
implements IMediator

A base IMediator implementation.

See Also:
View
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected java.lang.String mediatorName  
    static java.lang.String NAME
    The name of the Mediator.
    protected java.lang.Object viewComponent  

    Fields inherited from class org.puremvc.java.patterns.observer.Notifier

    facade
  • Constructor Summary

    Constructors 
    Constructor Description
    Mediator()
    Constructor.
    Mediator​(java.lang.String mediatorName)
    Constructor.
    Mediator​(java.lang.String mediatorName, java.lang.Object viewComponent)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    java.lang.String getMediatorName()
    Get the name of the Mediator.
    java.lang.Object getViewComponent()
    Get the Mediator's view component.
    void handleNotification​(INotification notification)
    Handle INotifications.
    java.lang.String[] listNotificationInterests()
    List the INotification names this Mediator is interested in being notified of.
    void onRegister()
    Called by the View when the Mediator is registered
    void onRemove()
    Called by the View when the Mediator is removed
    void setViewComponent​(java.lang.Object viewComponent)
    Set the IMediator's view component.

    Methods inherited from class org.puremvc.java.patterns.observer.Notifier

    sendNotification, sendNotification, sendNotification

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.puremvc.java.interfaces.INotifier

    sendNotification, sendNotification, sendNotification
  • Field Details

    • NAME

      public static final java.lang.String NAME

      The name of the Mediator.

      Typically, a Mediator will be written to serve one specific control or group controls and so, will not have a need to be dynamically named.

      See Also:
      Constant Field Values
    • mediatorName

      protected java.lang.String mediatorName
    • viewComponent

      protected java.lang.Object viewComponent
  • Constructor Details

    • Mediator

      public Mediator​(java.lang.String mediatorName, java.lang.Object viewComponent)

      Constructor.

      Parameters:
      mediatorName - mediator name
      viewComponent - view component
    • Mediator

      public Mediator​(java.lang.String mediatorName)

      Constructor.

      Parameters:
      mediatorName - mediator name
    • Mediator

      public Mediator()

      Constructor.

  • Method Details

    • listNotificationInterests

      public java.lang.String[] listNotificationInterests()

      List the INotification names this Mediator is interested in being notified of.

      Specified by:
      listNotificationInterests in interface IMediator
      Returns:
      Array the list of INotification names
    • handleNotification

      public void handleNotification​(INotification notification)

      Handle INotifications.

      Typically this will be handled in a switch statement, with one 'case' entry per INotification the Mediator is interested in.

      Specified by:
      handleNotification in interface IMediator
      Parameters:
      notification - the INotification to be handled
    • onRegister

      public void onRegister()

      Called by the View when the Mediator is registered

      Specified by:
      onRegister in interface IMediator
    • onRemove

      public void onRemove()

      Called by the View when the Mediator is removed

      Specified by:
      onRemove in interface IMediator
    • getMediatorName

      public java.lang.String getMediatorName()

      Get the name of the Mediator.

      Specified by:
      getMediatorName in interface IMediator
      Returns:
      the Mediator name
    • getViewComponent

      public java.lang.Object getViewComponent()

      Get the Mediator's view component.

      Additionally, an implicit getter will usually be defined in the subclass that casts the view object to a type, like this:

      public javax.swing.JComboBox getViewComponent() { return viewComponent; }
      Specified by:
      getViewComponent in interface IMediator
      Returns:
      the view component
    • setViewComponent

      public void setViewComponent​(java.lang.Object viewComponent)

      Set the IMediator's view component.

      Specified by:
      setViewComponent in interface IMediator
      Parameters:
      viewComponent - the view component