| Package | vegas.models.maps |
| Class | public class MapModel |
| Inheritance | MapModel ChangeModel CoreModel CoreEventDispatcher Object |
| Implements | Iterable |
Map to register Entry objects with a specific key and this corresponding value.
| Property | Defined By | ||
|---|---|---|---|
| _map : Map
The internal map of this model. | MapModel | ||
| _sAddType : String
The internal ModelObjectEvent type use in the addVO method. | MapModel | ||
| _sRemoveType : String
The internal ModelObjectEvent type use in the removeVO method. | MapModel | ||
| _sUpdateType : String
The internal ModelObjectEvent type when the update event type is use. | MapModel | ||
| Method | Defined By | ||
|---|---|---|---|
Creates a new MapModel instance. | MapModel | ||
![]() | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0.0, useWeakReference:Boolean = false):void
Allows the registration of event listeners on the event target. | CoreEventDispatcher | |
clear():void [override]
Removes all value objects in the model. | MapModel | ||
contains(value:*):Boolean
Returns true if the model contains the specified value. | MapModel | ||
containsKey(key:*):Boolean
Returns true if the model contains the specified id key in argument. | MapModel | ||
![]() | dispatchEvent(event:Event):Boolean
Dispatches an event into the event flow. | CoreEventDispatcher | |
get(key:*):*
Returns the value register in the model with the specified key. | MapModel | ||
![]() |
Returns the internal system.events.EventDispatcher reference. | CoreEventDispatcher | |
getEventTypeADD():String
Returns the event name use in the addVO method. | MapModel | ||
![]() | getEventTypeBEFORE_CHANGE():String
Returns the event name use in the setCurrentVO method before is changed. | ChangeModel | |
![]() | getEventTypeCHANGE():String
Returns the event name use in the setVO method. | ChangeModel | |
![]() | getEventTypeCLEAR():String
Returns the event name use in the clear method. | ChangeModel | |
getEventTypeREMOVE():String
Returns the event name use in the removeVO method. | MapModel | ||
getEventTypeUPDATE():String
Returns the event name use in the updateVO method. | MapModel | ||
Returns the internal map of this model. | MapModel | ||
getMapEntry(key:*):MapEntry
Returns the MapEntry representation of the key/value entry register in the model with the specified key. | MapModel | ||
![]() | hasEventListener(type:String):Boolean
Checks whether the EventDispatcher object has any listeners registered for a specific type of event. | CoreEventDispatcher | |
initEventType():void [override]
This method is invoked to initialize all event types of the model. | MapModel | ||
Initialize the internal Map instance in the constructor of the class. | MapModel | ||
isEmpty():Boolean
Returns true if the model is empty. | MapModel | ||
![]() | isGlobal():Boolean
Indicates if the dispatcher use a global event flow. | CoreEventDispatcher | |
![]() | isLocked():Boolean
Returns true if the object is locked. | CoreEventDispatcher | |
Returns the iterator of this model. | MapModel | ||
Returns the keys iterator of this model. | MapModel | ||
![]() | lock():void
Locks the object. | CoreEventDispatcher | |
Notify a ModelObjectEvent when a ValueObject is inserted in the model. | MapModel | ||
notifyBeforeChange(value:*):void [override]
Notify an event before the current value selected in the model is changed. | MapModel | ||
notifyChange(value:*):void [override]
Notify an event when a value is selected and changed in the model. | MapModel | ||
notifyClear():void [override]
Notify an event when the model is cleared. | MapModel | ||
notifyRemove(entry:Entry):void
Notify an EntryEvent when an key/value entry is removed in the model. | MapModel | ||
notifyUpdate(entry:Entry):void
Notify an EntryEvent when the model is updated. | MapModel | ||
put(key:*, value:*):void
Inserts a value object in the model. | MapModel | ||
![]() | registerEventListener(type:String, listener:*, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Allows the registration of event listeners on the event target (Function or EventListener). | CoreEventDispatcher | |
remove(key:*):void
Removes the entry register in the model with the specified key. | MapModel | ||
![]() | removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object. | CoreEventDispatcher | |
![]() | run(... arguments):void
Run the first process with this model. | CoreModel | |
![]() | setEventDispatcher(dispatcher:EventDispatcher):void
Sets the internal EventDispatcher reference. | CoreEventDispatcher | |
setEventTypeADD(type:String):void
Sets the event name use in the addVO method. | MapModel | ||
![]() | setEventTypeBEFORE_CHANGE(type:String):void
Returns the event name use in the setCurrentVO method before is changed. | ChangeModel | |
![]() | setEventTypeCHANGE(type:String):void
Returns the event name use in the setVO method. | ChangeModel | |
![]() | setEventTypeCLEAR(type:String):void
Returns the event name use in the clear method. | ChangeModel | |
setEventTypeREMOVE(type:String):void
Sets the event name use in the removeVO method. | MapModel | ||
setEventTypeUPDATE(type:String):void
Sets the event name use in the addVO method. | MapModel | ||
![]() | setGlobal(flag:Boolean = false, channel:String = null):void
Sets if the instance use a global system.events.EventDispatcher to dispatch this events, if the flag value is false the instance use a local EventDispatcher. | CoreEventDispatcher | |
Sets the internal map of this model. | MapModel | ||
size():Number
Returns the number of ValueObject in this model. | MapModel | ||
![]() | unlock():void
Unlocks the display. | CoreEventDispatcher | |
![]() | unregisterEventListener(type:String, listener:*, useCapture:Boolean = false):void
Removes a listener (Function or EventListener object) from the EventDispatcher object. | CoreEventDispatcher | |
update(key:*, value:*):void
Update a key/value entry in the model. | MapModel | ||
![]() | willTrigger(type:String):Boolean
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type. | CoreEventDispatcher | |
| _map | property |
protected var _map:MapThe internal map of this model.
| _sAddType | property |
protected var _sAddType:StringThe internal ModelObjectEvent type use in the addVO method.
| _sRemoveType | property |
protected var _sRemoveType:StringThe internal ModelObjectEvent type use in the removeVO method.
| _sUpdateType | property |
protected var _sUpdateType:StringThe internal ModelObjectEvent type when the update event type is use.
| MapModel | () | Constructor |
public function MapModel(global:Boolean = true, channel:String = null, factory:Map = null, id:* = null)Creates a new MapModel instance.
Parametersglobal:Boolean (default = true) — the flag to use a global event flow or a local event flow (default true).
| |
channel:String (default = null) — (optional) the name of the global event flow if the global argument is true.
| |
factory:Map (default = null) — (optional) the Map factory reference used in the model to register all entries.
| |
id:* (default = null) — the id of this model.
|
| clear | () | method |
override public function clear():voidRemoves all value objects in the model.
| contains | () | method |
public function contains(value:*):Boolean
Returns true if the model contains the specified value.
Parameters
value:* |
Boolean — true if the model contains the specified value.
|
| containsKey | () | method |
public function containsKey(key:*):Boolean
Returns true if the model contains the specified id key in argument.
Parameters
key:* |
Boolean — true if the model contains the specified id key in argument
|
| get | () | method |
public function get(key:*):*Returns the value register in the model with the specified key.
Parameters
key:* |
* — the value register in the model with the specified key.
|
| getEventTypeADD | () | method |
public function getEventTypeADD():String
Returns the event name use in the addVO method.
String — the event name use in the addVO method.
|
| getEventTypeREMOVE | () | method |
public function getEventTypeREMOVE():String
Returns the event name use in the removeVO method.
String — the event name use in the removeVO method.
|
| getEventTypeUPDATE | () | method |
public function getEventTypeUPDATE():String
Returns the event name use in the updateVO method.
String — the event name use in the updateVO method.
|
| getMap | () | method |
public function getMap():MapReturns the internal map of this model.
ReturnsMap — the internal map of this model.
|
| getMapEntry | () | method |
public function getMapEntry(key:*):MapEntryReturns the MapEntry representation of the key/value entry register in the model with the specified key.
Parameters
key:* |
MapEntry — the MapEntry representation of the key/value entry register in the model with the specified key.
|
| initEventType | () | method |
override public function initEventType():voidThis method is invoked to initialize all event types of the model.
| initializeMap | () | method |
public function initializeMap():MapInitialize the internal Map instance in the constructor of the class. You can overrides this method if you want change the default HashMap use in this model.
ReturnsMap |
| isEmpty | () | method |
public function isEmpty():Boolean
Returns true if the model is empty.
Boolean — true if the model is empty.
|
| iterator | () | method |
public function iterator():IteratorReturns the iterator of this model.
ReturnsIterator — the iterator of this model.
|
| keyIterator | () | method |
public function keyIterator():IteratorReturns the keys iterator of this model.
ReturnsIterator — the keys iterator of this model.
|
| notifyAdd | () | method |
public function notifyAdd(entry:Entry):void
Notify a ModelObjectEvent when a ValueObject is inserted in the model.
Parameters
entry:Entry |
| notifyBeforeChange | () | method |
override public function notifyBeforeChange(value:*):void
Notify an event before the current value selected in the model is changed.
Parameters
value:* |
| notifyChange | () | method |
override public function notifyChange(value:*):voidNotify an event when a value is selected and changed in the model.
Parameters
value:* |
| notifyClear | () | method |
override public function notifyClear():voidNotify an event when the model is cleared.
| notifyRemove | () | method |
public function notifyRemove(entry:Entry):void
Notify an EntryEvent when an key/value entry is removed in the model.
Parameters
entry:Entry |
| notifyUpdate | () | method |
public function notifyUpdate(entry:Entry):void
Notify an EntryEvent when the model is updated.
Parameters
entry:Entry |
| put | () | method |
public function put(key:*, value:*):voidInserts a value object in the model.
Parameters
key:* | |
value:* |
ArgumentError — if the argument of this method is 'null' or 'undefined'.
| |
ArgumentError — if the key passed in argument is already register in the model.
|
| remove | () | method |
public function remove(key:*):voidRemoves the entry register in the model with the specified key.
Parameters
key:* |
| setEventTypeADD | () | method |
public function setEventTypeADD(type:String):void
Sets the event name use in the addVO method.
Parameters
type:String |
| setEventTypeREMOVE | () | method |
public function setEventTypeREMOVE(type:String):void
Sets the event name use in the removeVO method.
Parameters
type:String |
| setEventTypeUPDATE | () | method |
public function setEventTypeUPDATE(type:String):void
Sets the event name use in the addVO method.
Parameters
type:String |
| setMap | () | method |
public function setMap(m:Map):voidSets the internal map of this model. By default the 'initializeMap' method is used if the passed-in argument is null.
Parameters
m:Map |
| size | () | method |
public function size():Number
Returns the number of ValueObject in this model.
Number — the number of ValueObject in this model.
|
| update | () | method |
public function update(key:*, value:*):voidUpdate a key/value entry in the model.
Parameters
key:* | |
value:* |
ArgumentError — if the key passed-in argument isn't register in the model.
|
package examples
{
import vegas.events.EntryEvent;
import vegas.models.maps.MapModel;
import system.data.Iterator;
import system.data.maps.ArrayMap;
import flash.display.Sprite;
public class ExampleMapModel extends Sprite
{
public function ExampleMapModel()
{
var model:MapModel = new MapModel() ;
model.setMap( new ArrayMap() ) ;
model.addEventListener( EntryEvent.ADD , debug ) ;
model.addEventListener( EntryEvent.BEFORE_CHANGE , debug ) ;
model.addEventListener( EntryEvent.CHANGE , debug ) ;
model.addEventListener( EntryEvent.REMOVE , debug ) ;
model.addEventListener( EntryEvent.UPDATE , debug ) ;
var count:uint = 4 ;
for (var i:int ; i<count ; i++ )
{
model.put( "key" + i , "value" + i ) ;
}
var it:Iterator = model.keyIterator() ;
while( it.hasNext() )
{
model.current = it.next() ;
}
trace( "- model current : " + model.current ) ;
trace( "- model size : " + model.size() ) ;
model.remove( "key2" ) ;
trace( "- model size : " + model.size() ) ;
model.update( "key3" , "content3" ) ;
}
public function debug( e:EntryEvent ):void
{
trace( "# type:" + e.type + " entry:" + e.entry ) ;
}
}
}