Packagemvcexpress.core
Classpublic class CommandMap
InheritanceCommandMap Inheritance Object

Handles command mappings, and executes them then mapped message string is sent.



Protected Properties
 PropertyDefined By
  classRegistry : Dictionary
CommandMap
  commandClassParamTypes : Dictionary
[static] types of command execute function, needed for debug mode only validation of execute() parameter.
CommandMap
  commandPools : Dictionary
CommandMap
  mediatorMap : MediatorMap
CommandMap
  messenger : Messenger
CommandMap
  moduleName : String
CommandMap
  proxyMap : ProxyMap
CommandMap
  validatedCommands : Dictionary
[static] Dictionary with validated command classes.
CommandMap
Public Methods
 MethodDefined By
  
CommandMap($moduleName:String, $messenger:Messenger, $proxyMap:ProxyMap, $mediatorMap:MediatorMap)
CONSTRUCTOR
CommandMap
  
clearCommandPool(commandClass:Class = null):void
Clears all command pools, or specific one.
CommandMap
  
execute(commandClass:Class, params:Object = null):void
Instantiates and executes provided command class, and sends params to it.
CommandMap
  
isCommandPooled(commandClass:Class):Boolean
Checks if specific PooledCommand is already pooled.
CommandMap
  
isMapped(type:String, commandClass:Class = null):Boolean
Checks if Command class is already added to message type, or any class.
CommandMap
  
listMappings(verbose:Boolean = true):String
Returns text of all command classes that are mapped to constants.
CommandMap
  
map(type:String, commandClass:Class, canMapOver:Boolean = false):void
Map a class to be executed then message with provided type is sent.
CommandMap
  
unmap(type:String):void
Unmaps a class to be executed then message with provided type is sent.
CommandMap
Property Detail
classRegistryproperty
protected var classRegistry:Dictionary

commandClassParamTypesproperty 
protected static var commandClassParamTypes:Dictionary

types of command execute function, needed for debug mode only validation of execute() parameter.

commandPoolsproperty 
protected var commandPools:Dictionary

mediatorMapproperty 
protected var mediatorMap:MediatorMap

messengerproperty 
protected var messenger:Messenger

moduleNameproperty 
protected var moduleName:String

proxyMapproperty 
protected var proxyMap:ProxyMap

validatedCommandsproperty 
protected static var validatedCommands:Dictionary

Dictionary with validated command classes.

Constructor Detail
CommandMap()Constructor
public function CommandMap($moduleName:String, $messenger:Messenger, $proxyMap:ProxyMap, $mediatorMap:MediatorMap)

CONSTRUCTOR

Parameters
$moduleName:String
 
$messenger:Messenger
 
$proxyMap:ProxyMap
 
$mediatorMap:MediatorMap
Method Detail
clearCommandPool()method
public function clearCommandPool(commandClass:Class = null):void

Clears all command pools, or specific one. (if commands are not pooled - function fails silently.)

Parameters

commandClass:Class (default = null) — Optional Command class to clear specific command pool

execute()method 
public function execute(commandClass:Class, params:Object = null):void

Instantiates and executes provided command class, and sends params to it.

Parameters

commandClass:Class — Command class to be instantiated and executed.
 
params:Object (default = null) — Object to be sent to execute() function.

isCommandPooled()method 
public function isCommandPooled(commandClass:Class):Boolean

Checks if specific PooledCommand is already pooled.

Parameters

commandClass:Class — PooledCommand subclass to check Command pool for.

Returns
Boolean — true if command pool is created.
isMapped()method 
public function isMapped(type:String, commandClass:Class = null):Boolean

Checks if Command class is already added to message type, or any class.

Parameters

type:String — Message type for command class to react to.
 
commandClass:Class (default = null) — Optional: Command class that will be instantiated and executed.

Returns
Boolean — true if Command class is already mapped to message
listMappings()method 
public function listMappings(verbose:Boolean = true):String

Returns text of all command classes that are mapped to constants. (for debugging)

Parameters

verbose:Boolean (default = true) — if set to true, will return readable string, false will return pairs of message type and command class definition separated by '>', all pairs are separated by ';'.

Returns
String — Text with all mapped commands.
map()method 
public function map(type:String, commandClass:Class, canMapOver:Boolean = false):void

Map a class to be executed then message with provided type is sent.

Only one command can be mapped to single messageType. Error will be thrown if you attempt to map second command class to same message type, unless canMapOver set to true.

Parameters

type:String — Message type for command class to react to.
 
commandClass:Class — Command class that will be executed.
 
canMapOver:Boolean (default = false) — Allows mapping command class over already existing command.

unmap()method 
public function unmap(type:String):void

Unmaps a class to be executed then message with provided type is sent.

Parameters

type:String — Message type for command class to react to.