org.apache.camel.util
Class GroupIterator

java.lang.Object
  extended by org.apache.camel.util.GroupIterator
All Implemented Interfaces:
Closeable, Iterator<Object>

public final class GroupIterator
extends Object
implements Iterator<Object>, Closeable

Group based Iterator which groups the given Iterator a number of times and then return a combined response as a String.

This implementation uses as internal byte array buffer, to combine the response. The token is inserted between the individual parts.

For example if you group by new line, then a new line token is inserted between the lines.


Constructor Summary
GroupIterator(CamelContext camelContext, Iterator<?> it, String token, int group)
          Creates a new group iterator
 
Method Summary
 void close()
           
 boolean hasNext()
           
 Object next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupIterator

public GroupIterator(CamelContext camelContext,
                     Iterator<?> it,
                     String token,
                     int group)
Creates a new group iterator

Parameters:
camelContext - the camel context
it - the iterator to group
token - then token used to separate between the parts, use null to not add the token
group - number of parts to group together
Throws:
IllegalArgumentException - is thrown if group is not a positive number
Method Detail

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<Object>

next

public Object next()
Specified by:
next in interface Iterator<Object>

remove

public void remove()
Specified by:
remove in interface Iterator<Object>


Apache CAMEL