|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jauvm.util.Generator<T>
public abstract class Generator<T>
The abstract base class for generators.
This class serves as the base class for generators, providing them thegenerate(Object... args)
and yield(T value)
methods. Sub-classes must implement the run(Object... args)
method.
Note: the same Generator
object is not to be used to iterate on more than one iterator simultaneously. For
that purpose, you should create two (or more) Generator
objects of the same class.
Iterable
,
Iterator
Constructor Summary | |
---|---|
Generator()
|
Method Summary | |
---|---|
Iterable<T> |
generate(Object... args)
Creates an Iterable object that will have the values for its iterators generated by this Generator object. |
protected abstract void |
run(Object... args)
Generates the next value for the present iterator. |
protected void |
yield(T value)
Hands down the next value to be yielded by the present iterator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Generator()
Method Detail |
---|
protected abstract void run(Object... args)
Iterator
objects associated with the Iterable
object returned by the
generate(Object... args)
method to produce each next value for the iterator.
Values are successively passed from this method to those iterators by calling the yield
method and
proceding with determining the next value to pass. When no more values can be produced, this method should
return.
The arguments passed to this method are the arguments given to the generate(Object... args)
method that
returned the Iterable
object whose iterators are invoking this method.
args
- the args
passed to the generate(Object... args)
methodgenerate(Object...)
,
yield(Object)
protected final void yield(T value)
run(Object... args)
method to pass the next value to be yielded to
the iterator.
value
- the next value to pass to the iterator
UnsupportedOperationException
- if yield is invoked outside the context of an iterator.public final Iterable<T> generate(Object... args)
Iterable
object that will have the values for its iterators generated by this Generator
object.
The arguments to this method will be passed to the run(Object... args)
method, which will successively
generate each value for the returned Iterable
object's iterators.
args
- the arguments to be handed down to the run(Object... args)
method
Iterable
object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |