/*
 * 
 * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
 * 
 * The contents of this file are subject to the Sun Community Source
 * License v3.0/Jini Technology Specific Attachment v 1.0 (the
 * "License"). You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at
 * http://wwws.sun.com/software/jini/licensing/SCSL3_JiniTSA1.html.
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the License for the specific language governing rights and limitations
 * under the License.
 * 
 * The Reference Code is Jini Technology Core Platform code, v2.0. The
 * Developer of the Reference Code is Sun Microsystems, Inc.
 * 
 * Contributor(s): Sun Microsystems, Inc.
 * 
 * The contents of this file comply with the Jini Technology Core
 * Platform Compatibility Kit, v2.0A.
 * 
 * Tester(s): Sun Microsystems, Inc.
 * 
 * Test Platform(s):
 * Java 2 SDK, Standard Edition, Version 1.4.2_03 for Solaris(TM)SPARC/x86
 * Java 2 SDK, Standard Edition, Version 1.4.2_03 for Linux (Intel x86)
 * Java 2 SDK, Standard Edition, Version 1.4.2_03 for Windows (Intel Platform)
 * 
 */
package com.sun.jini.mercury;

import java.io.IOException;
import java.util.NoSuchElementException;

import net.jini.core.event.RemoteEvent;

/** 
 * <code>EventLogIterator</code> provides an abstraction for accessing 
 * the events
 * stored on behalf of a particular registration.  The methods closely
 * resemble the <tt>java.util.iterator</tt> interface with the 
 * exception of the <code>throws</code> clauses and the additional 
 * <tt>destroy</tt> and <tt>add</tt> methods.
 *
 * The semantics for this iterator are the same as <tt>java.util.Iterator</tt>
 * in that <tt>next</tt> and <tt>remove</tt> are intended to be called
 * in pairs.
 *
 * @author Sun Microsystems, Inc.
 *
 * @since 1.1
 */
interface EventLogIterator {
    /** 
     * Store the given <tt>RemoteEvent</tt> event.
     * @throws IOException if an I/O errors occurs
     */
    void add(RemoteEvent re) throws IOException;

    /**  
     * Return true if there are any events in the collection and 
     * false otherwise.
     * @throws IOException if an I/O errors occurs
     */
    boolean hasNext() throws IOException;

    /** 
     * Return the next event in the collection. 
     * @throws IOException if an I/O errors occurs
     * @throws NoSuchElementException if there are no available
     *    <code>RemoteEvent</code>s
     * @throws ClassNotFoundException if there was a problem deserializing
     *    the stored <code>RemoteEvent</code>
     */
    RemoteEvent next() throws IOException, NoSuchElementException,
			      ClassNotFoundException;

    /** 
     * 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
     */
    void remove() throws IOException;

    /** 
     * Destroy the collection of stored events. 
     * @throws IOException if an I/O errors occurs
     */
    void destroy() throws IOException;
}

