com.sun.jini.mercury
Interface EventLogIterator

All Known Implementing Classes:
EventLogFactory.EventLogIteratorImpl

interface EventLogIterator

EventLogIterator provides an abstraction for accessing the events stored on behalf of a particular registration. The methods closely resemble the java.util.iterator interface with the exception of the throws clauses and the additional destroy and add methods. The semantics for this iterator are the same as java.util.Iterator in that next and remove are intended to be called in pairs.

Since:
1.1
Author:
Sun Microsystems, Inc.

Method Summary
 void add(RemoteEvent re)
          Store the given RemoteEvent event.
 void destroy()
          Destroy the collection of stored events.
 boolean hasNext()
          Return true if there are any events in the collection and false otherwise.
 void moveAhead(Object cookie)
          Effectively removes the last set of read events from the log.
 RemoteEvent next()
          Return the next event in the collection.
 RemoteEventData[] readAhead(int maxEvents)
          Return an array of RemoteEventData with a limit of maxEvents elements.
 void remove()
          Remove the event at the iterator's current cursor position.
 

Method Detail

add

void add(RemoteEvent re)
         throws IOException
Store the given RemoteEvent event.

Throws:
IOException - if an I/O errors occurs

hasNext

boolean hasNext()
                throws IOException
Return true if there are any events in the collection and false otherwise.

Throws:
IOException - if an I/O errors occurs

next

RemoteEvent next()
                 throws IOException,
                        NoSuchElementException,
                        ClassNotFoundException
Return the next event in the collection.

Throws:
IOException - if an I/O errors occurs
NoSuchElementException - if there are no available RemoteEvents
ClassNotFoundException - if there was a problem deserializing the stored RemoteEvent

remove

void remove()
            throws IOException
Remove the event at the iterator's current cursor position. It is expected that the cursor position will be updated to point to the next unread event object, if any, upon return from this method.

Throws:
IOException - if an I/O errors occurs

readAhead

RemoteEventData[] readAhead(int maxEvents)
                            throws IOException,
                                   ClassNotFoundException
Return an array of RemoteEventData with a limit of maxEvents elements. Note that readAhead is meant to be used in conjunction with moveAhead. Subsequent calls to readAhead with the same argument value will return the same set of events until moveAhead is called, which actually updates the read pointer to the next unread event (indicating that the previously read events were successfully processed).

Parameters:
maxEvents - maximum number of events/elements to return
Throws:
IOException - if an I/O error occurs
ClassNotFoundException - if a class for the serialized object could not be found
NoSuchElementException - if no event is available

moveAhead

void moveAhead(Object cookie)
               throws IOException
Effectively removes the last set of read events from the log. It does this by advancing the read pointer to the next available event after the event associated with the provided cookie object.

Parameters:
cookie - object associated with event to read past. This object should have been obtained from a previous call to readAhead on this event log.
Throws:
IOException - if there was a problem advancing the read pointer.

destroy

void destroy()
             throws IOException
Destroy the collection of stored events.

Throws:
IOException - if an I/O errors occurs


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.