151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/*
251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Copyright (c) 1994, 2005, Oracle and/or its affiliates. All rights reserved.
351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is free software; you can redistribute it and/or modify it
651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * under the terms of the GNU General Public License version 2 only, as
751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * published by the Free Software Foundation.  Oracle designates this
851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * particular file as subject to the "Classpath" exception as provided
951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * by Oracle in the LICENSE file that accompanied this code.
1051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
1151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is distributed in the hope that it will be useful, but WITHOUT
1251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * version 2 for more details (a copy is included in the LICENSE file that
1551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * accompanied this code).
1651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
1751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * You should have received a copy of the GNU General Public License version
1851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 2 along with this work; if not, write to the Free Software Foundation,
1951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
2151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or visit www.oracle.com if you need additional information or have any
2351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * questions.
2451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */
2551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
2651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipackage java.util;
2751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
2851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/**
2951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * An object that implements the Enumeration interface generates a
3051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * series of elements, one at a time. Successive calls to the
3151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>nextElement</code> method return successive elements of the
3251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * series.
3351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>
3451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * For example, to print all elements of a <tt>Vector&lt;E&gt;</tt> <i>v</i>:
3551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <pre>
3651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *   for (Enumeration&lt;E&gt; e = v.elements(); e.hasMoreElements();)
3751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *       System.out.println(e.nextElement());</pre>
3851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>
3951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Methods are provided to enumerate through the elements of a
4051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * vector, the keys of a hashtable, and the values in a hashtable.
4151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Enumerations are also used to specify the input streams to a
4251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>SequenceInputStream</code>.
4351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>
4451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * NOTE: The functionality of this interface is duplicated by the Iterator
4551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * interface.  In addition, Iterator adds an optional remove operation, and
4651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * has shorter method names.  New implementations should consider using
4751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Iterator in preference to Enumeration.
4851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
4951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see     java.util.Iterator
5051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see     java.io.SequenceInputStream
5151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see     java.util.Enumeration#nextElement()
5251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see     java.util.Hashtable
5351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see     java.util.Hashtable#elements()
5451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see     java.util.Hashtable#keys()
5551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see     java.util.Vector
5651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see     java.util.Vector#elements()
5751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
5851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @author  Lee Boynton
5951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since   JDK1.0
6051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */
6151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipublic interface Enumeration<E> {
6251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    /**
6351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * Tests if this enumeration contains more elements.
6451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
6551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @return  <code>true</code> if and only if this enumeration object
6651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *           contains at least one more element to provide;
6751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *          <code>false</code> otherwise.
6851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     */
6951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    boolean hasMoreElements();
7051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
7151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    /**
7251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * Returns the next element of this enumeration if this enumeration
7351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * object has at least one more element to provide.
7451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
7551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @return     the next element of this enumeration.
7651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @exception  NoSuchElementException  if no more elements exist.
7751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     */
7851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    E nextElement();
7951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski}
80