org.puremvc.java.multicore.core.view
Class View

java.lang.Object
  extended by org.puremvc.java.multicore.core.view.View
All Implemented Interfaces:
IView

public class View
extends Object
implements IView

A Multiton IView implementation.

In PureMVC, the View class assumes these responsibilities:

See Also:
Mediator, Observer, Notification

Field Summary
protected static Map<String,View> instanceMap
           
protected  String multitonKey
          The Multiton Key for this Core.
 
Constructor Summary
protected View(String key)
          Constructor.
 
Method Summary
static View getInstance(String key)
          View Singleton Factory method.
 boolean hasMediator(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(String notificationName, IObserver observer)
          Register an Observer to be notified of INotifications with a given name.
 IMediator removeMediator(String mediatorName)
          Remove an Mediator from the View.
 void removeObserver(String notificationName, Object notifyContext)
          Remove the observer for a given notifyContext from an observer list for a given Notification name.
static void removeView(String key)
          Remove an IView instance
 IMediator retrieveMediator(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
 

Field Detail

multitonKey

protected String multitonKey
The Multiton Key for this Core.


instanceMap

protected static Map<String,View> instanceMap
Constructor Detail

View

protected View(String key)
Constructor.

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

Throws:
Error - Error if instance for this Multiton key 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(String key)
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(String notificationName,
                           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(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(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(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(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.

removeView

public static void removeView(String key)
Remove an IView instance

Parameters:
multitonKey - of IView instance to remove


Copyright © 2010. All Rights Reserved.