Packageorg.robotlegs.base
Classpublic class CommandMap
InheritanceCommandMap Inheritance Object
Implements ICommandMap

An abstract ICommandMap implementation



Protected Properties
 PropertyDefined By
  detainedCommands : Dictionary
CommandMap
  eventDispatcher : IEventDispatcher
The IEventDispatcher to listen to
CommandMap
  eventTypeMap : Dictionary
Internal TODO: This needs to be documented
CommandMap
  injector : IInjector
The IInjector to inject with
CommandMap
  reflector : IReflector
The IReflector to reflect with
CommandMap
  verifiedCommandClasses : Dictionary
Internal Collection of command classes that have been verified to implement an execute method
CommandMap
Public Methods
 MethodDefined By
  
CommandMap(eventDispatcher:IEventDispatcher, injector:IInjector, reflector:IReflector)
Creates a new CommandMap object
CommandMap
  
detain(command:Object):void
Detain a Command instance
CommandMap
  
execute(commandClass:Class, payload:Object = null, payloadClass:Class = null, named:String):void
Execute a Command with an optional payload The commandClass must implement an execute() method
CommandMap
  
hasEventCommand(eventType:String, commandClass:Class, eventClass:Class = null):Boolean
Check if a Class has been mapped to an Event type
CommandMap
  
mapEvent(eventType:String, commandClass:Class, eventClass:Class = null, oneshot:Boolean = false):void
Map a Class to an Event type The commandClass must implement an execute() method
CommandMap
  
release(command:Object):void
Release a Command instance
CommandMap
  
unmapEvent(eventType:String, commandClass:Class, eventClass:Class = null):void
Unmap a Class to Event type mapping
CommandMap
  
Removes all mappings made through mapEvent
CommandMap
Protected Methods
 MethodDefined By
  
routeEventToCommand(event:Event, commandClass:Class, oneshot:Boolean, originalEventClass:Class):Boolean
Event Handler
CommandMap
  
verifyCommandClass(commandClass:Class):void
CommandMap
Property Detail
detainedCommandsproperty
protected var detainedCommands:Dictionary

eventDispatcherproperty 
protected var eventDispatcher:IEventDispatcher

The IEventDispatcher to listen to

eventTypeMapproperty 
protected var eventTypeMap:Dictionary

Internal TODO: This needs to be documented

injectorproperty 
protected var injector:IInjector

The IInjector to inject with

reflectorproperty 
protected var reflector:IReflector

The IReflector to reflect with

verifiedCommandClassesproperty 
protected var verifiedCommandClasses:Dictionary

Internal Collection of command classes that have been verified to implement an execute method

Constructor Detail
CommandMap()Constructor
public function CommandMap(eventDispatcher:IEventDispatcher, injector:IInjector, reflector:IReflector)

Creates a new CommandMap object

Parameters
eventDispatcher:IEventDispatcher — The IEventDispatcher to listen to
 
injector:IInjector — An IInjector to use for this context
 
reflector:IReflector — An IReflector to use for this context
Method Detail
detain()method
public function detain(command:Object):void

Detain a Command instance

Parameters

command:Object — The Command instance to detain

execute()method 
public function execute(commandClass:Class, payload:Object = null, payloadClass:Class = null, named:String):void

Execute a Command with an optional payload

The commandClass must implement an execute() method

Parameters

commandClass:Class — The Class to instantiate - must have an execute() method
 
payload:Object (default = null) — An optional payload
 
payloadClass:Class (default = null) — An optional class to inject the payload as
 
named:String — An optional name for the payload injection

hasEventCommand()method 
public function hasEventCommand(eventType:String, commandClass:Class, eventClass:Class = null):Boolean

Check if a Class has been mapped to an Event type

Parameters

eventType:String — The Event type
 
commandClass:Class — The Class
 
eventClass:Class (default = null) — Optional Event class for a stronger mapping. Defaults to flash.events.Event.

Returns
Boolean — Whether the Class is mapped to this Event type
mapEvent()method 
public function mapEvent(eventType:String, commandClass:Class, eventClass:Class = null, oneshot:Boolean = false):void

Map a Class to an Event type

The commandClass must implement an execute() method

Parameters

eventType:String — The Event type to listen for
 
commandClass:Class — The Class to instantiate - must have an execute() method
 
eventClass:Class (default = null) — Optional Event class for a stronger mapping. Defaults to flash.events.Event. Your commandClass can optionally [Inject] a variable of this type to access the event that triggered the command.
 
oneshot:Boolean (default = false) — Unmap the Class after execution?

release()method 
public function release(command:Object):void

Release a Command instance

Parameters

command:Object — The Command instance to release for garbage collection

routeEventToCommand()method 
protected function routeEventToCommand(event:Event, commandClass:Class, oneshot:Boolean, originalEventClass:Class):Boolean

Event Handler

Parameters

event:Event — The Event
 
commandClass:Class — The Class to construct and execute
 
oneshot:Boolean — Should this command mapping be removed after execution?
 
originalEventClass:Class

Returns
Booleantrue if the event was routed to a Command and the Command was executed, false otherwise
unmapEvent()method 
public function unmapEvent(eventType:String, commandClass:Class, eventClass:Class = null):void

Unmap a Class to Event type mapping

Parameters

eventType:String — The Event type
 
commandClass:Class — The Class to unmap
 
eventClass:Class (default = null) — Optional Event class for a stronger mapping. Defaults to flash.events.Event.

unmapEvents()method 
public function unmapEvents():void

Removes all mappings made through mapEvent

verifyCommandClass()method 
protected function verifyCommandClass(commandClass:Class):void

Parameters

commandClass:Class


Throws
org.robotlegs.base::ContextError