| Package | system.models.maps |
| Class | public class MapModel |
| Inheritance | MapModel ChangeModel KernelModel Object |
| Implements | Iterable |
| Subclasses | OrderedMapModel |
Map to register objects with a specific key.
Example :
package examples
{
import core.dump;
import system.models.maps.MapModel;
import flash.display.Sprite;
public class MapModelExample extends Sprite
{
public function MapModelExample()
{
model = new MapModel() ;
trace( "# model primary key : " + model.primaryKey ) ;
model.added.connect( added ) ;
model.beforeChanged.connect( beforeChanged ) ;
model.changed.connect( changed ) ;
model.cleared.connect( cleared ) ;
model.removed.connect( removed ) ;
model.updated.connect( updated ) ;
model.add( o1 ) ;
model.add( o2 ) ;
model.add( o3 ) ;
trace( "# model.get('key1') == o1 : " + ( model.get("key1") == o1 ) ) ;
trace( "# model.get('key1') == o4 : " + ( model.get("key1") == o4 ) ) ;
model.update( o4 ) ;
model.current = o1 ;
model.current = o2 ;
model.remove( o1 ) ;
model.clear() ;
}
protected var model:MapModel ;
protected var o1:Object = { id : "key1" } ;
protected var o2:Object = { id : "key2" } ;
protected var o3:Object = { id : "key3" } ;
protected var o4:Object = { id : "key1" } ;
protected function added( value:, model:MapModel ):void
{
trace( model + " added : " + dump(value) ) ;
}
protected function beforeChanged( value:, model:MapModel ):void
{
trace( model + " beforeChanged : " + dump(value) ) ;
}
protected function changed( value:, model:MapModel ):void
{
trace( model + " changed : " + dump(value) ) ;
}
protected function cleared( model:MapModel ):void
{
trace( model + " cleared" ) ;
}
protected function removed( value:, model:MapModel ):void
{
trace( model + " removed : " + dump(value) ) ;
}
protected function updated( value:, model:MapModel ):void
{
trace( model + " updated : " + dump(value) ) ;
trace( "# model.get('key1') == o1 : " + ( model.get("key1") == o1 ) ) ;
trace( "# model.get('key1') == o4 : " + ( model.get("key1") == o4 ) ) ;
}
}
}
| Property | Defined By | ||
|---|---|---|---|
| added : Signaler [read-only]
Emits a message when an entry is added in the model. | MapModel | ||
![]() | beforeChanged : Signaler [read-only]
Emits a message before the current object in the model is changed. | ChangeModel | |
![]() | changed : Signaler [read-only]
Emits a message when the current object in the model is changed. | ChangeModel | |
![]() | cleared : Signaler [read-only]
Emits a message when the current object in the model is cleared. | ChangeModel | |
![]() | current : *
Determinates the selected value in this model. | ChangeModel | |
| length : uint [read-only]
Indicates the number of entries in the model. | MapModel | ||
| primaryKey : String
Indicates the name of the primary key used to map all objects in the model and identifies each record in the table. | MapModel | ||
| removed : Signaler [read-only]
Emits a message when an entry is removed in the model. | MapModel | ||
![]() | security : Boolean = true
This property defined if the current property can accept the same object in argument as the current one. | ChangeModel | |
| updated : Signaler [read-only]
Emits a message when an entry is updated in the model. | MapModel | ||
| Method | Defined By | ||
|---|---|---|---|
Creates a new MapModel instance. | MapModel | ||
add(entry:Object):void
Inserts an entry in the model, must be identifiable and contains an id property. | MapModel | ||
clear():void [override]
Removes all value objects in the model. | MapModel | ||
contains(entry:Object):Boolean
Returns true if the model contains the specified entry. | MapModel | ||
containsByProperty(propName:String, value:*):Boolean
Returns true if the model contains the specified attribute value. | MapModel | ||
containsKey(key:*):Boolean
Returns true if the model contains the specified id key in argument. | MapModel | ||
get(key:*):Object
Returns the entry defined by the key passed-in argument. | MapModel | ||
getByProperty(propName:String, value:*):Object
Returns an entry defines in the model with the specified member. | MapModel | ||
Returns the internal map of this model. | MapModel | ||
isEmpty():Boolean
Returns true if the model is empty. | MapModel | ||
![]() | isLocked():Boolean
Returns true if the object is locked. | KernelModel | |
Returns the iterator of this model. | MapModel | ||
Returns the keys iterator of this model. | MapModel | ||
![]() | lock():void
Locks the object. | KernelModel | |
notifyAdd(entry:Object):void
Notify a signal when a new entry is inserted in the model. | MapModel | ||
![]() | notifyBeforeChange(value:*):void
Notify a signal before the specified value is changed. | ChangeModel | |
![]() | notifyChange(value:*):void
Notify a signal when the model is changed. | ChangeModel | |
![]() | notifyClear():void
Notify a signal when the model is cleared. | ChangeModel | |
notifyRemove(entry:Object):void
Notify a signal when a new entry is removed in the model. | MapModel | ||
notifyUpdate(entry:Object):void
Notify a signal when a new entry is updated in the model. | MapModel | ||
remove(entry:Object):void
Removes an entry in the model. | MapModel | ||
Sets the internal map of this model (default use a new system.data.maps.HashMap instance). | MapModel | ||
![]() | supports(value:*):Boolean
Returns true if the Validator object validate the value. | KernelModel | |
![]() | unlock():void
Unlocks the display. | KernelModel | |
update(entry:Object):void
Update a value object in the model. | MapModel | ||
![]() | validate(value:*):void
Evaluates the specified value and throw a TypeError object if the value is not valid. | KernelModel | |
| Constant | Defined By | ||
|---|---|---|---|
| DEFAULT_PRIMARY_KEY : String = id [static]
Indicates the default primary key value ("id"). | MapModel | ||
| added | property |
added:Signaler [read-only] Emits a message when an entry is added in the model.
public function get added():Signaler| length | property |
length:uint [read-only] Indicates the number of entries in the model.
public function get length():uint| primaryKey | property |
primaryKey:StringIndicates the name of the primary key used to map all objects in the model and identifies each record in the table. By default the model use the "id" primary key in the objects.
Note: If you use this property and if the model contains entries, all entries will be removing.
public function get primaryKey():String public function set primaryKey(value:String):voidSee also
| removed | property |
removed:Signaler [read-only] Emits a message when an entry is removed in the model.
public function get removed():Signaler| updated | property |
updated:Signaler [read-only] Emits a message when an entry is updated in the model.
public function get updated():Signaler| MapModel | () | Constructor |
public function MapModel(factory:Map = null, key:String = id)Creates a new MapModel instance.
Parametersfactory:Map (default = null) — (optional) the Map factory reference used in the model to register all entries.
| |
key:String (default = id) — Indicates the name of the primary key used to map all objects in the model and identifies each record in the table (default "id").
|
| add | () | method |
public function add(entry:Object):voidInserts an entry in the model, must be identifiable and contains an id property.
Parameters
entry:Object |
ArgumentError — if the argument of this method is 'null' or 'undefined'.
| |
ArgumentError — if the passed-in entry is already register in the model.
|
| clear | () | method |
override public function clear():voidRemoves all value objects in the model.
| contains | () | method |
public function contains(entry:Object):Boolean
Returns true if the model contains the specified entry.
Parameters
entry:Object |
Boolean — true if the model contains the specified entry.
|
| containsByProperty | () | method |
public function containsByProperty(propName:String, value:*):Boolean
Returns true if the model contains the specified attribute value.
Parameters
propName:String | |
value:* |
Boolean — true if the model contains the specified key in argument
|
| 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:*):ObjectReturns the entry defined by the key passed-in argument.
Parameters
key:* |
Object — the entry defined by the key passed-in argument.
|
| getByProperty | () | method |
public function getByProperty(propName:String, value:*):ObjectReturns an entry defines in the model with the specified member.
Parameters
propName:String | |
value:* |
Object — an entry defines in the model with the specified member.
|
| getMap | () | method |
public function getMap():MapReturns the internal map of this model.
ReturnsMap — the internal map of this model.
|
| 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:Object):voidNotify a signal when a new entry is inserted in the model.
Parameters
entry:Object |
| notifyRemove | () | method |
public function notifyRemove(entry:Object):voidNotify a signal when a new entry is removed in the model.
Parameters
entry:Object |
| notifyUpdate | () | method |
public function notifyUpdate(entry:Object):voidNotify a signal when a new entry is updated in the model.
Parameters
entry:Object |
| remove | () | method |
public function remove(entry:Object):voidRemoves an entry in the model.
Parameters
entry:Object |
| setMap | () | method |
public function setMap(map:Map):voidSets the internal map of this model (default use a new system.data.maps.HashMap instance).
Parameters
map:Map |
| update | () | method |
public function update(entry:Object):voidUpdate a value object in the model.
Parameters
entry:Object |
ArgumentError — if the entry is not register in the model.
|
| DEFAULT_PRIMARY_KEY | Constant |
public static const DEFAULT_PRIMARY_KEY:String = idIndicates the default primary key value ("id").