cz.cuni.pogamut.Client
Class HistoryIterator

java.lang.Object
  extended by cz.cuni.pogamut.Client.HistoryIterator
All Implemented Interfaces:
java.util.Iterator

public class HistoryIterator
extends java.lang.Object
implements java.util.Iterator

HistoryIterator is an iterator for History
it has two kinds of next and hasNext according to the value of unique

in both cases it iterates through first batch and, after exhausting this one, proceed to next batch until it reaches the last batch or the specified depth

it iterates only through items of specified type


Field Summary
private  HistoryBatch actualBatch
          actual History Batch - for iteration through History
private  int actualDepth
          actual depth of iteration
private  MessageObject actualMessage
          necessary for unique iterator - keeps actual message
private  int depth
          identifies depth of iteration (number of batches to go through)
private  java.util.HashSet<java.lang.Integer> iteratedIDs
          necessary for unique iterator - keeps sended messages - their IDs
private  MessageType type
          type of MessageObject
private  boolean unique
          distinguish returning all messages from returning only unique messages (unique according to ID)
private  java.util.Iterator<MessageObject> valueSetIterator
          for iteration through HashMap in HistoryBatch
 
Constructor Summary
HistoryIterator(int depth, MessageType type, boolean unique, HistoryBatch actualBatch)
           
 
Method Summary
 boolean hasNext()
           
 boolean hasNextNormal()
          returns true if there is any other next item of proper type in proper depth
 boolean hasNextUnique()
          returns true if there is any next item, which was not send yet
 java.lang.Object next()
           
 java.lang.Object nextNormal()
           
 java.lang.Object nextUnique()
           
 void remove()
          Not implemented!!!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

depth

private int depth
identifies depth of iteration (number of batches to go through)


actualDepth

private int actualDepth
actual depth of iteration


unique

private boolean unique
distinguish returning all messages from returning only unique messages (unique according to ID)


type

private MessageType type
type of MessageObject


actualBatch

private HistoryBatch actualBatch
actual History Batch - for iteration through History


valueSetIterator

private java.util.Iterator<MessageObject> valueSetIterator
for iteration through HashMap in HistoryBatch


iteratedIDs

private java.util.HashSet<java.lang.Integer> iteratedIDs
necessary for unique iterator - keeps sended messages - their IDs


actualMessage

private MessageObject actualMessage
necessary for unique iterator - keeps actual message

Constructor Detail

HistoryIterator

public HistoryIterator(int depth,
                       MessageType type,
                       boolean unique,
                       HistoryBatch actualBatch)
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator
Returns:
hasNext item

next

public java.lang.Object next()
Specified by:
next in interface java.util.Iterator
Returns:
next item among searched space

hasNextNormal

public boolean hasNextNormal()
returns true if there is any other next item of proper type in proper depth

Returns:
hasNext

nextNormal

public java.lang.Object nextNormal()
Returns:
next item

hasNextUnique

public boolean hasNextUnique()
returns true if there is any next item, which was not send yet

Returns:
true if there is next item (different from previous)

nextUnique

public java.lang.Object nextUnique()

remove

public void remove()
Not implemented!!! - no use for it

Specified by:
remove in interface java.util.Iterator