//============================================================================== // ZIterator.java //============================================================================== package tribble.search.zip; // System imports import java.lang.String; import java.util.Enumeration; import java.util.Vector; // Local imports // (None) /******************************************************************************* * Zipfile entry iterator. * *

* This enumeration allows for iterating over all the entries found by a zipfile * searcher. * * * @version $Revision: 1.5 $ $Date: 2001/06/19 16:12:25 $ * @since 2001-05-18 * @author * David R. Tribble * (david@tribble.com). *
* Copyright * ©2001 by David R. Tribble, all rights reserved.
* * @see ZArchive */ public class ZIterator implements Enumeration { // Identification /** Revision information. */ static final String REV = "@(#)tribble/search/zip/ZIterator.java $Revision: 1.5 $ $Date: 2001/06/19 16:12:25 $\n"; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Public constants /** Series number. */ public static final int SERIES = 200; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Protected variables /** Zipfile searcher. */ protected ZArchive m_searcher; /** List of found zipfile entries ({@link ZFile} objects). */ protected Vector m_list; /* Position of the next list entry. */ protected int m_pos; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 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-18 */ public boolean hasMoreElements() //implements Enumeration { // Check if there are any entries left in the list return (m_pos < m_list.size()); } /*************************************************************************** * Retrieve the next element from this enumeration. * * @return * A {@link ZFile} object corresponding to a zipfile entry found by a * zipfile searcher. Returns null if there are no more entries left in the * list. * * @since 1.1, 2001-05-18 */ public Object nextElement() //implements Enumeration { // Retrieve the next zipfile entry in the list if (m_pos < m_list.size()) return (m_list.elementAt(m_pos++)); else return (null); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Protected constructors /*************************************************************************** * Constructor. * * @param searcher * The zipfile searcher that created this iterator. * * @param entries * A vector of {@link ZFile} zipfile entries to iterate upon. * * @since 1.2, 2001-06-14 */ protected ZIterator(ZArchive seacher, Vector entries) { // Establish the zipfile searcher and entries for this iterator m_searcher = seacher; m_list = entries; m_pos = 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Private constructors /*************************************************************************** * Default constructor. * * @since 1.1, 2001-05-18 */ private ZIterator() { // Do nothing } } // End ZIterator.java