From f7dbd56c9a1e2605f54a05c2f613cf086f32634b Mon Sep 17 00:00:00 2001 From: Michael Koch Date: Mon, 31 May 2004 22:14:37 +0000 Subject: [PATCH] InflaterInputStream.java: Merged more with Classpath version. 2004-06-01 Michael Koch * java/util/zip/InflaterInputStream.java: Merged more with Classpath version. * java/util/zip/ZipOutputStream.java (): Renamed enum to e to removed Java 1.5 keyword usage. From-SVN: r82509 --- libjava/ChangeLog | 7 ++ .../java/util/zip/InflaterInputStream.java | 86 +++++++++++++------ libjava/java/util/zip/ZipOutputStream.java | 6 +- 3 files changed, 72 insertions(+), 27 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index b6e4c8bb5d5..d0b99bf9087 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,10 @@ +2004-06-01 Michael Koch + + * java/util/zip/InflaterInputStream.java: Merged more with Classpath + version. + * java/util/zip/ZipOutputStream.java (): Renamed enum to e to removed + Java 1.5 keyword usage. + 2004-05-31 Olga Rodimina * javax/swing/plaf/basic/BasicMenuUI.java: diff --git a/libjava/java/util/zip/InflaterInputStream.java b/libjava/java/util/zip/InflaterInputStream.java index a8a7eeb7e1f..9fac83fc6dc 100644 --- a/libjava/java/util/zip/InflaterInputStream.java +++ b/libjava/java/util/zip/InflaterInputStream.java @@ -1,5 +1,6 @@ /* InflaterInputStream.java - Input stream filter for decompressing - Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 + Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -54,7 +55,20 @@ import java.io.IOException; */ public class InflaterInputStream extends FilterInputStream { + /** + * Decompressor for this filter + */ + protected Inflater inf; + + /** + * Byte array used as a buffer + */ + protected byte[] buf; + /** + * Size of buffer + */ + protected int len; protected void fill () throws IOException { @@ -63,26 +77,45 @@ public class InflaterInputStream extends FilterInputStream inf.setInput(buf, 0, len); } - public InflaterInputStream (InputStream in) + /** + * Create an InflaterInputStream with the default decompresseor + * and a default buffer size. + * + * @param in the InputStream to read bytes from + */ + public InflaterInputStream(InputStream in) { this (in, new Inflater (), 512); } - public InflaterInputStream (InputStream in, Inflater infl) + /** + * Create an InflaterInputStream with the specified decompresseor + * and a default buffer size. + * + * @param in the InputStream to read bytes from + * @param inf the decompressor used to decompress data read from in + */ + public InflaterInputStream(InputStream in, Inflater inf) { - this (in, infl, 512); + this (in, inf, 512); } - public InflaterInputStream (InputStream in, Inflater inf, int size) + /** + * Create an InflaterInputStream with the specified decompresseor + * and a specified buffer size. + * + * @param in the InputStream to read bytes from + * @param inf the decompressor used to decompress data read from in + * @param size size of the buffer to use + */ + public InflaterInputStream(InputStream in, Inflater inf, int size) { - super (in); + super(in); if (in == null) throw new NullPointerException ("in may not be null"); - if (inf == null) throw new NullPointerException ("inf may not be null"); - if (size < 0) throw new IllegalArgumentException ("size may not be negative"); @@ -99,7 +132,15 @@ public class InflaterInputStream extends FilterInputStream return r; } - public int read (byte[] buf, int off, int len) throws IOException + + /** + * Decompresses data into the byte array + * + * @param b the array to read and decompress data into + * @param off the offset indicating where the data should be placed + * @param len the number of bytes to decompress + */ + public int read(byte[] b, int off, int len) throws IOException { if (inf == null) throw new IOException ("stream closed"); @@ -113,9 +154,10 @@ public class InflaterInputStream extends FilterInputStream { if (inf.needsInput()) fill (); + try { - count = inf.inflate(buf, off, len); + count = inf.inflate(b, off, len); if (count == 0) { if (this.len == -1) @@ -126,10 +168,10 @@ public class InflaterInputStream extends FilterInputStream if (inf.needsDictionary()) throw new ZipException ("Inflater needs Dictionary"); } - } - catch (DataFormatException dfe) + } + catch (DataFormatException dfe) { - throw new ZipException (dfe.getMessage()); + throw new ZipException(dfe.getMessage()); } } return count; @@ -150,7 +192,12 @@ public class InflaterInputStream extends FilterInputStream return inf.finished () ? 0 : 1; } - public long skip (long n) throws IOException + /** + * Skip specified number of bytes of uncompressed data + * + * @param n number of bytes to skip + */ + public long skip(long n) throws IOException { if (inf == null) throw new IOException ("stream closed"); @@ -173,14 +220,5 @@ public class InflaterInputStream extends FilterInputStream } return s; - } - - // Buffer for delivering uncompressed data to inflater. - protected byte[] buf; - - // Inflater used to decompress data. - protected Inflater inf; - - // Number of read bytes in buf. - protected int len; + } } diff --git a/libjava/java/util/zip/ZipOutputStream.java b/libjava/java/util/zip/ZipOutputStream.java index 7d36e45214d..9c3a2c81908 100644 --- a/libjava/java/util/zip/ZipOutputStream.java +++ b/libjava/java/util/zip/ZipOutputStream.java @@ -338,10 +338,10 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant int numEntries = 0; int sizeEntries = 0; - Enumeration enum = entries.elements(); - while (enum.hasMoreElements()) + Enumeration e = entries.elements(); + while (e.hasMoreElements()) { - ZipEntry entry = (ZipEntry) enum.nextElement(); + ZipEntry entry = (ZipEntry) e.nextElement(); int method = entry.getMethod(); writeLeInt(CENSIG); -- 2.30.2