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.patterns.observer
Class Observer

    java.lang.Object
      org.puremvc.java.patterns.observer.Observer

All Implemented Interfaces:
  IObserver

    public class Observer

extends java.lang.Object
implements IObserver

A base `IObserver` implementation.

An `Observer` is an object that encapsulates information about an interested object with a method that should be called when a particular `INotification` is broadcast.

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

- Encapsulate the notification (callback) method of the interested object.
- Encapsulate the notification context (this) of the interested object.
- Provide methods for setting the notification method and context.
- Provide a method for notifying the interested object.

See Also:
  `View`, `Notification`

Constructor Summary
`Observer(IFunction notify, java.lang.Object context)` Constructor.

Method Summary
`boolean` | `compareNotifyContext(java.lang.Object object)` Compare an object to the notification context.
`java.lang.Object` | `getNotifyContext()` Get the notification context.
`IFunction` | `getNotifyMethod()` Get the notification method.
`void` | `notifyObserver(INotification notification)` Notify the interested object.
`void` | `setNotifyContext(java.lang.Object notifyContext)` Set the notification context.
`void` | `setNotifyMethod(IFunction notifyMethod)` Set the notification method.

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

Constructor Detail

### Observer

    public Observer(IFunction notify,
                    java.lang.Object context)

  Constructor.

  The notification method on the interested object should take one parameter of type `INotification`

  Parameters:
    `notify` - the notification method of the interested object
    `context` - the notification context of the interested object

Method Detail

### compareNotifyContext

    public boolean compareNotifyContext(java.lang.Object object)

  Compare an object to the notification context.

  Specified by:
    `compareNotifyContext` in interface `IObserver`
  Parameters:
    `object` - the object to compare
  Returns:
    boolean indicating if the object and the notification context are the same

### notifyObserver

    public void notifyObserver(INotification notification)

  Notify the interested object.

  Specified by:
    `notifyObserver` in interface `IObserver`
  Parameters:
    `notification` - the `INotification` to pass to the interested object's notification method.

### setNotifyContext

    public void setNotifyContext(java.lang.Object notifyContext)

  Set the notification context.

  Specified by:
    `setNotifyContext` in interface `IObserver`
  Parameters:
    `notifyContext` - the notification context (this) of the interested object.

### setNotifyMethod

    public void setNotifyMethod(IFunction notifyMethod)

  Set the notification method.

  The notification method should take one parameter of type `INotification`.

  Specified by:
    `setNotifyMethod` in interface `IObserver`
  Parameters:
    `notifyMethod` - the notification (callback) method of the interested object.

### getNotifyMethod

    public IFunction getNotifyMethod()

  Get the notification method.

  Returns:
    the notification (callback) method of the interested object.

### getNotifyContext

    public java.lang.Object getNotifyContext()

  Get the notification context.

  Returns:
    the notification context (`this`) of the interested object.

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