com.sun.jini.mercury
Class EventLogFactory.EventLogIteratorImpl

java.lang.Object
  extended by com.sun.jini.mercury.EventLogFactory.EventLogIteratorImpl
All Implemented Interfaces:
EventLogIterator
Enclosing class:
EventLogFactory

private static class EventLogFactory.EventLogIteratorImpl
extends Object
implements EventLogIterator

Private class which implements the EventLogIterator interface. This class delegates to an EventLog for most of its functionality.


Field Summary
private  EventLog log
          The associated EventLog for this iterator
private  Uuid uuid
          The associated Uuid for this iterator
 
Constructor Summary
EventLogFactory.EventLogIteratorImpl(Uuid id)
          Simple constructor that assigns the Uuid field to the appropriate internal field and creates a transient event log.
EventLogFactory.EventLogIteratorImpl(Uuid id, File logPath)
          Simple constructor that assigns the Uuid field to the appropriate internal field and creates a persistent EventLog object using the provided File argument.
 
Method Summary
 void add(RemoteEvent evt)
          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 init()
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uuid

private final Uuid uuid
The associated Uuid for this iterator


log

private EventLog log
The associated EventLog for this iterator

Constructor Detail

EventLogFactory.EventLogIteratorImpl

EventLogFactory.EventLogIteratorImpl(Uuid id,
                                     File logPath)
Simple constructor that assigns the Uuid field to the appropriate internal field and creates a persistent EventLog object using the provided File argument.


EventLogFactory.EventLogIteratorImpl

EventLogFactory.EventLogIteratorImpl(Uuid id)
Simple constructor that assigns the Uuid field to the appropriate internal field and creates a transient event log.

Method Detail

init

public void init()
          throws IOException
Throws:
IOException

add

public void add(RemoteEvent evt)
         throws IOException,
                IllegalArgumentException
Description copied from interface: EventLogIterator
Store the given RemoteEvent event.

Specified by:
add in interface EventLogIterator
Throws:
IOException - if an I/O errors occurs
IllegalArgumentException

hasNext

public boolean hasNext()
                throws IOException
Description copied from interface: EventLogIterator
Return true if there are any events in the collection and false otherwise.

Specified by:
hasNext in interface EventLogIterator
Throws:
IOException - if an I/O errors occurs

next

public RemoteEvent next()
                 throws IOException,
                        ClassNotFoundException,
                        NoSuchElementException
Description copied from interface: EventLogIterator
Return the next event in the collection.

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

remove

public void remove()
            throws IOException,
                   IllegalStateException
Description copied from interface: EventLogIterator
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.

Specified by:
remove in interface EventLogIterator
Throws:
IOException - if an I/O errors occurs
IllegalStateException

readAhead

public RemoteEventData[] readAhead(int maxEvents)
                            throws IOException,
                                   ClassNotFoundException
Description copied from interface: EventLogIterator
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).

Specified by:
readAhead in interface EventLogIterator
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

moveAhead

public void moveAhead(Object cookie)
               throws IOException
Description copied from interface: EventLogIterator
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.

Specified by:
moveAhead in interface EventLogIterator
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

public void destroy()
             throws IOException
Description copied from interface: EventLogIterator
Destroy the collection of stored events.

Specified by:
destroy in interface EventLogIterator
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.