[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] [generics] Patch: FYI: generics in java.util.zip
From: |
Tom Tromey |
Subject: |
[cp-patches] [generics] Patch: FYI: generics in java.util.zip |
Date: |
27 Sep 2005 10:46:33 -0600 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
I'm checking this in on the generics branch.
This genericizes some types in java.util.zip, as pointed out by the
new japi.
Tom
Index: ChangeLog
from Tom Tromey <address@hidden>
* java/util/zip/ZipFile.java (entries): Updated return type.
(ZipEntryEnumeration): Updated 'implements' type.
(entries): Updated type.
(ZipEntryEnumeration.elements): Likewise.
(readEntries): Updated.
(getEntries): Likewise.
(getEntry): Likewise.
(getInputStream): Likewise.
Index: java/util/zip/ZipFile.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/zip/ZipFile.java,v
retrieving revision 1.16.2.7
diff -u -r1.16.2.7 ZipFile.java
--- java/util/zip/ZipFile.java 20 Sep 2005 18:46:30 -0000 1.16.2.7
+++ java/util/zip/ZipFile.java 27 Sep 2005 16:41:39 -0000
@@ -84,7 +84,7 @@
private final RandomAccessFile raf;
// The entries of this zip file when initialized and not yet closed.
- private HashMap entries;
+ private HashMap<String, ZipEntry> entries;
private boolean closed = false;
@@ -268,7 +268,7 @@
throw new EOFException(name);
int centralOffset = readLeInt(raf, ebs);
- entries = new HashMap(count+count/2);
+ entries = new HashMap<String, ZipEntry> (count+count/2);
raf.seek(centralOffset);
byte[] buffer = new byte[16];
@@ -368,7 +368,7 @@
*
* @exception IllegalStateException when the ZipFile has already been closed
*/
- public Enumeration entries()
+ public Enumeration<ZipEntry> entries()
{
checkClosed();
@@ -388,7 +388,7 @@
* @exception IllegalStateException when the ZipFile has already been closed.
* @exception IOException when the entries could not be read.
*/
- private HashMap getEntries() throws IOException
+ private HashMap<String, ZipEntry> getEntries() throws IOException
{
synchronized(raf)
{
@@ -416,11 +416,11 @@
try
{
- HashMap entries = getEntries();
- ZipEntry entry = (ZipEntry) entries.get(name);
+ HashMap<String, ZipEntry> entries = getEntries();
+ ZipEntry entry = entries.get(name);
// If we didn't find it, maybe it's a directory.
if (entry == null && !name.endsWith("/"))
- entry = (ZipEntry) entries.get(name + '/');
+ entry = entries.get(name + '/');
return entry != null ? new ZipEntry(entry, name) : null;
}
catch (IOException ioe)
@@ -491,9 +491,9 @@
{
checkClosed();
- HashMap entries = getEntries();
+ HashMap<String, ZipEntry> entries = getEntries();
String name = entry.getName();
- ZipEntry zipEntry = (ZipEntry) entries.get(name);
+ ZipEntry zipEntry = entries.get(name);
if (zipEntry == null)
return null;
@@ -539,11 +539,11 @@
}
}
- private static class ZipEntryEnumeration implements Enumeration
+ private static class ZipEntryEnumeration implements Enumeration<ZipEntry>
{
- private final Iterator elements;
+ private final Iterator<ZipEntry> elements;
- public ZipEntryEnumeration(Iterator elements)
+ public ZipEntryEnumeration(Iterator<ZipEntry> elements)
{
this.elements = elements;
}
@@ -553,12 +553,12 @@
return elements.hasNext();
}
- public Object nextElement()
+ public ZipEntry nextElement()
{
/* We return a clone, just to be safe that the user doesn't
* change the entry.
*/
- return ((ZipEntry)elements.next()).clone();
+ return (ZipEntry) (elements.next().clone());
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] [generics] Patch: FYI: generics in java.util.zip,
Tom Tromey <=