home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / util / Enumeration.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  2.5 KB  |  74 lines

  1. /*
  2.  * @(#)Enumeration.java    1.15 98/03/18
  3.  *
  4.  * Copyright 1994-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.util;
  16.  
  17. /**
  18.  * An object that implements the Enumeration interface generates a 
  19.  * series of elements, one at a time. Successive calls to the 
  20.  * <code>nextElement</code> method return successive elements of the 
  21.  * series. 
  22.  * <p>
  23.  * For example, to print all elements of a vector <i>v</i>:
  24.  * <blockquote><pre>
  25.  *     for (Enumeration e = v.elements() ; e.hasMoreElements() ;) {
  26.  *         System.out.println(e.nextElement());<br>
  27.  *     }
  28.  * </pre></blockquote>
  29.  * <p>
  30.  * Methods are provided to enumerate through the elements of a 
  31.  * vector, the keys of a hashtable, and the values in a hashtable. 
  32.  * Enumerations are also used to specify the input streams to a 
  33.  * <code>SequenceInputStream</code>. 
  34.  * <p>
  35.  * NOTE: The functionality of this interface is duplicated by the Iterator
  36.  * interface.  In addition, Iterator adds an optional remove operation, and
  37.  * has shorter method names.  New implementations should consider using
  38.  * Iterator in preference to Enumeration.
  39.  *
  40.  * @see     java.util.Iterator
  41.  * @see     java.io.SequenceInputStream
  42.  * @see     java.util.Enumeration#nextElement()
  43.  * @see     java.util.Hashtable
  44.  * @see     java.util.Hashtable#elements()
  45.  * @see     java.util.Hashtable#keys()
  46.  * @see     java.util.Vector
  47.  * @see     java.util.Vector#elements()
  48.  *
  49.  * @author  Lee Boynton
  50.  * @version 1.15, 03/18/98
  51.  * @since   JDK1.0
  52.  */
  53. public interface Enumeration {
  54.     /**
  55.      * Tests if this enumeration contains more elements.
  56.      *
  57.      * @return  <code>true</code> if and only if this enumeration object 
  58.      *           contains at least one more element to provide;
  59.      *          <code>false</code> otherwise.
  60.      * @since   JDK1.0
  61.      */
  62.     boolean hasMoreElements();
  63.  
  64.     /**
  65.      * Returns the next element of this enumeration if this enumeration 
  66.      * object has at least one more element to provide.
  67.      *
  68.      * @return     the next element of this enumeration. 
  69.      * @exception  NoSuchElementException  if no more elements exist.
  70.      * @since      JDK1.0
  71.      */
  72.     Object nextElement();
  73. }
  74.