/[classpath]/classpath/java/util/zip/ZipFile.java
ViewVC logotype

Diff of /classpath/java/util/zip/ZipFile.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16.2.7 by gnu_andrew, Tue Sep 20 18:46:30 2005 UTC revision 1.16.2.8 by tromey, Tue Sep 27 16:52:59 2005 UTC
# Line 84  public class ZipFile implements ZipConst Line 84  public class ZipFile implements ZipConst
84    private final RandomAccessFile raf;    private final RandomAccessFile raf;
85    
86    // The entries of this zip file when initialized and not yet closed.    // The entries of this zip file when initialized and not yet closed.
87    private HashMap entries;    private HashMap<String, ZipEntry> entries;
88    
89    private boolean closed = false;    private boolean closed = false;
90    
# Line 268  public class ZipFile implements ZipConst Line 268  public class ZipFile implements ZipConst
268        throw new EOFException(name);        throw new EOFException(name);
269      int centralOffset = readLeInt(raf, ebs);      int centralOffset = readLeInt(raf, ebs);
270    
271      entries = new HashMap(count+count/2);      entries = new HashMap<String, ZipEntry> (count+count/2);
272      raf.seek(centralOffset);      raf.seek(centralOffset);
273            
274      byte[] buffer = new byte[16];      byte[] buffer = new byte[16];
# Line 368  public class ZipFile implements ZipConst Line 368  public class ZipFile implements ZipConst
368     *     *
369     * @exception IllegalStateException when the ZipFile has already been closed     * @exception IllegalStateException when the ZipFile has already been closed
370     */     */
371    public Enumeration entries()    public Enumeration<ZipEntry> entries()
372    {    {
373      checkClosed();      checkClosed();
374            
# Line 388  public class ZipFile implements ZipConst Line 388  public class ZipFile implements ZipConst
388     * @exception IllegalStateException when the ZipFile has already been closed.     * @exception IllegalStateException when the ZipFile has already been closed.
389     * @exception IOException when the entries could not be read.     * @exception IOException when the entries could not be read.
390     */     */
391    private HashMap getEntries() throws IOException    private HashMap<String, ZipEntry> getEntries() throws IOException
392    {    {
393      synchronized(raf)      synchronized(raf)
394        {        {
# Line 416  public class ZipFile implements ZipConst Line 416  public class ZipFile implements ZipConst
416    
417      try      try
418        {        {
419          HashMap entries = getEntries();          HashMap<String, ZipEntry> entries = getEntries();
420          ZipEntry entry = (ZipEntry) entries.get(name);          ZipEntry entry = entries.get(name);
421          // If we didn't find it, maybe it's a directory.          // If we didn't find it, maybe it's a directory.
422          if (entry == null && !name.endsWith("/"))          if (entry == null && !name.endsWith("/"))
423              entry = (ZipEntry) entries.get(name + '/');            entry = entries.get(name + '/');
424          return entry != null ? new ZipEntry(entry, name) : null;          return entry != null ? new ZipEntry(entry, name) : null;
425        }        }
426      catch (IOException ioe)      catch (IOException ioe)
# Line 491  public class ZipFile implements ZipConst Line 491  public class ZipFile implements ZipConst
491    {    {
492      checkClosed();      checkClosed();
493    
494      HashMap entries = getEntries();      HashMap<String, ZipEntry> entries = getEntries();
495      String name = entry.getName();      String name = entry.getName();
496      ZipEntry zipEntry = (ZipEntry) entries.get(name);      ZipEntry zipEntry = entries.get(name);
497      if (zipEntry == null)      if (zipEntry == null)
498        return null;        return null;
499    
# Line 539  public class ZipFile implements ZipConst Line 539  public class ZipFile implements ZipConst
539        }        }
540    }    }
541        
542    private static class ZipEntryEnumeration implements Enumeration    private static class ZipEntryEnumeration implements Enumeration<ZipEntry>
543    {    {
544      private final Iterator elements;      private final Iterator<ZipEntry> elements;
545    
546      public ZipEntryEnumeration(Iterator elements)      public ZipEntryEnumeration(Iterator<ZipEntry> elements)
547      {      {
548        this.elements = elements;        this.elements = elements;
549      }      }
# Line 553  public class ZipFile implements ZipConst Line 553  public class ZipFile implements ZipConst
553        return elements.hasNext();        return elements.hasNext();
554      }      }
555    
556      public Object nextElement()      public ZipEntry nextElement()
557      {      {
558        /* We return a clone, just to be safe that the user doesn't        /* We return a clone, just to be safe that the user doesn't
559         * change the entry.           * change the entry.  
560         */         */
561        return ((ZipEntry)elements.next()).clone();        return (ZipEntry) (elements.next().clone());
562      }      }
563    }    }
564    

Legend:
Removed from v.1.16.2.7  
changed lines
  Added in v.1.16.2.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26