com.varankin.io.stream
Class AccuChopper<Component extends Accumulator<Part>,Part>

java.lang.Object
  extended by com.varankin.io.stream.AccuChopper<Component,Part>
All Implemented Interfaces:
java.lang.Iterable<Component>

public final class AccuChopper<Component extends Accumulator<Part>,Part>
extends java.lang.Object
implements java.lang.Iterable<Component>

General purpose parser, trying to construct Component's from Part's. Component is considered completed, once it rejects next Part object. Parser starts consuming part(s) on getting Component over iterator. Parser retracts unused Part's from completed Component to reuse them for next Component instance.

Author:
© 2010 Nikolai Varankine

Constructor Summary
AccuChopper(java.lang.Iterable<Part> aSource, java.util.Iterator<Component> aFactory)
           
 
Method Summary
 java.util.Iterator<Component> iterator()
          Returns singleton iterator that produces Component's from input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccuChopper

public AccuChopper(java.lang.Iterable<Part> aSource,
                   java.util.Iterator<Component> aFactory)
Parameters:
aSource - source of Part(s) to construct Component(s).
aFactory - producer of stub Component to fill in with Part(s).
Method Detail

iterator

public java.util.Iterator<Component> iterator()
Returns singleton iterator that produces Component's from input stream. Next invocation of the method returns the same object.

Specified by:
iterator in interface java.lang.Iterable<Component extends Accumulator<Part>>
Returns:
iterator over Component's.