Packagesystem.data.iterators
Classpublic class PageByPageIterator
InheritancePageByPageIterator Inheritance Object
Implements OrderedIterator

An iterator page by page over an array who return an new array of elements. If the step size value is 1 the next and previous methods returns the single value element in the data array.

Example :

     import system.iterator.PageByPageIterator;
     
     var ar:Array = [1, 2, 3, 4, 5, 6, 7, 8] ;
     
     var it:PageByPageIterator = new PageByPageIterator( a, 2 ) ;
     
     var next:Function = function():void
     {
         if (!it.hasNext())
         {
             it.reset() ;
         }
         var next:= it.next()
         trace( "> " + next + " : " + it.currentPage() ) ;
     }
     
     var prev:Function = function():void
     {
         var prev:;
         if ( !it.hasPrevious())
         {
             it.lastPage() ;
             // use it.current() to get the current page after a it.lastPage() invokation.
             prev = it.current() ; 
         }
         else
         {
             prev = it.previous() ;
         }
         trace( "> " + prev + " : " + it.currentPage() ) ;
     }
     
     next() ; // > 1,2 : 1
     next() ; // > 3,4 : 2
     next() ; // > 5,6 : 3
     next() ; // > 7,8 : 4
     next() ; // > 1,2 : 1
     prev() ; // > 7,8 : 4
     
     trace( "> current : " + it.current() ) ;
     



Public Properties
 PropertyDefined By
  DEFAULT_STEP : Number = 1
[static] The default step value in all the PageByPageIterators.
PageByPageIterator
Public Methods
 MethodDefined By
  
PageByPageIterator(data:Array, stepSize:uint = 1)
Creates a new PageByPageIterator.
PageByPageIterator
  
Returns the current value.
PageByPageIterator
  
currentPage():Number
Returns the current page value.
PageByPageIterator
  
firstPage():void
Seek the iterator in the first page of this object.
PageByPageIterator
  
getStepSize():Number
Returns the step size of this PageByPageIterator.
PageByPageIterator
  
hasNext():Boolean
Returns true if the iteration has more elements.
PageByPageIterator
  
hasPrevious():Boolean
Checks to see if there is a previous element that can be iterated to.
PageByPageIterator
  
key():*
Returns the current page number.
PageByPageIterator
  
lastPage():void
Seek the iterator in the last page of this object.
PageByPageIterator
  
next():*
Returns the next Array page of elements or the next element in the Array if the getStepSize() value is 1.
PageByPageIterator
  
pageCount():Number
Returns the numbers of page of this iterator.
PageByPageIterator
  
Returns the previous Array page of elements or the previous element in the Array if the getStepSize() value is 1.
PageByPageIterator
  
remove():*
Unsupported operation in a PageByPageIterator.
PageByPageIterator
  
reset():void
Resets the key pointer of the iterator.
PageByPageIterator
  
seek(position:*):void
Seek the key pointer of the iterator.
PageByPageIterator
Property Detail
DEFAULT_STEPproperty
public static var DEFAULT_STEP:Number = 1

The default step value in all the PageByPageIterators.

Constructor Detail
PageByPageIterator()Constructor
public function PageByPageIterator(data:Array, stepSize:uint = 1)

Creates a new PageByPageIterator.

Parameters
data:Array — the array to enumerate.
 
stepSize:uint (default = 1) — the step size value.

Throws
IllegalOperationError — if the data array is empty.
Method Detail
current()method
public function current():*

Returns the current value.

Returns
* — the current value.
currentPage()method 
public function currentPage():Number

Returns the current page value.

Returns
Number — the number of the current page.
firstPage()method 
public function firstPage():void

Seek the iterator in the first page of this object.

getStepSize()method 
public function getStepSize():Number

Returns the step size of this PageByPageIterator.

Returns
Number — the step size of this PageByPageIterator.
hasNext()method 
public function hasNext():Boolean

Returns true if the iteration has more elements.

Returns
Booleantrue if the iterator 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.
key()method 
public function key():*

Returns the current page number.

Returns
* — the current page number.
lastPage()method 
public function lastPage():void

Seek the iterator in the last page of this object.

next()method 
public function next():*

Returns the next Array page of elements or the next element in the Array if the getStepSize() value is 1.

Returns
* — the next Array page of elements or the next element in the Array if the getStepSize() value is 1.
pageCount()method 
public function pageCount():Number

Returns the numbers of page of this iterator.

Returns
Number — the numbers of page of this iterator.
previous()method 
public function previous():*

Returns the previous Array page of elements or the previous element in the Array if the getStepSize() value is 1.

Returns
* — the previous element from the collection.
remove()method 
public function remove():*

Unsupported operation in a PageByPageIterator.

Returns
*

Throws
IllegalOperationError — the method remove() in this iterator is unsupported.
reset()method 
public function reset():void

Resets the key pointer of the iterator.

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

Seek the key pointer of the iterator.

Parameters

position:*