Packagesystem.models.maps
Classpublic class OrderedMapModel
InheritanceOrderedMapModel Inheritance MapModel Inheritance ChangeModel Inheritance KernelModel Inheritance Object
Implements Runnable

This map model object is ordered with a previous and next methods inside.

View the examples



Public Properties
 PropertyDefined By
 Inheritedadded : Signaler
[read-only] Emits a message when an entry is added in the model.
MapModel
 InheritedbeforeChanged : Signaler
[read-only] Emits a message before the current object in the model is changed.
ChangeModel
 Inheritedchanged : Signaler
[read-only] Emits a message when the current object in the model is changed.
ChangeModel
 Inheritedcleared : Signaler
[read-only] Emits a message when the current object in the model is cleared.
ChangeModel
 Inheritedcurrent : *
Determinates the selected value in this model.
ChangeModel
 Inheritedlength : 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
 InheritedprimaryKey : String
Indicates the name of the primary key used to map all objects in the model and identifies each record in the table.
MapModel
 Inheritedremoved : Signaler
[read-only] Emits a message when an entry is removed in the model.
MapModel
 Inheritedsecurity : Boolean = true
This property defined if the current property can accept the same object in argument as the current one.
ChangeModel
 Inheritedupdated : Signaler
[read-only] Emits a message when an entry is updated in the model.
MapModel
Public Methods
 MethodDefined By
  
OrderedMapModel(key:String = id)
Creates a new OrderedMapModel instance.
OrderedMapModel
 Inherited
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
 Inherited
contains(entry:Object):Boolean
Returns true if the model contains the specified entry.
MapModel
 Inherited
containsByProperty(propName:String, value:*):Boolean
Returns true if the model contains the specified attribute value.
MapModel
 Inherited
containsKey(key:*):Boolean
Returns true if the model contains the specified id key in argument.
MapModel
 Inherited
get(key:*):Object
Returns the entry defined by the key passed-in argument.
MapModel
 Inherited
getByProperty(propName:String, value:*):Object
Returns an entry defines in the model with the specified member.
MapModel
 Inherited
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
 Inherited
isEmpty():Boolean
Returns true if the model is empty.
MapModel
 Inherited
isLocked():Boolean
Returns true if the object is locked.
KernelModel
 Inherited
Returns the iterator of this model.
MapModel
 Inherited
Returns the keys iterator of this model.
MapModel
 Inherited
lock():void
Locks the object.
KernelModel
  
next():*
Sets the next value object in the model.
OrderedMapModel
 Inherited
notifyAdd(entry:Object):void
Notify a signal when a new entry is inserted in the model.
MapModel
 Inherited
notifyBeforeChange(value:*):void
Notify a signal before the specified value is changed.
ChangeModel
 Inherited
notifyChange(value:*):void
Notify a signal when the model is changed.
ChangeModel
 Inherited
Notify a signal when the model is cleared.
ChangeModel
 Inherited
notifyRemove(entry:Object):void
Notify a signal when a new entry is removed in the model.
MapModel
 Inherited
notifyUpdate(entry:Object):void
Notify a signal when a new entry is updated in the model.
MapModel
  
Sets the previous value object in the model.
OrderedMapModel
 Inherited
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
  
setMap(map:Map):void
[override] Sets the internal map of this model (default use a new system.data.maps.HashMap instance).
OrderedMapModel
 Inherited
supports(value:*):Boolean
Returns true if the Validator object validate the value.
KernelModel
 Inherited
unlock():void
Unlocks the display.
KernelModel
 Inherited
update(entry:Object):void
Update a value object in the model.
MapModel
 Inherited
validate(value:*):void
Evaluates the specified value and throw a TypeError object if the value is not valid.
KernelModel
Public Constants
 ConstantDefined By
 InheritedDEFAULT_PRIMARY_KEY : String = id
[static] Indicates the default primary key value ("id").
MapModel
Property Detail
loopproperty
public var loop:Boolean = true

Indicates if the next and previous method loops when the internal ordered iterator can find a next or previous value object.

Constructor Detail
OrderedMapModel()Constructor
public function OrderedMapModel(key:String = id)

Creates a new OrderedMapModel instance.

Parameters
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").
Method Detail
clear()method
override public function clear():void

Clear the model.

hasNext()method 
public function hasNext():Boolean

Returns true if the model has more elements.

Returns
Booleantrue if the model has more elements.
hasPrevious()method 
public function hasPrevious():Boolean

Checks to see if there is a previous element that can be iterated to.

Returns
Booleantrue 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():void

Reset the internal iterator of the model.

run()method 
public function run(... arguments):void

Resets the model and run the model to select the next value object register in the model.

Parameters

... arguments

seek()method 
public function seek(position:*):void

Seek the model and select the specified object.

Parameters

position:* — The object reference to seek the model.


Throws
ArgumentError — if the passed-in ValueObject isn't register in the model.
setMap()method 
override public function setMap(map:Map):void

Sets the internal map of this model (default use a new system.data.maps.HashMap instance).

Parameters

map:Map


Throws
IllegalOperationError — The OrderedMapModel class fix the internal map with an ArrayMap instance only, you can't change it.
Examples
Example
     
     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 ;
                     }
                 }
             }
         }
     }