| Package | com.ericfeminella.utils.iterators |
| Class | public class IteratorFactory |
| Method | Defined by | ||
|---|---|---|---|
|
getIterator(iteratorType:String):IIterator
[static]
Static method which handles Iterator instantiation based on static
constants defined in IteratorTypes:
To avoid this error as a best practice only use an IteratorTypes constant: IteratorTypes.OBJECT_ITERATOR; IteratorTypes.ARRAY_ITERATOR; IteratorTypes.ARRAY_COLLECTION_ITERATOR; For instance, a client would typically create an iterator as follows
import com.ericfeminella.utils.iterators.IIterator;
import com.ericfeminella.utils.iterators.IteratorFactory;
import com.ericfeminella.utils.iterators.IteratorTypes;
private var iterator:IIterator;
this.iterator = IteratorFactory.getIterator(IteratorTypes.OBJECT_ITERATOR);
this.iterator.setAggregate({name: 'IteratorFactory', version: 1.0, author: 'Eric Feminella'});
while (this.iterator.hasNext())
{
trace(this.iterator.next());
}
traces:
IteratorFactory
1.0
Eric Feminella
this.iterator = IteratorFactory.getIterator(IteratorTypes.ARRAY_ITERATOR);
this.iterator.setAggregate(['IteratorFactory', 1.0, 'Eric Feminella']);
while (this.iterator.hasNext())
{
trace(this.iterator.next());
}
traces:
IteratorFactory
1.0
Eric Feminella
By typing an Iterator instance as an IIterator, a client has the flexibility of changing the type of iteration at anytime. | IteratorFactory | ||
| getIterator | () | method |
public static function getIterator(iteratorType:String):IIteratorStatic method which handles Iterator instantiation based on static constants defined in IteratorTypes:
To avoid this error as a best practice only use an IteratorTypes constant: IteratorTypes.OBJECT_ITERATOR; IteratorTypes.ARRAY_ITERATOR; IteratorTypes.ARRAY_COLLECTION_ITERATOR;
For instance, a client would typically create an iterator as follows
import com.ericfeminella.utils.iterators.IIterator;
import com.ericfeminella.utils.iterators.IteratorFactory;
import com.ericfeminella.utils.iterators.IteratorTypes;
private var iterator:IIterator;
this.iterator = IteratorFactory.getIterator(IteratorTypes.OBJECT_ITERATOR);
this.iterator.setAggregate({name: 'IteratorFactory', version: 1.0, author: 'Eric Feminella'});
while (this.iterator.hasNext())
{
trace(this.iterator.next());
}
traces:
IteratorFactory
1.0
Eric Feminella
this.iterator = IteratorFactory.getIterator(IteratorTypes.ARRAY_ITERATOR);
this.iterator.setAggregate(['IteratorFactory', 1.0, 'Eric Feminella']);
while (this.iterator.hasNext())
{
trace(this.iterator.next());
}
traces:
IteratorFactory
1.0
Eric Feminella
By typing an Iterator instance as an IIterator, a client has the flexibility of changing the type of iteration at anytime.
ParametersiteratorType:String — a static constant representing a valid IteratorType
|
IIterator —
IIterator interface which defines the Iterator instance which is returned
|
— IteratorFactoryTypeError specifying that the iterator type does not exist
|
See also