com.varankin.io.stream
Class Chopper<Component extends Receiver<Part>,Part>

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

public final class Chopper<Component extends Receiver<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.

Author:
© 2010 Nikolai Varankine

Constructor Summary
Chopper(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

Chopper

public Chopper(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 Receiver<Part>>
Returns:
iterator over Component's.