IteratorFactory : public class
Created: |
04/26/07 10:55:48 |
Modified: |
04/26/07 10:55:48 |
|
Project: |
|
Author: |
Eric J. Feminella |
Version: |
1.0 |
Phase: |
1.0 |
Status: |
Proposed |
Complexity: |
Easy |
Advanced: |
|
UUID: |
{C10ECC73-B5BB-4ad2-A96F-8E5A08AA75EC} |
Appears In: |
iterators |
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,
Default: |
|
Kind: |
in |
Stereotype: |
|
|
|
):IIterator
|
Sequential
Notes:
|
Static method which handles Iterator instantiation based on static constants defined in IteratorTypes: <br /><p> As a best practice, use a 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, a 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, 0 B, 1 C, 2 iterator = IteratorFactory.getIterator(IteratorTypes.ARRAY_ITERATOR); iterator.setAggregate(["A", "B", "C"]); while (iterator.hasNext()) { trace(iterator.next()); } A, 0 B, 1 C, 2 <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 a static constant representing a valid IteratorType<br />@return concrete iterator implementation as specified by type argument<br />@see <code>com.ericfeminella.utils.iterators#IteratorTypes</code>
|
|