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 |
|
|
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]; |
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 |
|
|
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 |
{ |
{ |
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) |
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 |
|
|
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 |
} |
} |
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 |
|
|