//============================================================================== // FIterator.java //============================================================================== package tribble.search.disk; // System imports import java.lang.Error; import java.lang.Object; import java.util.Enumeration; import java.util.Vector; // Local imports // (None) /******************************************************************************* * File entry list iterator/enumeration. * * @version $Revision: 1.3 $ $Date: 2001/06/18 03:04:28 $ * @since 2001-05-12 * @author * David R. Tribble * (david@tribble.com). *
* Copyright * ©2001 by David R. Tribble, all rights reserved.
* * @see FDirectory */ public class FIterator implements Enumeration { // Identification /** Revision information. */ static final String REV = "@(#)tribble/search/disk/FIterator.java $Revision: 1.3 $ $Date: 2001/06/18 03:04:28 $\n"; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Public constants /** Series number. */ public static final int SERIES = 200; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Private variables /** * File entries being iterated over. * Contains a list of {@link FFile} objects. */ private Vector m_list; /** Next file entry index. */ private int m_pos; /** File searcher that created this iterator. */ private FDirectory m_search; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Public methods /*************************************************************************** * Determine if there are any more entries left in this enumeration. * * @return * True if there are entries left to iterate upon, otherwise false. * * @since 1.1, 2001-05-12 */ public boolean hasMoreElements() // implements Enumeration { // Check for any remaining entries in the list return (m_pos < m_list.size()); } /*************************************************************************** * Retrieve the next element from this enumeration. * * @return * A {@link FFile} object corresponding to a directory file found by a * directory searcher. Returns null if there are no more entries left in the * list. * * @since 1.1, 2001-05-12 */ public Object nextElement() // implements Enumeration { // Get the next file entry in the list if (m_pos < m_list.size()) return (m_list.elementAt(m_pos++)); else return (null); // Or throw an exception? } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Protected constructors /*************************************************************************** * Constructor. * * @param searcher * The disk directory searcher that created this iterator. * * @param entries * A vector of {@link FFile} file entries to iterate upon. * * @since 1.2, 2001-06-15 */ protected FIterator(FDirectory searcher, Vector list) { // Establish a new entry list to iterate upon m_list = list; m_pos = 0; m_search = searcher; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Private constructors /*************************************************************************** * Default constructor. * * @since 1.1, 2001-05-12 */ private FIterator() { // Do nothing } } // End FIterator.java