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.command
Class MacroCommand

    java.lang.Object
      org.puremvc.java.patterns.observer.Notifier
          org.puremvc.java.patterns.command.MacroCommand

All Implemented Interfaces:
  ICommand, INotifier

    public class MacroCommand

extends Notifier
implements ICommand

A base `ICommand` implementation that executes other `ICommand`s.

A `MacroCommand` maintains an list of `ICommand` Class references called SubCommands.

When `execute` is called, the `MacroCommand` instantiates and calls `execute` on each of its SubCommands turn. Each SubCommand will be passed a reference to the original `INotification` that was passed to the `MacroCommand`'s `execute` method.

Unlike `SimpleCommand`, your subclass should not override `execute`, but instead, should override the `initializeMacroCommand` method, calling `addSubCommand` once for each SubCommand to be executed.

See Also:
  `Controller`, `Notification`, `SimpleCommand`

Field Summary

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

Constructor Summary
`MacroCommand()` Constructor.

Method Summary
`protected void` | `addSubCommand(ICommand commandClassRef)` Add a SubCommand.
`void` | `execute(INotification notification)` Execute this `MacroCommand`'s SubCommands.
`protected void` | `initializeMacroCommand()` Initialize the `MacroCommand`.

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`

Constructor Detail

### MacroCommand

    public MacroCommand()

  Constructor.

  You should not need to define a constructor, instead, override the `initializeMacroCommand` method.

  If your subclass does define a constructor, be sure to call `super()`.

Method Detail

### initializeMacroCommand

    protected void initializeMacroCommand()

  Initialize the `MacroCommand`.

  In your subclass, override this method to initialize the `MacroCommand`'s SubCommand list with `ICommand` class references like this:

       // Initialize MyMacroCommand override protected function
       initializeMacroCommand( ) : void { addSubCommand(
       com.me.myapp.controller.FirstCommand ); addSubCommand(
       com.me.myapp.controller.SecondCommand ); addSubCommand(
       com.me.myapp.controller.ThirdCommand ); }

  Note that SubCommands may be any `ICommand` implementor, `MacroCommand`s or `SimpleCommands` are both acceptable.

### addSubCommand

    protected void addSubCommand(ICommand commandClassRef)

  Add a SubCommand.

  The SubCommands will be called in First In/First Out (FIFO) order.

  Parameters:
    `commandClassRef` - a reference to the `Class` of the `ICommand`.

### execute

    public void execute(INotification notification)

  Execute this `MacroCommand`'s SubCommands.

  The SubCommands will be called in First In/First Out (FIFO) order.

  Specified by:
    `execute` in interface `ICommand`
  Parameters:
    `notification` - the `INotification` object to be passsed to each SubCommand.

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