IteratorFactory : public class
Created: 04/26/07 10:55:48
Modified: 04/26/07 10:55:48
Project:
Advanced:
Iterator specific Factory Pattern implementation which defines an API for handling specific Iterator instantiation 
@see com.ericfeminella.utils.iterators.IteratorTypes
Operation Details
public static
getIterator(
type: String,
):IIterator
Sequential
Notes: Static method which handles Iterator instantiation based on static constants defined in IteratorTypes: <br /><p> As best practice, use constant defined by IteratorTypes: <br /><ul><br /><li>IteratorTypes.OBJECT_ITERATOR;</li><br /><li>IteratorTypes.ARRAY_ITERATOR;</li><br /><li>IteratorTypes.COLLECTION_ITERATOR;</li><br /></ul><br /></p> <br />@example For instance, client would typically create an iterator as follows <br /><listing version="3.0"  import com.ericfeminella.utils.iterators.IIterator; import com.ericfeminella.utils.iterators.IteratorFactory; import com.ericfeminella.utils.iterators.IteratorTypes; import mx.collections.ArrayCollection;  var collection:ArrayCollection new ArrayCollection(["A","B","C"]); var it:IIterator IteratorFactory.getIterator( IteratorTypes.COLLECTION_ITERATOR ); it.setAggregate( collection );  while iterator.hasNext() trace( it.next(), it.position());  A, B, C,  iterator IteratorFactory.getIterator(IteratorTypes.ARRAY_ITERATOR); iterator.setAggregate(["A", "B", "C"]);  while (iterator.hasNext()) trace(iterator.next());  A, B, C, <br /></listing> <br /><p> By typing an Iterator instance as an IIterator, clients have the flexibility of changing the concrete iterator at runtime<br /></p> <br />@param   static constant representing valid IteratorType<br />@return  concrete iterator implementation as specified by type argument<br />@see     <code>com.ericfeminella.utils.iterators#IteratorTypes</code>