/*
 * 
 * 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.outrigger;

import java.rmi.RemoteException;

import net.jini.core.entry.Entry;
import net.jini.core.entry.UnusableEntryException;

/**
 * Interface for the iterators returned by the <code>contents()</code>
 * method of <code>JavaSpaceAdmin</code>.  Note
 * <code>AdminIterator</code>s do not survive restarts of the
 * underlying space.
 * <p>
 *
 * @author Sun Microsystems, Inc.
 *
 * @see JavaSpaceAdmin 
 */
public interface AdminIterator {
    /**
     * Return the next entry in the sequence.  Returns <code>null</code>
     * if there are no more matching entries in the space.
     * <p>
     * This method is idempotent in the face of <code>RemoteException</code>s.
     *
     * @throws UnusableEntryException if the field of next entry in
     * sequence can't be deserialized (usually this is because the class
     * in question could not be loaded).
     */
    public Entry next()	throws UnusableEntryException, RemoteException;

    /**
     * The effect of this call depends on the most recent call to
     * <code>next()</code>:
     * <ul>
     * <li> If the last call to <code>next()</code> returned an
     * <code>Entry</code> that entry will be removed from the space.
     * <p>
     * <li> If the last call to <code>next()</code> threw a
     * <code>UnusableEntryException</code> the <code>Entry</code> that
     * could not be deserialized will be removed from the space.
     * <p>
     * <li> If the last call to <code>next()</code> returned
     * <code>null</code>, threw a <code>RemoteException</code>, or
     * <code>next()</code> has not yet been called on this iterator a
     * <code>IllegalStateException</code> will be thrown and no entry will
     * be removed.
     * <p>
     * </ul>
     * This method is idempotent in the face of
     * <code>RemoteException</code>.
     * <p>
     * @throws IllegalStateException if <code>next()</code> has not be
     * called on this iterator, or the last invocation of
     * <code>next()</code> returned <code>null</code> or threw
     * <code>RemoteException</code>.     
     */
    public void delete() throws RemoteException;

    /**
     * Tell the server that this iterator is no longer in use.  All
     * operations on a closed iterator  have undefined results, except  
     * the <code>close()</code> method.
     * <p> 
     * This method is idempotent in the face of <code>RemoteException</code>.
     */
    public void close() throws RemoteException;
}
