| Package | system.models.maps |
| Class | public class OrderedMapModel |
| Inheritance | OrderedMapModel MapModel ChangeModel KernelModel Object |
| Implements | Runnable |
| 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 | |
| loop : Boolean = true
Indicates if the next and previous method loops when the internal ordered iterator can find a next or previous value object. | OrderedMapModel | ||
![]() | 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 | ||
|---|---|---|---|
OrderedMapModel(key:String = id)
Creates a new OrderedMapModel instance. | OrderedMapModel | ||
![]() | add(entry:Object):void
Inserts an entry in the model, must be identifiable and contains an id property. | MapModel | |
clear():void [override]
Clear the model. | OrderedMapModel | ||
![]() | 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 | |
hasNext():Boolean
Returns true if the model has more elements. | OrderedMapModel | ||
hasPrevious():Boolean
Checks to see if there is a previous element that can be iterated to. | OrderedMapModel | ||
![]() | 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 | |
next():*
Sets the next value object in the model. | OrderedMapModel | ||
![]() | 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 | |
previous():*
Sets the previous value object in the model. | OrderedMapModel | ||
![]() | remove(entry:Object):void
Removes an entry in the model. | MapModel | |
reset():void
Reset the internal iterator of the model. | OrderedMapModel | ||
run(... arguments):void
Resets the model and run the model to select the next value object register in the model. | OrderedMapModel | ||
seek(position:*):void
Seek the model and select the specified object. | OrderedMapModel | ||
[override]
Sets the internal map of this model (default use a new system.data.maps.HashMap instance). | OrderedMapModel | ||
![]() | 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 | |
| loop | property |
public var loop:Boolean = trueIndicates if the next and previous method loops when the internal ordered iterator can find a next or previous value object.
| OrderedMapModel | () | Constructor |
public function OrderedMapModel(key:String = id)Creates a new OrderedMapModel instance.
Parameterskey: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").
|
| clear | () | method |
override public function clear():voidClear the model.
| hasNext | () | method |
public function hasNext():Boolean
Returns true if the model has more elements.
Boolean — true if the model has more elements.
|
| hasPrevious | () | method |
public function hasPrevious():BooleanChecks to see if there is a previous element that can be iterated to.
ReturnsBoolean — true if the iterator has more elements.
|
| next | () | method |
public function next():*Sets the next value object in the model.
Returns* |
| previous | () | method |
public function previous():*Sets the previous value object in the model. If no value object is selected in the model this method invoke the next() method to select the first value object.
Returns* |
| reset | () | method |
public function reset():voidReset the internal iterator of the model.
| run | () | method |
public function run(... arguments):voidResets the model and run the model to select the next value object register in the model.
Parameters
... arguments |
| seek | () | method |
public function seek(position:*):voidSeek the model and select the specified object.
Parameters
position:* — The object reference to seek the model.
|
ArgumentError — if the passed-in ValueObject isn't register in the model.
|
| setMap | () | method |
override public function setMap(map:Map):voidSets the internal map of this model (default use a new system.data.maps.HashMap instance).
Parameters
map:Map |
IllegalOperationError — The OrderedMapModel class fix the internal map with an ArrayMap instance only, you can't change it.
|
package examples
{
import system.models.Model ;
import system.models.maps.OrderedMapModel ;
import flash.display.Sprite;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
public class OrderedMapModelExample extends Sprite
{
public function OrderedMapModelExample()
{
model = new OrderedMapModel() ;
model.added.connect( added ) ;
model.changed.connect( changed ) ;
var count:uint = 4 ;
for (var i:int ; i < count ; i++ )
{
model.add( { id : i , filter : i << 1 } ) ;
}
model.run() ;
stage.addEventListener( KeyboardEvent.KEY_DOWN , keyDown ) ;
}
public var model:OrderedMapModel ;
public function added( entry:Object , model:Model ):void
{
trace( "add entry:" + entry + " in " + model ) ;
}
public function changed( entry:Object , model:Model ):void
{
trace( "change entry:" + entry ) ;
}
public function keyDown( e:KeyboardEvent ):void
{
var code:uint = e.keyCode ;
switch( code )
{
case Keyboard.LEFT :
{
model.previous() ;
trace( "hasPrevious:" + model.hasPrevious() ) ;
break ;
}
case Keyboard.RIGHT :
{
model.next() ;
trace( "hasNext:" + model.hasNext() ) ;
break ;
}
case Keyboard.SPACE :
{
model.loop = !model.loop ;
trace( "loop:" + model.loop ) ;
break ;
}
}
}
}
}