Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.puremvc.java.core
Class View

    java.lang.Object
      org.puremvc.java.core.View

All Implemented Interfaces:
  IView

    public class View

extends java.lang.Object
implements IView

A Singleton `IView` implementation.

In PureMVC, the `View` class assumes these responsibilities:

- Maintain a cache of `IMediator` instances.
- Provide methods for registering, retrieving, and removing `IMediators`.
- Managing the observer lists for each `INotification` in the application.
- Providing a method for attaching `IObservers` to an `INotification`'s observer list.
- Providing a method for broadcasting an `INotification`.
- Notifying the `IObservers` of a given `INotification` when it broadcast.

See Also:
  `Mediator`, `Observer`, `Notification`

Constructor Summary
`protected` | `View()` Constructor.

Method Summary
`static View` | `getInstance()` View Singleton Factory method.
`boolean` | `hasMediator(java.lang.String mediatorName)` Check if a Mediator is registered or not
`protected void` | `initializeView()` Initialize the Singleton View instance.
`void` | `notifyObservers(INotification note)` Notify the `Observers` for a particular `Notification`.
`void` | `registerMediator(IMediator mediator)` Register an `Mediator` instance with the `View`.
`void` | `registerObserver(java.lang.String notificationName, IObserver observer)` Register an `Observer` to be notified of `INotifications` with a given name.
`IMediator` | `removeMediator(java.lang.String mediatorName)` Remove an `Mediator` from the `View`.
`void` | `removeObserver(java.lang.String notificationName, java.lang.Object notifyContext)` Remove the observer for a given notifyContext from an observer list for a given Notification name.
`IMediator` | `retrieveMediator(java.lang.String mediatorName)` Retrieve an `Mediator` from the `View`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### View

    protected View()

  Constructor.

  This `IView` implementation is a Singleton, so you should not call the constructor directly, but instead call the static Singleton Factory method `View.getInstance()`

  Throws:
    `java.lang.Error` - Error if Singleton instance has already been constructed

Method Detail

### initializeView

    protected void initializeView()

  Initialize the Singleton View instance.

  Called automatically by the constructor, this is your opportunity to initialize the Singleton instance in your subclass without overriding the constructor.

### getInstance

    public static View getInstance()

  View Singleton Factory method.

  Returns:
    The Singleton instance of `View`

### notifyObservers

    public void notifyObservers(INotification note)

  Notify the `Observers` for a particular `Notification`.

  All previously attached `Observers` for this `Notification`'s list are notified and are passed a reference to the `Notification` in the order in which they were registered.

  Specified by:
    `notifyObservers` in interface `IView`
  Parameters:
    `note` - the `Notification` to notify `Observers` of.

### removeObserver

    public void removeObserver(java.lang.String notificationName,
                               java.lang.Object notifyContext)

  Remove the observer for a given notifyContext from an observer list for a given Notification name.

  Parameters:
    `notificationName` - Which observer list to remove from
    `notifyContext` - Remove the observer with this object as its notifyContext

### registerMediator

    public void registerMediator(IMediator mediator)

  Register an `Mediator` instance with the `View`.

  Registers the `Mediator` so that it can be retrieved by name, and further interrogates the `Mediator` for its `Notification` interests.

  If the `Mediator` returns any `Notification` names to be notified about, an `Observer` is created encapsulating the `Mediator` instance's `handleNotification` method and registering it as an `Observer` for all `Notifications` the `Mediator` is interested in.

  Specified by:
    `registerMediator` in interface `IView`
  Parameters:
    `mediator` - the name to associate with this `IMediator` instance

### registerObserver

    public void registerObserver(java.lang.String notificationName,
                                 IObserver observer)

  Register an `Observer` to be notified of `INotifications` with a given name.

  Specified by:
    `registerObserver` in interface `IView`
  Parameters:
    `notificationName` - the name of the `Notifications` to notify this `Observer` of
    `observer` - the `Observer` to register

### removeMediator

    public IMediator removeMediator(java.lang.String mediatorName)

  Remove an `Mediator` from the `View`.

  Specified by:
    `removeMediator` in interface `IView`
  Parameters:
    `mediatorName` - name of the `Mediator` instance to be removed.

### retrieveMediator

    public IMediator retrieveMediator(java.lang.String mediatorName)

  Retrieve an `Mediator` from the `View`.

  Specified by:
    `retrieveMediator` in interface `IView`
  Parameters:
    `mediatorName` - the name of the `Mediator` instance to retrieve.
  Returns:
    the `Mediator` instance previously registered with the given `mediatorName`.

### hasMediator

    public boolean hasMediator(java.lang.String mediatorName)

  Check if a Mediator is registered or not

  Specified by:
    `hasMediator` in interface `IView`
  Parameters:
    `mediatorName` -
  Returns:
    whether a Mediator is registered with the given `mediatorName`.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD