harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r556570 [2/3] - in /harmony/enhanced/classlib/trunk/modules/archive/src/main/java: java/util/jar/ java/util/zip/ org/apache/harmony/archive/internal/nls/ org/apache/harmony/archive/util/
Date Mon, 16 Jul 2007 09:22:24 GMT
Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java?view=diff&rev=556570&r1=556569&r2=556570
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java Mon Jul 16 02:22:19 2007
@@ -17,7 +17,6 @@
 
 package java.util.zip;
 
-
 import java.io.FilterOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -30,154 +29,154 @@
  * Deflater.
  */
 public class DeflaterOutputStream extends FilterOutputStream {
-	static final int BUF_SIZE = 512;
+    static final int BUF_SIZE = 512;
 
-	protected byte[] buf;
+    protected byte[] buf;
 
-	protected Deflater def;
+    protected Deflater def;
 
-	boolean done = false;
+    boolean done = false;
 
-	/**
-	 * Constructs a new DeflaterOutputStream instance using os as the underlying
-	 * stream. The provided Deflater instance will be used to compress data.
-	 * 
-	 * @param os
-	 *            OutputStream to receive compressed data
-	 * @param def
-	 *            Deflater to perform compression
-	 */
-	public DeflaterOutputStream(OutputStream os, Deflater def) {
-		this(os, def, BUF_SIZE);
-	}
-
-	/**
-	 * Constructs a new DeflaterOutputStream instance using os as the underlying
-	 * stream.
-	 * 
-	 * @param os
-	 *            OutputStream to receive compressed data
-	 */
-	public DeflaterOutputStream(OutputStream os) {
-		this(os, new Deflater());
-	}
-
-	/**
-	 * Constructs a new DeflaterOutputStream instance using os as the underlying
-	 * stream. The provided Deflater instance will be used to compress data. The
-	 * internal buffer for storing compressed data will be of size bsize.
-	 * 
-	 * @param os
-	 *            OutputStream to receive compressed data
-	 * @param def
-	 *            Deflater to perform compression
-	 * @param bsize
-	 *            size of internal compression buffer
-	 */
-	public DeflaterOutputStream(OutputStream os, Deflater def, int bsize) {
-		super(os);
-		if (os == null || def == null) {
+    /**
+     * Constructs a new DeflaterOutputStream instance using os as the underlying
+     * stream. The provided Deflater instance will be used to compress data.
+     * 
+     * @param os
+     *            OutputStream to receive compressed data
+     * @param def
+     *            Deflater to perform compression
+     */
+    public DeflaterOutputStream(OutputStream os, Deflater def) {
+        this(os, def, BUF_SIZE);
+    }
+
+    /**
+     * Constructs a new DeflaterOutputStream instance using os as the underlying
+     * stream.
+     * 
+     * @param os
+     *            OutputStream to receive compressed data
+     */
+    public DeflaterOutputStream(OutputStream os) {
+        this(os, new Deflater());
+    }
+
+    /**
+     * Constructs a new DeflaterOutputStream instance using os as the underlying
+     * stream. The provided Deflater instance will be used to compress data. The
+     * internal buffer for storing compressed data will be of size bsize.
+     * 
+     * @param os
+     *            OutputStream to receive compressed data
+     * @param def
+     *            Deflater to perform compression
+     * @param bsize
+     *            size of internal compression buffer
+     */
+    public DeflaterOutputStream(OutputStream os, Deflater def, int bsize) {
+        super(os);
+        if (os == null || def == null) {
             throw new NullPointerException();
         }
-		if (bsize <= 0) {
+        if (bsize <= 0) {
             throw new IllegalArgumentException();
         }
-		this.def = def;
-		buf = new byte[bsize];
-	}
-
-	/**
-	 * Compress the data in the input buffer and write it to the underlying
-	 * stream.
-	 * 
-	 * @exception java.io.IOException
-	 *                If an error occurs during deflation.
-	 */
-	protected void deflate() throws IOException {
-		int x = 0;
-		do {
-			x = def.deflate(buf);
-			out.write(buf, 0, x);
-		} while (!def.needsInput());
-	}
-
-	/**
-	 * Writes any unwritten compressed data to the underlying stream, the closes
-	 * all underlying streams. This stream can no longer be used after close()
-	 * has been called.
-	 * 
-	 * @exception java.io.IOException
-	 *                If an error occurs during close.
-	 */
-	@Override
+        this.def = def;
+        buf = new byte[bsize];
+    }
+
+    /**
+     * Compress the data in the input buffer and write it to the underlying
+     * stream.
+     * 
+     * @exception java.io.IOException
+     *                If an error occurs during deflation.
+     */
+    protected void deflate() throws IOException {
+        int x = 0;
+        do {
+            x = def.deflate(buf);
+            out.write(buf, 0, x);
+        } while (!def.needsInput());
+    }
+
+    /**
+     * Writes any unwritten compressed data to the underlying stream, the closes
+     * all underlying streams. This stream can no longer be used after close()
+     * has been called.
+     * 
+     * @exception java.io.IOException
+     *                If an error occurs during close.
+     */
+    @Override
     public void close() throws IOException {
-		if (!def.finished()) {
+        if (!def.finished()) {
             finish();
         }
-		def.end();
-		out.close();
-	}
-
-	/**
-	 * Write any unwritten data to the underlying stream. Do not close the
-	 * stream. This allows subsequent Deflater's to write to the same stream.
-	 * This Deflater cannot be used again.
-	 * 
-	 * @exception java.io.IOException
-	 *                If an error occurs.
-	 */
-	public void finish() throws IOException {
-		if (done) {
+        def.end();
+        out.close();
+    }
+
+    /**
+     * Write any unwritten data to the underlying stream. Do not close the
+     * stream. This allows subsequent Deflater's to write to the same stream.
+     * This Deflater cannot be used again.
+     * 
+     * @exception java.io.IOException
+     *                If an error occurs.
+     */
+    public void finish() throws IOException {
+        if (done) {
             return;
         }
-		def.finish();
-		int x = 0;
-		while (!def.finished()) {
-			if (def.needsInput()) {
+        def.finish();
+        int x = 0;
+        while (!def.finished()) {
+            if (def.needsInput()) {
                 def.setInput(buf, 0, 0);
             }
-			x = def.deflate(buf);
-			out.write(buf, 0, x);
-		}
-		done = true;
-	}
+            x = def.deflate(buf);
+            out.write(buf, 0, x);
+        }
+        done = true;
+    }
 
-	@Override
+    @Override
     public void write(int i) throws IOException {
-		byte[] b = new byte[1];
-		b[0] = (byte) i;
-		write(b, 0, 1);
-	}
-
-	/**
-	 * Compress nbytes of data from buf starting at off and write it to the
-	 * underlying stream.
-	 * 
-	 * @param buf
-	 *            Buffer of data to compress
-	 * @param off
-	 *            offset in buffer to extract data from
-	 * @param nbytes
-	 *            Number of bytes of data to compress and write
-	 * 
-	 * @exception java.io.IOException
-	 *                If an error occurs during writing.
-	 */
-	@Override
+        byte[] b = new byte[1];
+        b[0] = (byte) i;
+        write(b, 0, 1);
+    }
+
+    /**
+     * Compress nbytes of data from buf starting at off and write it to the
+     * underlying stream.
+     * 
+     * @param buf
+     *            Buffer of data to compress
+     * @param off
+     *            offset in buffer to extract data from
+     * @param nbytes
+     *            Number of bytes of data to compress and write
+     * 
+     * @exception java.io.IOException
+     *                If an error occurs during writing.
+     */
+    @Override
     public void write(byte[] buffer, int off, int nbytes) throws IOException {
-		if (done) {
+        if (done) {
             throw new IOException(Messages.getString("archive.26")); //$NON-NLS-1$
         }
-		// avoid int overflow, check null buf
-		if (off <= buffer.length && nbytes >= 0 && off >= 0
-				&& buffer.length - off >= nbytes) {
-			if (!def.needsInput()) {
+        // avoid int overflow, check null buf
+        if (off <= buffer.length && nbytes >= 0 && off >= 0
+                && buffer.length - off >= nbytes) {
+            if (!def.needsInput()) {
                 throw new IOException();
             }
-			def.setInput(buffer, off, nbytes);
-			deflate();
-		} else {
+            def.setInput(buffer, off, nbytes);
+            deflate();
+        } else {
             throw new ArrayIndexOutOfBoundsException();
         }
-	}
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java?view=diff&rev=556570&r1=556569&r2=556570
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java Mon Jul 16 02:22:19 2007
@@ -17,7 +17,6 @@
 
 package java.util.zip;
 
-
 import java.io.EOFException;
 import java.io.IOException;
 import java.io.InputStream;
@@ -28,181 +27,182 @@
  * The GZIPInputStream class is used to read data stored in the GZIP format.
  */
 public class GZIPInputStream extends java.util.zip.InflaterInputStream {
-	protected CRC32 crc = new CRC32();
+    protected CRC32 crc = new CRC32();
 
-	protected boolean eos = false;
+    protected boolean eos = false;
 
-	public final static int GZIP_MAGIC = 0x8b1f;
+    public final static int GZIP_MAGIC = 0x8b1f;
 
-	private static final int FHCRC = 2;
+    private static final int FHCRC = 2;
 
-	private static final int FEXTRA = 4;
-
-	private static final int FNAME = 8;
-
-	private static final int FCOMMENT = 16;
-
-	/**
-	 * Construct a GZIPInputStream to read from GZIP data from the underlying
-	 * stream
-	 * 
-	 * @param is
-	 *            InputStream to read data from
-	 */
-	public GZIPInputStream(InputStream is) throws IOException {
-		this(is, BUF_SIZE);
-	}
-
-	/**
-	 * Construct a GZIPInputStream to read from GZIP data from the underlying
-	 * stream. Set the internal buffer size to size
-	 * 
-	 * @param is
-	 *            InputStream to read data from
-	 * @param size
-	 *            Internal read buffer size
-	 */
-	public GZIPInputStream(InputStream is, int size) throws IOException {
-		super(is, new Inflater(true), size);
-		byte[] header = new byte[10];
-		readFully(header, 0, header.length);
-		if (getShort(header, 0) != GZIP_MAGIC) {
+    private static final int FEXTRA = 4;
+
+    private static final int FNAME = 8;
+
+    private static final int FCOMMENT = 16;
+
+    /**
+     * Construct a GZIPInputStream to read from GZIP data from the underlying
+     * stream
+     * 
+     * @param is
+     *            InputStream to read data from
+     */
+    public GZIPInputStream(InputStream is) throws IOException {
+        this(is, BUF_SIZE);
+    }
+
+    /**
+     * Construct a GZIPInputStream to read from GZIP data from the underlying
+     * stream. Set the internal buffer size to size
+     * 
+     * @param is
+     *            InputStream to read data from
+     * @param size
+     *            Internal read buffer size
+     */
+    public GZIPInputStream(InputStream is, int size) throws IOException {
+        super(is, new Inflater(true), size);
+        byte[] header = new byte[10];
+        readFully(header, 0, header.length);
+        if (getShort(header, 0) != GZIP_MAGIC) {
             throw new IOException(Messages.getString("archive.1F")); //$NON-NLS-1$;
         }
-		int flags = header[3];
-		boolean hcrc = (flags & FHCRC) != 0;
-		if (hcrc) {
+        int flags = header[3];
+        boolean hcrc = (flags & FHCRC) != 0;
+        if (hcrc) {
             crc.update(header, 0, header.length);
         }
-		if ((flags & FEXTRA) != 0) {
-			readFully(header, 0, 2);
-			if (hcrc) {
+        if ((flags & FEXTRA) != 0) {
+            readFully(header, 0, 2);
+            if (hcrc) {
                 crc.update(header, 0, 2);
             }
-			int length = getShort(header, 0);
-			while (length > 0) {
-				int max = length > buf.length ? buf.length : length;
-				int result = in.read(buf, 0, max);
-				if (result == -1) {
+            int length = getShort(header, 0);
+            while (length > 0) {
+                int max = length > buf.length ? buf.length : length;
+                int result = in.read(buf, 0, max);
+                if (result == -1) {
                     throw new EOFException();
                 }
-				if (hcrc) {
+                if (hcrc) {
                     crc.update(buf, 0, result);
                 }
-				length -= result;
-			}
-		}
-		if ((flags & FNAME) != 0) {
+                length -= result;
+            }
+        }
+        if ((flags & FNAME) != 0) {
             readZeroTerminated(hcrc);
         }
-		if ((flags & FCOMMENT) != 0) {
+        if ((flags & FCOMMENT) != 0) {
             readZeroTerminated(hcrc);
         }
-		if (hcrc) {
-			readFully(header, 0, 2);
-			int crc16 = getShort(header, 0);
-			if ((crc.getValue() & 0xffff) != crc16) {
+        if (hcrc) {
+            readFully(header, 0, 2);
+            int crc16 = getShort(header, 0);
+            if ((crc.getValue() & 0xffff) != crc16) {
                 throw new IOException(Messages.getString("archive.20")); //$NON-NLS-1$
             }
-			crc.reset();
-		}
-	}
-
-	private long getLong(byte[] buffer, int off) {
-		long l = 0;
-		l |= (buffer[off] & 0xFF);
-		l |= (buffer[off + 1] & 0xFF) << 8;
-		l |= (buffer[off + 2] & 0xFF) << 16;
-		l |= ((long) (buffer[off + 3] & 0xFF)) << 24;
-		return l;
-	}
-
-	private int getShort(byte[] buffer, int off) {
-		return (buffer[off] & 0xFF) | ((buffer[off + 1] & 0xFF) << 8);
-	}
-
-	/**
-	 * Reads and decompresses GZIP data from the underlying stream into buf.
-	 * 
-	 * @param buffer
-	 *            Buffer to receive data
-	 * @param off
-	 *            Offset in buffer to store data
-	 * @param nbytes
-	 *            Number of bytes to read
-	 */
-	@Override
+            crc.reset();
+        }
+    }
+
+    private long getLong(byte[] buffer, int off) {
+        long l = 0;
+        l |= (buffer[off] & 0xFF);
+        l |= (buffer[off + 1] & 0xFF) << 8;
+        l |= (buffer[off + 2] & 0xFF) << 16;
+        l |= ((long) (buffer[off + 3] & 0xFF)) << 24;
+        return l;
+    }
+
+    private int getShort(byte[] buffer, int off) {
+        return (buffer[off] & 0xFF) | ((buffer[off + 1] & 0xFF) << 8);
+    }
+
+    /**
+     * Reads and decompresses GZIP data from the underlying stream into buf.
+     * 
+     * @param buffer
+     *            Buffer to receive data
+     * @param off
+     *            Offset in buffer to store data
+     * @param nbytes
+     *            Number of bytes to read
+     */
+    @Override
     public int read(byte[] buffer, int off, int nbytes) throws IOException {
         if (closed) {
             throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$
         }
-        if(eof){
+        if (eof) {
             return -1;
         }
-		// avoid int overflow, check null buffer
-		if (off <= buffer.length && nbytes >= 0 && off >= 0
-				&& buffer.length - off >= nbytes) {
-			int val = super.read(buffer, off, nbytes);
-			if (val != -1) {
+        // avoid int overflow, check null buffer
+        if (off <= buffer.length && nbytes >= 0 && off >= 0
+                && buffer.length - off >= nbytes) {
+            int val = super.read(buffer, off, nbytes);
+            if (val != -1) {
                 crc.update(buffer, off, val);
             } else if (!eos) {
-				eos = true;
-				// Get non-compressed bytes read by fill
-				int size = inf.getRemaining();
-				final int trailerSize = 8; // crc (4 bytes) + total out (4 bytes)
-				byte[] b = new byte[trailerSize];
-				int copySize = (size > trailerSize) ? trailerSize : size;
+                eos = true;
+                // Get non-compressed bytes read by fill
+                int size = inf.getRemaining();
+                final int trailerSize = 8; // crc (4 bytes) + total out (4
+                                            // bytes)
+                byte[] b = new byte[trailerSize];
+                int copySize = (size > trailerSize) ? trailerSize : size;
 
                 System.arraycopy(buf, len - size, b, 0, copySize);
-				readFully(b, copySize, trailerSize - copySize);
+                readFully(b, copySize, trailerSize - copySize);
 
-				if (getLong(b, 0) != crc.getValue()) {
+                if (getLong(b, 0) != crc.getValue()) {
                     throw new IOException(Messages.getString("archive.20")); //$NON-NLS-1$
                 }
-				if ((int) getLong(b, 4) != inf.getTotalOut()) {
+                if ((int) getLong(b, 4) != inf.getTotalOut()) {
                     throw new IOException(Messages.getString("archive.21")); //$NON-NLS-1$
                 }
-			}
-			return val;
-		}
-		throw new ArrayIndexOutOfBoundsException();
-	}
-
-	/**
-	 * Closes this stream and any underlying streams.
-	 */
-	@Override
+            }
+            return val;
+        }
+        throw new ArrayIndexOutOfBoundsException();
+    }
+
+    /**
+     * Closes this stream and any underlying streams.
+     */
+    @Override
     public void close() throws IOException {
-		eos = true;
-		super.close();
-	}
-
-	private void readFully(byte[] buffer, int offset, int length)
-			throws IOException {
-		int result;
-		while (length > 0) {
-			result = in.read(buffer, offset, length);
-			if (result == -1) {
+        eos = true;
+        super.close();
+    }
+
+    private void readFully(byte[] buffer, int offset, int length)
+            throws IOException {
+        int result;
+        while (length > 0) {
+            result = in.read(buffer, offset, length);
+            if (result == -1) {
                 throw new EOFException();
             }
-			offset += result;
-			length -= result;
-		}
-	}
-
-	private void readZeroTerminated(boolean hcrc) throws IOException {
-		int result;
-		while ((result = in.read()) > 0) {
-			if (hcrc) {
+            offset += result;
+            length -= result;
+        }
+    }
+
+    private void readZeroTerminated(boolean hcrc) throws IOException {
+        int result;
+        while ((result = in.read()) > 0) {
+            if (hcrc) {
                 crc.update(result);
             }
-		}
-		if (result == -1) {
+        }
+        if (result == -1) {
             throw new EOFException();
         }
-		// Add the zero
-		if (hcrc) {
+        // Add the zero
+        if (hcrc) {
             crc.update(result);
         }
-	}
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java?view=diff&rev=556570&r1=556569&r2=556570
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java Mon Jul 16 02:22:19 2007
@@ -17,7 +17,6 @@
 
 package java.util.zip;
 
-
 import java.io.IOException;
 import java.io.OutputStream;
 
@@ -27,71 +26,71 @@
  */
 public class GZIPOutputStream extends DeflaterOutputStream {
 
-	protected CRC32 crc = new CRC32();
+    protected CRC32 crc = new CRC32();
 
-	/**
-	 * Construct a new GZIPOutputStream to write data in GZIP format to the
-	 * underlying stream.
-	 * 
-	 * @param os
-	 *            OutputStream to write to
-	 */
-	public GZIPOutputStream(OutputStream os) throws IOException {
-		this(os, BUF_SIZE);
-	}
-
-	/**
-	 * Construct a new GZIPOutputStream to write data in GZIP format to the
-	 * underlying stream. Set the internal compression buffer to sise size.
-	 * 
-	 * @param os
-	 *            OutputStream to write to
-	 * @param size
-	 *            Internal buffer size
-	 */
-	public GZIPOutputStream(OutputStream os, int size) throws IOException {
-		super(os, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size);
-		writeShort(GZIPInputStream.GZIP_MAGIC);
-		out.write(Deflater.DEFLATED);
-		out.write(0); // flags
-		writeLong(0); // mod time
-		out.write(0); // extra flags
-		out.write(0); // operating system
-	}
-
-	/**
-	 * Indicates to the stream that all data has been written out, and any GZIP
-	 * terminal data can now be output.
-	 */
-	@Override
+    /**
+     * Construct a new GZIPOutputStream to write data in GZIP format to the
+     * underlying stream.
+     * 
+     * @param os
+     *            OutputStream to write to
+     */
+    public GZIPOutputStream(OutputStream os) throws IOException {
+        this(os, BUF_SIZE);
+    }
+
+    /**
+     * Construct a new GZIPOutputStream to write data in GZIP format to the
+     * underlying stream. Set the internal compression buffer to sise size.
+     * 
+     * @param os
+     *            OutputStream to write to
+     * @param size
+     *            Internal buffer size
+     */
+    public GZIPOutputStream(OutputStream os, int size) throws IOException {
+        super(os, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size);
+        writeShort(GZIPInputStream.GZIP_MAGIC);
+        out.write(Deflater.DEFLATED);
+        out.write(0); // flags
+        writeLong(0); // mod time
+        out.write(0); // extra flags
+        out.write(0); // operating system
+    }
+
+    /**
+     * Indicates to the stream that all data has been written out, and any GZIP
+     * terminal data can now be output.
+     */
+    @Override
     public void finish() throws IOException {
-		super.finish();
-		writeLong(crc.getValue());
-		writeLong(crc.tbytes);
-	}
-
-	/**
-	 * Write up to nbytes of data from buf, starting at offset off, to the
-	 * underlying stream in GZIP format.
-	 */
-	@Override
+        super.finish();
+        writeLong(crc.getValue());
+        writeLong(crc.tbytes);
+    }
+
+    /**
+     * Write up to nbytes of data from buf, starting at offset off, to the
+     * underlying stream in GZIP format.
+     */
+    @Override
     public void write(byte[] buffer, int off, int nbytes) throws IOException {
-		super.write(buffer, off, nbytes);
-		crc.update(buffer, off, nbytes);
-	}
-
-	private int writeShort(int i) throws IOException {
-		out.write(i & 0xFF);
-		out.write((i >> 8) & 0xFF);
-		return i;
-	}
-
-	private long writeLong(long i) throws IOException {
-		// Write out the long value as an unsigned int
-		out.write((int) (i & 0xFF));
-		out.write((int) (i >> 8) & 0xFF);
-		out.write((int) (i >> 16) & 0xFF);
-		out.write((int) (i >> 24) & 0xFF);
-		return i;
-	}
+        super.write(buffer, off, nbytes);
+        crc.update(buffer, off, nbytes);
+    }
+
+    private int writeShort(int i) throws IOException {
+        out.write(i & 0xFF);
+        out.write((i >> 8) & 0xFF);
+        return i;
+    }
+
+    private long writeLong(long i) throws IOException {
+        // Write out the long value as an unsigned int
+        out.write((int) (i & 0xFF));
+        out.write((int) (i >> 8) & 0xFF);
+        out.write((int) (i >> 16) & 0xFF);
+        out.write((int) (i >> 24) & 0xFF);
+        return i;
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java?view=diff&rev=556570&r1=556569&r2=556570
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java (original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java Mon Jul 16 02:22:19 2007
@@ -19,7 +19,6 @@
 
 import org.apache.harmony.archive.internal.nls.Messages;
 
-
 /**
  * The Inflater class is used to decompress bytes using the DEFLATE compression
  * algorithm. Inflation is performed by the ZLIB compression library.
@@ -29,156 +28,158 @@
  */
 public class Inflater {
 
-	private boolean finished; // Set by the inflateImpl native
+    private boolean finished; // Set by the inflateImpl native
+
+    private boolean needsDictionary; // Set by the inflateImpl native
 
-	private boolean needsDictionary; // Set by the inflateImpl native
+    private long streamHandle = -1;
 
-	private long streamHandle = -1;
+    int inRead;
 
-	int inRead;
-    
     int inLength;
 
-	// Fill in the JNI id caches
-	private static native void oneTimeInitialization();
+    // Fill in the JNI id caches
+    private static native void oneTimeInitialization();
+
+    static {
+        oneTimeInitialization();
+    }
 
-	static {
-		oneTimeInitialization();
-	}
-    
     private static final byte MAGIC_NUMBER = 120;
+
     private boolean gotFirstByte = false;
+
     private boolean pass_magic_number_check = true;
-    
-	/**
-	 * Release any resources associated with this Inflater. Any unused
-	 * input/output is discarded. This is also called by the finalize method.
-	 */
-	public synchronized void end() {
-		if (streamHandle != -1) {
-			endImpl(streamHandle);
-			inRead = 0;
-			inLength = 0;
-			streamHandle = -1;
-		}
-	}
 
-	private native synchronized void endImpl(long handle);
+    /**
+     * Release any resources associated with this Inflater. Any unused
+     * input/output is discarded. This is also called by the finalize method.
+     */
+    public synchronized void end() {
+        if (streamHandle != -1) {
+            endImpl(streamHandle);
+            inRead = 0;
+            inLength = 0;
+            streamHandle = -1;
+        }
+    }
+
+    private native synchronized void endImpl(long handle);
 
-	@Override
+    @Override
     protected void finalize() {
-		end();
-	}
+        end();
+    }
 
-	/**
-	 * Indicates if the Inflater has inflated the entire deflated stream. If
-	 * deflated bytes remain and needsInput returns true this method will return
-	 * false. This method should be called after all deflated input is supplied
-	 * to the Inflater.
-	 * 
-	 * @return True if all input has been inflated, false otherwise
-	 */
-	public synchronized boolean finished() {
-		return finished;
-	}
-
-	/**
-	 * Returns the Adler32 checksum of either all bytes inflated, or the
-	 * checksum of the preset dictionary if one has been supplied.
-	 * 
-	 * @return The Adler32 checksum associated with this Inflater.
-	 */
-	public synchronized int getAdler() {
-		if (streamHandle == -1) {
+    /**
+     * Indicates if the Inflater has inflated the entire deflated stream. If
+     * deflated bytes remain and needsInput returns true this method will return
+     * false. This method should be called after all deflated input is supplied
+     * to the Inflater.
+     * 
+     * @return True if all input has been inflated, false otherwise
+     */
+    public synchronized boolean finished() {
+        return finished;
+    }
+
+    /**
+     * Returns the Adler32 checksum of either all bytes inflated, or the
+     * checksum of the preset dictionary if one has been supplied.
+     * 
+     * @return The Adler32 checksum associated with this Inflater.
+     */
+    public synchronized int getAdler() {
+        if (streamHandle == -1) {
             throw new IllegalStateException();
         }
-		return getAdlerImpl(streamHandle);
-	}
+        return getAdlerImpl(streamHandle);
+    }
 
-	private native synchronized int getAdlerImpl(long handle);
+    private native synchronized int getAdlerImpl(long handle);
 
-	/**
-	 * Returns the number of bytes of current input remaining to be read by the
-	 * inflater
-	 * 
-	 * @return Number of bytes of unread input.
-	 */
-	public synchronized int getRemaining() {
-		return inLength - inRead;
-	}
-
-	/**
-	 * Returns total number of bytes of input read by the Inflater.
-	 * 
-	 * @return Total bytes read
-	 */
-	public synchronized int getTotalIn() {
-		if (streamHandle == -1) {
+    /**
+     * Returns the number of bytes of current input remaining to be read by the
+     * inflater
+     * 
+     * @return Number of bytes of unread input.
+     */
+    public synchronized int getRemaining() {
+        return inLength - inRead;
+    }
+
+    /**
+     * Returns total number of bytes of input read by the Inflater.
+     * 
+     * @return Total bytes read
+     */
+    public synchronized int getTotalIn() {
+        if (streamHandle == -1) {
             throw new IllegalStateException();
         }
-		long totalIn = getTotalInImpl(streamHandle);
-		return (totalIn <= Integer.MAX_VALUE ? (int) totalIn
-				: Integer.MAX_VALUE);
-	}
-
-	private synchronized native long getTotalInImpl(long handle);
-
-	/**
-	 * Returns total number of bytes of input output by the Inflater.
-	 * 
-	 * @return Total bytes output
-	 */
-	public synchronized int getTotalOut() {
-		if (streamHandle == -1) {
+        long totalIn = getTotalInImpl(streamHandle);
+        return (totalIn <= Integer.MAX_VALUE ? (int) totalIn
+                : Integer.MAX_VALUE);
+    }
+
+    private synchronized native long getTotalInImpl(long handle);
+
+    /**
+     * Returns total number of bytes of input output by the Inflater.
+     * 
+     * @return Total bytes output
+     */
+    public synchronized int getTotalOut() {
+        if (streamHandle == -1) {
             throw new IllegalStateException();
         }
-		long totalOut = getTotalOutImpl(streamHandle);
-		return (totalOut <= Integer.MAX_VALUE ? (int) totalOut
-				: Integer.MAX_VALUE);
-	}
-
-	private native synchronized long getTotalOutImpl(long handle);
-
-	/**
-	 * Inflates bytes from current input and stores them in buf.
-	 * 
-	 * @param buf
-	 *            Buffer to output inflated bytes
-	 * @return Number of bytes inflated
-	 * @exception DataFormatException
-	 *                If the underlying stream is corrupted or was not DEFLATED
-	 * 
-	 */
-	public int inflate(byte[] buf) throws DataFormatException {
-		return inflate(buf, 0, buf.length);
-	}
-
-	/**
-	 * Inflates up to nbytes bytes from current input and stores them in buf
-	 * starting at off.
-	 * 
-	 * @param buf
-	 *            Buffer to output inflated bytes
-	 * @param off
-	 *            Offset in buffer into which to store inflated bytes
-	 * @param nbytes
-	 *            Number of inflated bytes to store
-	 * @exception DataFormatException
-	 *                If the underlying stream is corrupted or was not DEFLATED
-	 * @return Number of bytes inflated
-	 */
-	public synchronized int inflate(byte[] buf, int off, int nbytes)
-			throws DataFormatException {
-		// avoid int overflow, check null buf
-		if (off <= buf.length && nbytes >= 0 && off >= 0
-				&& buf.length - off >= nbytes) {
+        long totalOut = getTotalOutImpl(streamHandle);
+        return (totalOut <= Integer.MAX_VALUE ? (int) totalOut
+                : Integer.MAX_VALUE);
+    }
+
+    private native synchronized long getTotalOutImpl(long handle);
+
+    /**
+     * Inflates bytes from current input and stores them in buf.
+     * 
+     * @param buf
+     *            Buffer to output inflated bytes
+     * @return Number of bytes inflated
+     * @exception DataFormatException
+     *                If the underlying stream is corrupted or was not DEFLATED
+     * 
+     */
+    public int inflate(byte[] buf) throws DataFormatException {
+        return inflate(buf, 0, buf.length);
+    }
+
+    /**
+     * Inflates up to nbytes bytes from current input and stores them in buf
+     * starting at off.
+     * 
+     * @param buf
+     *            Buffer to output inflated bytes
+     * @param off
+     *            Offset in buffer into which to store inflated bytes
+     * @param nbytes
+     *            Number of inflated bytes to store
+     * @exception DataFormatException
+     *                If the underlying stream is corrupted or was not DEFLATED
+     * @return Number of bytes inflated
+     */
+    public synchronized int inflate(byte[] buf, int off, int nbytes)
+            throws DataFormatException {
+        // avoid int overflow, check null buf
+        if (off <= buf.length && nbytes >= 0 && off >= 0
+                && buf.length - off >= nbytes) {
             if (nbytes == 0)
                 return 0;
 
-			if (streamHandle == -1) {
+            if (streamHandle == -1) {
                 throw new IllegalStateException();
             }
-            
+
             if (!pass_magic_number_check) {
                 throw new DataFormatException();
             }
@@ -186,183 +187,180 @@
             if (needsInput()) {
                 return 0;
             }
-            
-			boolean neededDict = needsDictionary;
-			needsDictionary = false;
-			int result = inflateImpl(buf, off, nbytes, streamHandle);
-			if (needsDictionary && neededDict) {
+
+            boolean neededDict = needsDictionary;
+            needsDictionary = false;
+            int result = inflateImpl(buf, off, nbytes, streamHandle);
+            if (needsDictionary && neededDict) {
                 throw new DataFormatException(Messages.getString("archive.27")); //$NON-NLS-1$
             }
-			return result;
-		}
-		throw new ArrayIndexOutOfBoundsException();
-	}
-
-	private native synchronized int inflateImpl(byte[] buf, int off,
-			int nbytes, long handle);
-
-	/**
-	 * Constructs a new Inflater instance.
-	 */
-	public Inflater() {
-		this(false);
-	}
-
-	/**
-	 * Constructs a new Inflater instance. If noHeader is true the Inflater will
-	 * not attempt to read a ZLIB header.
-	 * 
-	 * @param noHeader
-	 *            If true, read a ZLIB header from input.
-	 */
-	public Inflater(boolean noHeader) {
-		streamHandle = createStream(noHeader);
-	}
-
-	/**
-	 * Indicates whether the input bytes were compressed with a preset
-	 * dictionary. This method should be called prior to inflate() to determine
-	 * if a dictionary is required. If so setDictionary() should be called with
-	 * the appropriate dictionary prior to calling inflate().
-	 * 
-	 * @return true if a preset dictionary is required for inflation.
-	 * @see #setDictionary(byte[])
-	 * @see #setDictionary(byte[], int, int)
-	 */
-	public synchronized boolean needsDictionary() {
-		return needsDictionary;
-	}
-
-	public synchronized boolean needsInput() {
-		return inRead == inLength;
-	}
-
-	/**
-	 * Resets the Inflater.
-	 */
-	public synchronized void reset() {
-		if (streamHandle == -1) {
+            return result;
+        }
+        throw new ArrayIndexOutOfBoundsException();
+    }
+
+    private native synchronized int inflateImpl(byte[] buf, int off,
+            int nbytes, long handle);
+
+    /**
+     * Constructs a new Inflater instance.
+     */
+    public Inflater() {
+        this(false);
+    }
+
+    /**
+     * Constructs a new Inflater instance. If noHeader is true the Inflater will
+     * not attempt to read a ZLIB header.
+     * 
+     * @param noHeader
+     *            If true, read a ZLIB header from input.
+     */
+    public Inflater(boolean noHeader) {
+        streamHandle = createStream(noHeader);
+    }
+
+    /**
+     * Indicates whether the input bytes were compressed with a preset
+     * dictionary. This method should be called prior to inflate() to determine
+     * if a dictionary is required. If so setDictionary() should be called with
+     * the appropriate dictionary prior to calling inflate().
+     * 
+     * @return true if a preset dictionary is required for inflation.
+     * @see #setDictionary(byte[])
+     * @see #setDictionary(byte[], int, int)
+     */
+    public synchronized boolean needsDictionary() {
+        return needsDictionary;
+    }
+
+    public synchronized boolean needsInput() {
+        return inRead == inLength;
+    }
+
+    /**
+     * Resets the Inflater.
+     */
+    public synchronized void reset() {
+        if (streamHandle == -1) {
             throw new NullPointerException();
         }
-		finished = false;
-		needsDictionary = false;
-		inLength = inRead = 0;
-		resetImpl(streamHandle);
-	}
-
-	private native synchronized void resetImpl(long handle);
-
-	/**
-	 * Sets the preset dictionary to be used for inflation to buf.
-	 * needsDictionary() can be called to determine whether the current input
-	 * was deflated using a preset dictionary.
-	 * 
-	 * @param buf
-	 *            The buffer containing the dictionary bytes
-	 * @see #needsDictionary
-	 */
-	public synchronized void setDictionary(byte[] buf) {
-		setDictionary(buf, 0, buf.length);
-	}
+        finished = false;
+        needsDictionary = false;
+        inLength = inRead = 0;
+        resetImpl(streamHandle);
+    }
+
+    private native synchronized void resetImpl(long handle);
+
+    /**
+     * Sets the preset dictionary to be used for inflation to buf.
+     * needsDictionary() can be called to determine whether the current input
+     * was deflated using a preset dictionary.
+     * 
+     * @param buf
+     *            The buffer containing the dictionary bytes
+     * @see #needsDictionary
+     */
+    public synchronized void setDictionary(byte[] buf) {
+        setDictionary(buf, 0, buf.length);
+    }
 
-	public synchronized void setDictionary(byte[] buf, int off, int nbytes) {
-		if (streamHandle == -1) {
+    public synchronized void setDictionary(byte[] buf, int off, int nbytes) {
+        if (streamHandle == -1) {
             throw new IllegalStateException();
         }
-		// avoid int overflow, check null buf
-		if (off <= buf.length && nbytes >= 0 && off >= 0
-				&& buf.length - off >= nbytes) {
+        // avoid int overflow, check null buf
+        if (off <= buf.length && nbytes >= 0 && off >= 0
+                && buf.length - off >= nbytes) {
             setDictionaryImpl(buf, off, nbytes, streamHandle);
         } else {
             throw new ArrayIndexOutOfBoundsException();
         }
-	}
+    }
 
-	private native synchronized void setDictionaryImpl(byte[] buf, int off,
-			int nbytes, long handle);
+    private native synchronized void setDictionaryImpl(byte[] buf, int off,
+            int nbytes, long handle);
 
-	/**
-	 * Sets the current input to buf. This method should only be called if
-	 * needsInput() returns true.
-	 * 
-	 * @param buf
-	 *            input buffer
-	 * @see #needsInput
-	 */
-	public synchronized void setInput(byte[] buf) {
-		setInput(buf, 0, buf.length);
-	}
-
-	/**
-	 * Sets the current input to the region of buf starting at off and ending at
-	 * nbytes - 1. This method should only be called if needsInput() returns
-	 * true.
-	 * 
-	 * @param buf
-	 *            input buffer
-	 * @param off
-	 *            offset to read from in buffer
-	 * @param nbytes
-	 *            number of bytes to read
-	 * @see #needsInput
-	 */
-	public synchronized void setInput(byte[] buf, int off, int nbytes) {
-		if (streamHandle == -1) {
+    /**
+     * Sets the current input to buf. This method should only be called if
+     * needsInput() returns true.
+     * 
+     * @param buf
+     *            input buffer
+     * @see #needsInput
+     */
+    public synchronized void setInput(byte[] buf) {
+        setInput(buf, 0, buf.length);
+    }
+
+    /**
+     * Sets the current input to the region of buf starting at off and ending at
+     * nbytes - 1. This method should only be called if needsInput() returns
+     * true.
+     * 
+     * @param buf
+     *            input buffer
+     * @param off
+     *            offset to read from in buffer
+     * @param nbytes
+     *            number of bytes to read
+     * @see #needsInput
+     */
+    public synchronized void setInput(byte[] buf, int off, int nbytes) {
+        if (streamHandle == -1) {
             throw new IllegalStateException();
         }
-		// avoid int overflow, check null buf
-		if (off <= buf.length && nbytes >= 0 && off >= 0
-				&& buf.length - off >= nbytes) {
-			inRead = 0;
-			inLength = nbytes;
-			setInputImpl(buf, off, nbytes, streamHandle);
-		} else {
+        // avoid int overflow, check null buf
+        if (off <= buf.length && nbytes >= 0 && off >= 0
+                && buf.length - off >= nbytes) {
+            inRead = 0;
+            inLength = nbytes;
+            setInputImpl(buf, off, nbytes, streamHandle);
+        } else {
             throw new ArrayIndexOutOfBoundsException();
         }
-        
-        if(!gotFirstByte && nbytes>0)
-        {
-           pass_magic_number_check = (buf[off] == MAGIC_NUMBER || nbytes > 1);           
-           gotFirstByte = true;
-        }
-	}
-
-	/**
-	 * Returns a long int of total number of bytes of input read by the
-	 * Inflater.
-	 * This method performs the same as getTotalIn except it returns a 
-	 * long value instead of an integer
-	 * 
-	 * @see getTotalIn
-	 * @return Total bytes read
-	 */
-	public synchronized long getBytesRead() {
-		// Throw NPE here
-		if (streamHandle == -1) {
+
+        if (!gotFirstByte && nbytes > 0) {
+            pass_magic_number_check = (buf[off] == MAGIC_NUMBER || nbytes > 1);
+            gotFirstByte = true;
+        }
+    }
+
+    /**
+     * Returns a long int of total number of bytes of input read by the
+     * Inflater. This method performs the same as getTotalIn except it returns a
+     * long value instead of an integer
+     * 
+     * @see getTotalIn
+     * @return Total bytes read
+     */
+    public synchronized long getBytesRead() {
+        // Throw NPE here
+        if (streamHandle == -1) {
             throw new NullPointerException();
         }
-		return getTotalInImpl(streamHandle);
-	}
+        return getTotalInImpl(streamHandle);
+    }
 
-	/**
-	 * Returns a long int of total number of bytes of input output by the
-	 * Inflater.
-	 * This method performs the same as getTotalOut except it returns a 
-	 * long value instead of an integer
-	 * 
-	 * @see getTotalOut
-	 * @return Total bytes output
-	 */
-	public synchronized long getBytesWritten() {
-		// Throw NPE here
-		if (streamHandle == -1) {
+    /**
+     * Returns a long int of total number of bytes of input output by the
+     * Inflater. This method performs the same as getTotalOut except it returns
+     * a long value instead of an integer
+     * 
+     * @see getTotalOut
+     * @return Total bytes output
+     */
+    public synchronized long getBytesWritten() {
+        // Throw NPE here
+        if (streamHandle == -1) {
             throw new NullPointerException();
         }
-		return getTotalOutImpl(streamHandle);
-	}
+        return getTotalOutImpl(streamHandle);
+    }
 
-	private native synchronized void setInputImpl(byte[] buf, int off,
-			int nbytes, long handle);
+    private native synchronized void setInputImpl(byte[] buf, int off,
+            int nbytes, long handle);
 
-	private native long createStream(boolean noHeader1);
+    private native long createStream(boolean noHeader1);
 }

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java?view=diff&rev=556570&r1=556569&r2=556570
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java Mon Jul 16 02:22:19 2007
@@ -17,7 +17,6 @@
 
 package java.util.zip;
 
-
 import java.io.EOFException;
 import java.io.FilterInputStream;
 import java.io.IOException;
@@ -34,257 +33,259 @@
  */
 public class InflaterInputStream extends FilterInputStream {
 
-	protected Inflater inf;
+    protected Inflater inf;
+
+    protected byte[] buf;
+
+    protected int len;
 
-	protected byte[] buf;
+    boolean closed;
 
-	protected int len;
+    boolean eof;
+
+    static final int BUF_SIZE = 512;
+
+    /**
+     * Constructs a new InflaterOutputStream on is
+     * 
+     * @param is
+     *            The InputStream to read data from
+     */
+    public InflaterInputStream(InputStream is) {
+        this(is, new Inflater(), BUF_SIZE);
+    }
 
-	boolean closed;
+    /**
+     * Constructs a new InflaterOutputStream on is, using the Inflater provided
+     * in inf.
+     * 
+     * @param is
+     *            The InputStream to read data from
+     * @param inf
+     *            The Inflater to use for decompression
+     */
+    public InflaterInputStream(InputStream is, Inflater inf) {
+        this(is, inf, BUF_SIZE);
+    }
 
-	boolean eof;
-
-	static final int BUF_SIZE = 512;
-
-	/**
-	 * Constructs a new InflaterOutputStream on is
-	 * 
-	 * @param is The InputStream to read data from
-	 */
-	public InflaterInputStream(InputStream is) {
-		this(is, new Inflater(), BUF_SIZE);
-	}
-
-	/**
-	 * Constructs a new InflaterOutputStream on is, using the Inflater provided
-	 * in inf.
-	 * 
-	 * @param is
-	 *            The InputStream to read data from
-	 * @param inf
-	 *            The Inflater to use for decompression
-	 */
-	public InflaterInputStream(InputStream is, Inflater inf) {
-		this(is, inf, BUF_SIZE);
-	}
-
-	/**
-	 * Constructs a new InflaterOutputStream on is, using the Inflater provided
-	 * in inf. The size of the inflation buffer is determined by bsize.
-	 * 
-	 * @param is
-	 *            The InputStream to read data from
-	 * @param inf
-	 *            The Inflater to use for decompression
-	 * @param bsize
-	 *            size of the inflation buffer
-	 */
-	public InflaterInputStream(InputStream is, Inflater inf, int bsize) {
-		super(is);
-		if (is == null || inf == null) {
+    /**
+     * Constructs a new InflaterOutputStream on is, using the Inflater provided
+     * in inf. The size of the inflation buffer is determined by bsize.
+     * 
+     * @param is
+     *            The InputStream to read data from
+     * @param inf
+     *            The Inflater to use for decompression
+     * @param bsize
+     *            size of the inflation buffer
+     */
+    public InflaterInputStream(InputStream is, Inflater inf, int bsize) {
+        super(is);
+        if (is == null || inf == null) {
             throw new NullPointerException();
         }
-		if (bsize <= 0) {
+        if (bsize <= 0) {
             throw new IllegalArgumentException();
         }
-		this.inf = inf;
-		buf = new byte[bsize];
-	}
-
-	/**
-	 * Reads a single byte of decompressed data.
-	 * 
-	 * @return byte read
-	 * @throws IOException
-	 *                If an error occurs reading
-	 */
-	@Override
+        this.inf = inf;
+        buf = new byte[bsize];
+    }
+
+    /**
+     * Reads a single byte of decompressed data.
+     * 
+     * @return byte read
+     * @throws IOException
+     *             If an error occurs reading
+     */
+    @Override
     public int read() throws IOException {
-		byte[] b = new byte[1];
-		if (read(b, 0, 1) == -1) {
+        byte[] b = new byte[1];
+        if (read(b, 0, 1) == -1) {
             return -1;
         }
-		return b[0] & 0xff;
-	}
+        return b[0] & 0xff;
+    }
 
-	/**
-	 * Reads up to nbytes of decompressed data and stores it in buf starting at
-	 * off.
-	 * 
-	 * @param buffer
-	 *            Buffer to store into
-	 * @param off
-	 *            offset in buffer to store at
-	 * @param nbytes
-	 *            number of bytes to store
-	 * @return Number of uncompressed bytes read
-	 * @throws IOException
-	 *                If an error occurs reading
-	 */
-	@Override
+    /**
+     * Reads up to nbytes of decompressed data and stores it in buf starting at
+     * off.
+     * 
+     * @param buffer
+     *            Buffer to store into
+     * @param off
+     *            offset in buffer to store at
+     * @param nbytes
+     *            number of bytes to store
+     * @return Number of uncompressed bytes read
+     * @throws IOException
+     *             If an error occurs reading
+     */
+    @Override
     public int read(byte[] buffer, int off, int nbytes) throws IOException {
-		/* archive.1E=Stream is closed */
-		if (closed) {
+        /* archive.1E=Stream is closed */
+        if (closed) {
             throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$
         }
 
-		if (null == buffer) {
+        if (null == buffer) {
             throw new NullPointerException();
         }
 
-		if (off < 0 || nbytes < 0 || off + nbytes > buffer.length) {
+        if (off < 0 || nbytes < 0 || off + nbytes > buffer.length) {
             throw new IndexOutOfBoundsException();
         }
 
-		if (nbytes == 0) {
+        if (nbytes == 0) {
             return 0;
         }
 
-		if (inf.finished()) {
-			eof = true;
-			return -1;
-		}
-
-		// avoid int overflow, check null buffer
-		if (off <= buffer.length && nbytes >= 0 && off >= 0
-				&& buffer.length - off >= nbytes) {
-			do {
-				if (inf.needsInput()) {
+        if (inf.finished()) {
+            eof = true;
+            return -1;
+        }
+
+        // avoid int overflow, check null buffer
+        if (off <= buffer.length && nbytes >= 0 && off >= 0
+                && buffer.length - off >= nbytes) {
+            do {
+                if (inf.needsInput()) {
                     fill();
                 }
-				int result;
-				try {
-					result = inf.inflate(buffer, off, nbytes);
-				} catch (DataFormatException e) {
-					if (len == -1) {
+                int result;
+                try {
+                    result = inf.inflate(buffer, off, nbytes);
+                } catch (DataFormatException e) {
+                    if (len == -1) {
                         throw new EOFException();
                     }
-					throw (IOException)(new IOException().initCause(e));
-				}
-				if (result > 0) {
+                    throw (IOException) (new IOException().initCause(e));
+                }
+                if (result > 0) {
                     return result;
                 } else if (inf.finished()) {
-					eof = true;
-					return -1;
-				} else if (inf.needsDictionary()) {
+                    eof = true;
+                    return -1;
+                } else if (inf.needsDictionary()) {
                     return -1;
                 } else if (len == -1) {
                     throw new EOFException();
-				// If result == 0, fill() and try again
+                    // If result == 0, fill() and try again
                 }
-			} while (true);
-		}
-		throw new ArrayIndexOutOfBoundsException();
-	}
+            } while (true);
+        }
+        throw new ArrayIndexOutOfBoundsException();
+    }
 
-	protected void fill() throws IOException {
-		if (closed) {
+    protected void fill() throws IOException {
+        if (closed) {
             throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$
         }
-		if ((len = in.read(buf)) > 0) {
+        if ((len = in.read(buf)) > 0) {
             inf.setInput(buf, 0, len);
         }
-	}
+    }
 
-	/**
-	 * Skips up to nbytes of uncompressed data.
-	 * 
-	 * @param nbytes
-	 *            Number of bytes to skip
-	 * @return Number of uncompressed bytes skipped
-	 * @throws IOException
-	 *                If an error occurs skipping
-	 */
-	@Override
+    /**
+     * Skips up to nbytes of uncompressed data.
+     * 
+     * @param nbytes
+     *            Number of bytes to skip
+     * @return Number of uncompressed bytes skipped
+     * @throws IOException
+     *             If an error occurs skipping
+     */
+    @Override
     public long skip(long nbytes) throws IOException {
-		if (nbytes >= 0) {
-			long count = 0, rem = 0;
-			while (count < nbytes) {
-				int x = read(buf, 0,
-						(rem = nbytes - count) > buf.length ? buf.length
-								: (int) rem);
-				if (x == -1) {
-					eof = true;
-					return count;
-				}
-				count += x;
-			}
-			return count;
-		}
-		throw new IllegalArgumentException();
-	}
-
-	/**
-	 * Returns 0 if this stream has been closed, 1 otherwise.
-	 * 
-	 * @throws IOException
-	 *                If an error occurs
-	 */
-	@Override
+        if (nbytes >= 0) {
+            long count = 0, rem = 0;
+            while (count < nbytes) {
+                int x = read(buf, 0,
+                        (rem = nbytes - count) > buf.length ? buf.length
+                                : (int) rem);
+                if (x == -1) {
+                    eof = true;
+                    return count;
+                }
+                count += x;
+            }
+            return count;
+        }
+        throw new IllegalArgumentException();
+    }
+
+    /**
+     * Returns 0 if this stream has been closed, 1 otherwise.
+     * 
+     * @throws IOException
+     *             If an error occurs
+     */
+    @Override
     public int available() throws IOException {
-		if (closed) {
+        if (closed) {
             // archive.1E=Stream is closed
             throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$
         }
-		if (eof) {
+        if (eof) {
             return 0;
         }
-		return 1;
-	}
+        return 1;
+    }
 
-	/**
-	 * Closes the stream
-	 * 
-	 * @throws IOException
-	 *                If an error occurs closing the stream
-	 */
-	@Override
+    /**
+     * Closes the stream
+     * 
+     * @throws IOException
+     *             If an error occurs closing the stream
+     */
+    @Override
     public void close() throws IOException {
-		if (!closed) {
-			inf.end();
-			closed = true;
-			eof = true;
-			super.close();
-		}
-	}
-	
-    /**
-	 * Marks the current position in the stream.
-	 * 
-	 * This implementation overrides the supertype implementation to do nothing
-	 * at all.
-	 * 
-	 * @param readlimit
-	 *            of no use
-	 */
-	@Override
+        if (!closed) {
+            inf.end();
+            closed = true;
+            eof = true;
+            super.close();
+        }
+    }
+
+    /**
+     * Marks the current position in the stream.
+     * 
+     * This implementation overrides the supertype implementation to do nothing
+     * at all.
+     * 
+     * @param readlimit
+     *            of no use
+     */
+    @Override
     @SuppressWarnings("unused")
     public void mark(int readlimit) {
-		// do nothing
-	}
+        // do nothing
+    }
 
     /**
-	 * Reset the position of the stream to the last mark position.
-	 * 
-	 * This implementation overrides the supertype implementation and always
-	 * throws an {@link IOException IOException} when called.
-	 * 
-	 * @throws IOException
-	 *             if the method is called
-	 */
+     * Reset the position of the stream to the last mark position.
+     * 
+     * This implementation overrides the supertype implementation and always
+     * throws an {@link IOException IOException} when called.
+     * 
+     * @throws IOException
+     *             if the method is called
+     */
     @Override
-    public void reset() throws IOException{
+    public void reset() throws IOException {
         throw new IOException();
     }
-    
+
     /**
-	 * Answers whether the receiver implements mark semantics.  This type
-	 * does not support mark, so always responds <code>false</code>.
-	 * @return false 
-	 */
-	@Override
+     * Answers whether the receiver implements mark semantics. This type does
+     * not support mark, so always responds <code>false</code>.
+     * 
+     * @return false
+     */
+    @Override
     public boolean markSupported() {
-		return false;
-	}
+        return false;
+    }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipConstants.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipConstants.java?view=diff&rev=556570&r1=556569&r2=556570
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipConstants.java (original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipConstants.java Mon Jul 16 02:22:19 2007
@@ -17,18 +17,17 @@
 
 package java.util.zip;
 
-
 interface ZipConstants {
 
-	public static final long LOCSIG = 0x4034b50, EXTSIG = 0x8074b50,
-			CENSIG = 0x2014b50, ENDSIG = 0x6054b50;
+    public static final long LOCSIG = 0x4034b50, EXTSIG = 0x8074b50,
+            CENSIG = 0x2014b50, ENDSIG = 0x6054b50;
 
-	public static final int LOCHDR = 30, EXTHDR = 16, CENHDR = 46, ENDHDR = 22,
-			LOCVER = 4, LOCFLG = 6, LOCHOW = 8, LOCTIM = 10, LOCCRC = 14,
-			LOCSIZ = 18, LOCLEN = 22, LOCNAM = 26, LOCEXT = 28, EXTCRC = 4,
-			EXTSIZ = 8, EXTLEN = 12, CENVEM = 4, CENVER = 6, CENFLG = 8,
-			CENHOW = 10, CENTIM = 12, CENCRC = 16, CENSIZ = 20, CENLEN = 24,
-			CENNAM = 28, CENEXT = 30, CENCOM = 32, CENDSK = 34, CENATT = 36,
-			CENATX = 38, CENOFF = 42, ENDSUB = 8, ENDTOT = 10, ENDSIZ = 12,
-			ENDOFF = 16, ENDCOM = 20;
+    public static final int LOCHDR = 30, EXTHDR = 16, CENHDR = 46, ENDHDR = 22,
+            LOCVER = 4, LOCFLG = 6, LOCHOW = 8, LOCTIM = 10, LOCCRC = 14,
+            LOCSIZ = 18, LOCLEN = 22, LOCNAM = 26, LOCEXT = 28, EXTCRC = 4,
+            EXTSIZ = 8, EXTLEN = 12, CENVEM = 4, CENVER = 6, CENFLG = 8,
+            CENHOW = 10, CENTIM = 12, CENCRC = 16, CENSIZ = 20, CENLEN = 24,
+            CENNAM = 28, CENEXT = 30, CENCOM = 32, CENDSK = 34, CENATT = 36,
+            CENATX = 38, CENOFF = 42, ENDSUB = 8, ENDTOT = 10, ENDSIZ = 12,
+            ENDOFF = 16, ENDCOM = 20;
 }

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipEntry.java?view=diff&rev=556570&r1=556569&r2=556570
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipEntry.java (original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipEntry.java Mon Jul 16 02:22:19 2007
@@ -17,7 +17,6 @@
 
 package java.util.zip;
 
-
 import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
@@ -29,310 +28,310 @@
  * @see ZipInputStream
  */
 public class ZipEntry implements ZipConstants, Cloneable {
-	String name, comment;
+    String name, comment;
 
-	long compressedSize = -1, crc = -1, size = -1, dataOffset = -1;
+    long compressedSize = -1, crc = -1, size = -1, dataOffset = -1;
 
-	int compressionMethod = -1, time = -1, modDate = -1;
+    int compressionMethod = -1, time = -1, modDate = -1;
 
-	byte[] extra;
+    byte[] extra;
 
-	/**
-	 * Zip entry state: Deflated
-	 */
-	public static final int DEFLATED = 8;
-
-	/**
-	 * Zip entry state: Stored
-	 */
-	public static final int STORED = 0;
-
-	/**
-	 * Constructs a new ZipEntry with the specified name.
-	 * 
-	 * @param name
-	 *            the name of the zip entry
-	 */
-	public ZipEntry(String name) {
-		if (name == null) {
+    /**
+     * Zip entry state: Deflated
+     */
+    public static final int DEFLATED = 8;
+
+    /**
+     * Zip entry state: Stored
+     */
+    public static final int STORED = 0;
+
+    /**
+     * Constructs a new ZipEntry with the specified name.
+     * 
+     * @param name
+     *            the name of the zip entry
+     */
+    public ZipEntry(String name) {
+        if (name == null) {
             throw new NullPointerException();
         }
-		if (name.length() > 0xFFFF) {
+        if (name.length() > 0xFFFF) {
             throw new IllegalArgumentException();
         }
-		this.name = name;
-	}
+        this.name = name;
+    }
+
+    /**
+     * Gets the comment for this ZipEntry.
+     * 
+     * @return the comment for this ZipEntry, or null if there is no comment
+     */
+    public String getComment() {
+        return comment;
+    }
+
+    /**
+     * Gets the compressed size of this ZipEntry.
+     * 
+     * @return the compressed size, or -1 if the compressed size has not been
+     *         set
+     */
+    public long getCompressedSize() {
+        return compressedSize;
+    }
+
+    /**
+     * Gets the crc for this ZipEntry.
+     * 
+     * @return the crc, or -1 if the crc has not been set
+     */
+    public long getCrc() {
+        return crc;
+    }
+
+    /**
+     * Gets the extra information for this ZipEntry.
+     * 
+     * @return a byte array containing the extra information, or null if there
+     *         is none
+     */
+    public byte[] getExtra() {
+        return extra;
+    }
+
+    /**
+     * Gets the compression method for this ZipEntry.
+     * 
+     * @return the compression method, either DEFLATED, STORED or -1 if the
+     *         compression method has not been set
+     */
+    public int getMethod() {
+        return compressionMethod;
+    }
+
+    /**
+     * Gets the name of this ZipEntry.
+     * 
+     * @return the entry name
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Gets the uncompressed size of this ZipEntry.
+     * 
+     * @return the uncompressed size, or -1 if the size has not been set
+     */
+    public long getSize() {
+        return size;
+    }
+
+    /**
+     * Gets the last modification time of this ZipEntry.
+     * 
+     * @return the last modification time as the number of milliseconds since
+     *         Jan. 1, 1970
+     */
+    public long getTime() {
+        if (time != -1) {
+            GregorianCalendar cal = new GregorianCalendar();
+            cal.set(Calendar.MILLISECOND, 0);
+            cal.set(1980 + ((modDate >> 9) & 0x7f), ((modDate >> 5) & 0xf) - 1,
+                    modDate & 0x1f, (time >> 11) & 0x1f, (time >> 5) & 0x3f,
+                    (time & 0x1f) << 1);
+            return cal.getTime().getTime();
+        }
+        return -1;
+    }
 
-	/**
-	 * Gets the comment for this ZipEntry.
-	 * 
-	 * @return the comment for this ZipEntry, or null if there is no comment
-	 */
-	public String getComment() {
-		return comment;
-	}
-
-	/**
-	 * Gets the compressed size of this ZipEntry.
-	 * 
-	 * @return the compressed size, or -1 if the compressed size has not been
-	 *         set
-	 */
-	public long getCompressedSize() {
-		return compressedSize;
-	}
-
-	/**
-	 * Gets the crc for this ZipEntry.
-	 * 
-	 * @return the crc, or -1 if the crc has not been set
-	 */
-	public long getCrc() {
-		return crc;
-	}
-
-	/**
-	 * Gets the extra information for this ZipEntry.
-	 * 
-	 * @return a byte array containing the extra information, or null if there
-	 *         is none
-	 */
-	public byte[] getExtra() {
-		return extra;
-	}
-
-	/**
-	 * Gets the compression method for this ZipEntry.
-	 * 
-	 * @return the compression method, either DEFLATED, STORED or -1 if the
-	 *         compression method has not been set
-	 */
-	public int getMethod() {
-		return compressionMethod;
-	}
-
-	/**
-	 * Gets the name of this ZipEntry.
-	 * 
-	 * @return the entry name
-	 */
-	public String getName() {
-		return name;
-	}
-
-	/**
-	 * Gets the uncompressed size of this ZipEntry.
-	 * 
-	 * @return the uncompressed size, or -1 if the size has not been set
-	 */
-	public long getSize() {
-		return size;
-	}
-
-	/**
-	 * Gets the last modification time of this ZipEntry.
-	 * 
-	 * @return the last modification time as the number of milliseconds since
-	 *         Jan. 1, 1970
-	 */
-	public long getTime() {
-		if (time != -1) {
-			GregorianCalendar cal = new GregorianCalendar();
-			cal.set(Calendar.MILLISECOND, 0);
-			cal.set(1980 + ((modDate >> 9) & 0x7f), ((modDate >> 5) & 0xf) - 1,
-					modDate & 0x1f, (time >> 11) & 0x1f, (time >> 5) & 0x3f,
-					(time & 0x1f) << 1);
-			return cal.getTime().getTime();
-		}
-		return -1;
-	}
-
-	/**
-	 * Answers if this ZipEntry is a directory.
-	 * 
-	 * @return <code>true</code> when this ZipEntry is a directory,
-	 *         <code>false<code> otherwise
-	 */
-	public boolean isDirectory() {
-		return name.charAt(name.length() - 1) == '/';
-	}
-
-	/**
-	 * Sets the comment for this ZipEntry.
-	 * 
-	 * @param string
-	 *            the comment
-	 */
-	public void setComment(String string) {
-		if (string == null || string.length() <= 0xFFFF) {
+    /**
+     * Answers if this ZipEntry is a directory.
+     * 
+     * @return <code>true</code> when this ZipEntry is a directory,
+     *         <code>false<code> otherwise
+     */
+    public boolean isDirectory() {
+        return name.charAt(name.length() - 1) == '/';
+    }
+
+    /**
+     * Sets the comment for this ZipEntry.
+     * 
+     * @param string
+     *            the comment
+     */
+    public void setComment(String string) {
+        if (string == null || string.length() <= 0xFFFF) {
             comment = string;
         } else {
             throw new IllegalArgumentException();
         }
-	}
+    }
 
-	/**
-	 * Sets the compressed size for this ZipEntry.
-	 * 
-	 * @param value
-	 *            the compressed size
-	 */
-	public void setCompressedSize(long value) {
-		compressedSize = value;
-	}
-
-	/**
-	 * Sets the crc for this ZipEntry.
-	 * 
-	 * @param value
-	 *            the crc
-	 * 
-	 * @throws IllegalArgumentException
-	 *             if value is < 0 or > 0xFFFFFFFFL
-	 */
-	public void setCrc(long value) {
-		if (value >= 0 && value <= 0xFFFFFFFFL) {
+    /**
+     * Sets the compressed size for this ZipEntry.
+     * 
+     * @param value
+     *            the compressed size
+     */
+    public void setCompressedSize(long value) {
+        compressedSize = value;
+    }
+
+    /**
+     * Sets the crc for this ZipEntry.
+     * 
+     * @param value
+     *            the crc
+     * 
+     * @throws IllegalArgumentException
+     *             if value is < 0 or > 0xFFFFFFFFL
+     */
+    public void setCrc(long value) {
+        if (value >= 0 && value <= 0xFFFFFFFFL) {
             crc = value;
         } else {
             throw new IllegalArgumentException();
         }
-	}
+    }
 
-	/**
-	 * Sets the extra information for this ZipEntry.
-	 * 
-	 * @param data
-	 *            a byte array containing the extra information
-	 * 
-	 * @throws IllegalArgumentException
-	 *             when the length of data is > 0xFFFF bytes
-	 */
-	public void setExtra(byte[] data) {
-		if (data == null || data.length <= 0xFFFF) {
+    /**
+     * Sets the extra information for this ZipEntry.
+     * 
+     * @param data
+     *            a byte array containing the extra information
+     * 
+     * @throws IllegalArgumentException
+     *             when the length of data is > 0xFFFF bytes
+     */
+    public void setExtra(byte[] data) {
+        if (data == null || data.length <= 0xFFFF) {
             extra = data;
         } else {
             throw new IllegalArgumentException();
         }
-	}
+    }
 
-	/**
-	 * Sets the compression method for this ZipEntry.
-	 * 
-	 * @param value
-	 *            the compression method, either DEFLATED or STORED
-	 * 
-	 * @throws IllegalArgumentException
-	 *             when value is not DEFLATED or STORED
-	 */
-	public void setMethod(int value) {
-		if (value != STORED && value != DEFLATED) {
+    /**
+     * Sets the compression method for this ZipEntry.
+     * 
+     * @param value
+     *            the compression method, either DEFLATED or STORED
+     * 
+     * @throws IllegalArgumentException
+     *             when value is not DEFLATED or STORED
+     */
+    public void setMethod(int value) {
+        if (value != STORED && value != DEFLATED) {
             throw new IllegalArgumentException();
         }
-		compressionMethod = value;
-	}
+        compressionMethod = value;
+    }
 
-	/**
-	 * Sets the uncompressed size of this ZipEntry.
-	 * 
-	 * @param value
-	 *            the uncompressed size
-	 * 
-	 * @throws IllegalArgumentException
-	 *             if value is < 0 or > 0xFFFFFFFFL
-	 */
-	public void setSize(long value) {
-		if (value >= 0 && value <= 0xFFFFFFFFL) {
+    /**
+     * Sets the uncompressed size of this ZipEntry.
+     * 
+     * @param value
+     *            the uncompressed size
+     * 
+     * @throws IllegalArgumentException
+     *             if value is < 0 or > 0xFFFFFFFFL
+     */
+    public void setSize(long value) {
+        if (value >= 0 && value <= 0xFFFFFFFFL) {
             size = value;
         } else {
             throw new IllegalArgumentException();
         }
-	}
+    }
+
+    /**
+     * Sets the last modification time of this ZipEntry.
+     * 
+     * @param value
+     *            the last modification time as the number of milliseconds since
+     *            Jan. 1, 1970
+     */
+    public void setTime(long value) {
+        GregorianCalendar cal = new GregorianCalendar();
+        cal.setTime(new Date(value));
+        int year = cal.get(Calendar.YEAR);
+        if (year < 1980) {
+            modDate = 0x21;
+            time = 0;
+        } else {
+            modDate = cal.get(Calendar.DATE);
+            modDate = (cal.get(Calendar.MONTH) + 1 << 5) | modDate;
+            modDate = ((cal.get(Calendar.YEAR) - 1980) << 9) | modDate;
+            time = cal.get(Calendar.SECOND) >> 1;
+            time = (cal.get(Calendar.MINUTE) << 5) | time;
+            time = (cal.get(Calendar.HOUR_OF_DAY) << 11) | time;
+        }
+    }
 
-	/**
-	 * Sets the last modification time of this ZipEntry.
-	 * 
-	 * @param value
-	 *            the last modification time as the number of milliseconds since
-	 *            Jan. 1, 1970
-	 */
-	public void setTime(long value) {
-		GregorianCalendar cal = new GregorianCalendar();
-		cal.setTime(new Date(value));
-		int year = cal.get(Calendar.YEAR);
-		if (year < 1980) {
-			modDate = 0x21;
-			time = 0;
-		} else {
-			modDate = cal.get(Calendar.DATE);
-			modDate = (cal.get(Calendar.MONTH) + 1 << 5) | modDate;
-			modDate = ((cal.get(Calendar.YEAR) - 1980) << 9) | modDate;
-			time = cal.get(Calendar.SECOND) >> 1;
-			time = (cal.get(Calendar.MINUTE) << 5) | time;
-			time = (cal.get(Calendar.HOUR_OF_DAY) << 11) | time;
-		}
-	}
-
-	/**
-	 * Answers the string representation of this ZipEntry.
-	 * 
-	 * @return the string representation of this ZipEntry
-	 */
-	@Override
+    /**
+     * Answers the string representation of this ZipEntry.
+     * 
+     * @return the string representation of this ZipEntry
+     */
+    @Override
     public String toString() {
-		return name;
-	}
+        return name;
+    }
 
-	ZipEntry(String name, String comment, byte[] extra, long modTime,
-			long size, long compressedSize, long crc, int compressionMethod,
-			long modDate, long offset) {
-		this.name = name;
-		this.comment = comment;
-		this.extra = extra;
-		time = (int) modTime;
-		this.size = size;
-		this.compressedSize = compressedSize;
-		this.crc = crc;
-		this.compressionMethod = compressionMethod;
-		this.modDate = (int) modDate;
-		dataOffset = offset;
-	}
-
-	/**
-	 * Constructs a new ZipEntry using the values obtained from ze.
-	 * 
-	 * @param ze
-	 *            ZipEntry from which to obtain values.
-	 */
-	public ZipEntry(ZipEntry ze) {
-		name = ze.name;
-		comment = ze.comment;
-		time = ze.time;
-		size = ze.size;
-		compressedSize = ze.compressedSize;
-		crc = ze.crc;
-		compressionMethod = ze.compressionMethod;
-		modDate = ze.modDate;
-		extra = ze.extra;
-		dataOffset = ze.dataOffset;
-	}
-
-	/**
-	 * Returns a shallow copy of this entry
-	 * 
-	 * @return a copy of this entry
-	 */
-	@Override
+    ZipEntry(String name, String comment, byte[] extra, long modTime,
+            long size, long compressedSize, long crc, int compressionMethod,
+            long modDate, long offset) {
+        this.name = name;
+        this.comment = comment;
+        this.extra = extra;
+        time = (int) modTime;
+        this.size = size;
+        this.compressedSize = compressedSize;
+        this.crc = crc;
+        this.compressionMethod = compressionMethod;
+        this.modDate = (int) modDate;
+        dataOffset = offset;
+    }
+
+    /**
+     * Constructs a new ZipEntry using the values obtained from ze.
+     * 
+     * @param ze
+     *            ZipEntry from which to obtain values.
+     */
+    public ZipEntry(ZipEntry ze) {
+        name = ze.name;
+        comment = ze.comment;
+        time = ze.time;
+        size = ze.size;
+        compressedSize = ze.compressedSize;
+        crc = ze.crc;
+        compressionMethod = ze.compressionMethod;
+        modDate = ze.modDate;
+        extra = ze.extra;
+        dataOffset = ze.dataOffset;
+    }
+
+    /**
+     * Returns a shallow copy of this entry
+     * 
+     * @return a copy of this entry
+     */
+    @Override
     public Object clone() {
-		return new ZipEntry(this);
-	}
+        return new ZipEntry(this);
+    }
 
-	/**
-	 * Returns the hashCode for this ZipEntry.
-	 * 
-	 * @return the hashCode of the entry
-	 */
-	@Override
+    /**
+     * Returns the hashCode for this ZipEntry.
+     * 
+     * @return the hashCode of the entry
+     */
+    @Override
     public int hashCode() {
-		return name.hashCode();
-	}
+        return name.hashCode();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipException.java?view=diff&rev=556570&r1=556569&r2=556570
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipException.java Mon Jul 16 02:22:19 2007
@@ -17,7 +17,6 @@
 
 package java.util.zip;
 
-
 import java.io.IOException;
 
 /**
@@ -29,24 +28,24 @@
  */
 public class ZipException extends IOException {
 
-	private static final long serialVersionUID = 8000196834066748623L;
+    private static final long serialVersionUID = 8000196834066748623L;
 
-	/**
-	 * Constructs a new instance of this class with its walkback filled in.
-	 */
-	public ZipException() {
-		super();
-	}
+    /**
+     * Constructs a new instance of this class with its walkback filled in.
+     */
+    public ZipException() {
+        super();
+    }
 
-	/**
-	 * Constructs a new instance of this class with its walkback and message
-	 * filled in.
-	 * 
-	 * @param detailMessage
-	 *            String The detail message for the exception.
-	 */
-	public ZipException(String detailMessage) {
-		super(detailMessage);
-	}
+    /**
+     * Constructs a new instance of this class with its walkback and message
+     * filled in.
+     * 
+     * @param detailMessage
+     *            String The detail message for the exception.
+     */
+    public ZipException(String detailMessage) {
+        super(detailMessage);
+    }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java?view=diff&rev=556570&r1=556569&r2=556570
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java (original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java Mon Jul 16 02:22:19 2007
@@ -17,7 +17,6 @@
 
 package java.util.zip;
 
-
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
@@ -39,229 +38,237 @@
 
 public class ZipFile implements ZipConstants {
 
-	String fileName;
+    String fileName;
 
-	long descriptor = -1;
+    long descriptor = -1;
 
-	private int size = -1;
+    private int size = -1;
 
-	private int mode;
-	static {
+    private int mode;
+    static {
         System.loadLibrary("hyarchive"); //$NON-NLS-1$
-		ntvinit();
-	}
+        ntvinit();
+    }
 
-	/**
-	 * Open zip file for read.
-	 */
-	public static final int OPEN_READ = 1;
-
-	/**
-	 * Delete zip file when closed.
-	 */
-	public static final int OPEN_DELETE = 4;
-
-	/**
-	 * Constructs a new ZipFile opened on the specified File.
-	 * 
-	 * @param file
-	 *            the File
-	 */
-	public ZipFile(File file) throws ZipException, IOException {
-		this(file.getPath());
-	}
-
-	/**
-	 * Constructs a new ZipFile opened on the specified File using the specified
-	 * mode.
-	 * 
-	 * @param file
-	 *            the File
-	 * @param mode
-	 *            the mode to use, either OPEN_READ or OPEN_READ | OPEN_DELETE
-	 */
-	public ZipFile(File file, int mode) throws IOException {
-		if (mode == OPEN_READ || mode == (OPEN_READ | OPEN_DELETE)) {
-			fileName = file.getPath();
-			SecurityManager security = System.getSecurityManager();
-			if (security != null) {
-				security.checkRead(fileName);
-				if ((mode & OPEN_DELETE) != 0) {
-					security.checkDelete(fileName);
-				}
-			}
-			this.mode = mode;
-			openZip();
-		} else {
+    /**
+     * Open zip file for read.
+     */
+    public static final int OPEN_READ = 1;
+
+    /**
+     * Delete zip file when closed.
+     */
+    public static final int OPEN_DELETE = 4;
+
+    /**
+     * Constructs a new ZipFile opened on the specified File.
+     * 
+     * @param file
+     *            the File
+     */
+    public ZipFile(File file) throws ZipException, IOException {
+        this(file.getPath());
+    }
+
+    /**
+     * Constructs a new ZipFile opened on the specified File using the specified
+     * mode.
+     * 
+     * @param file
+     *            the File
+     * @param mode
+     *            the mode to use, either OPEN_READ or OPEN_READ | OPEN_DELETE
+     */
+    public ZipFile(File file, int mode) throws IOException {
+        if (mode == OPEN_READ || mode == (OPEN_READ | OPEN_DELETE)) {
+            fileName = file.getPath();
+            SecurityManager security = System.getSecurityManager();
+            if (security != null) {
+                security.checkRead(fileName);
+                if ((mode & OPEN_DELETE) != 0) {
+                    security.checkDelete(fileName);
+                }
+            }
+            this.mode = mode;
+            openZip();
+        } else {
             throw new IllegalArgumentException();
         }
-	}
+    }
 
-	/**
-	 * Constructs a new ZipFile opened on the specified file path name.
-	 * 
-	 * @param filename
-	 *            the file path name
-	 */
-	public ZipFile(String filename) throws IOException {
-		SecurityManager security = System.getSecurityManager();
-		if (security != null) {
-			security.checkRead(filename);
-		}
-		fileName = filename;
-		openZip();
-	}
-
-	private void openZip() throws IOException {
-		int result = openZipImpl(Util.getBytes(fileName));
-		if (result != 0) {
-			switch (result) {
-			case 1:
-				throw new ZipException(Messages.getString("archive.24", fileName)); //$NON-NLS-1$
-			case 2:
-				throw new ZipException(Messages.getString("archive.25", fileName)); //$NON-NLS-1$
-			default:
-				throw new OutOfMemoryError();
-			}
-		}
-	}
+    /**
+     * Constructs a new ZipFile opened on the specified file path name.
+     * 
+     * @param filename
+     *            the file path name
+     */
+    public ZipFile(String filename) throws IOException {
+        SecurityManager security = System.getSecurityManager();
+        if (security != null) {
+            security.checkRead(filename);
+        }
+        fileName = filename;
+        openZip();
+    }
+
+    private void openZip() throws IOException {
+        int result = openZipImpl(Util.getBytes(fileName));
+        if (result != 0) {
+            switch (result) {
+            case 1:
+                throw new ZipException(Messages.getString(
+                        "archive.24", fileName)); //$NON-NLS-1$
+            case 2:
+                throw new ZipException(Messages.getString(
+                        "archive.25", fileName)); //$NON-NLS-1$
+            default:
+                throw new OutOfMemoryError();
+            }
+        }
+    }
 
-	@Override
+    @Override
     protected void finalize() throws IOException {
-		close();
-	}
+        close();
+    }
+
+    /**
+     * Closes this ZipFile.
+     */
+    public synchronized void close() throws IOException {
+        if (descriptor != -1 && fileName != null) {
+            // Only close initialized instances
+            closeZipImpl(descriptor);
+            if ((mode & OPEN_DELETE) != 0) {
+                AccessController.doPrivileged(new PrivilegedAction<Object>() {
+                    public Object run() {
+                        new File(fileName).delete();
+                        return null;
+                    }
+                });
+            }
+        }
+    }
+
+    /**
+     * Answers all of the zip entries contained in this ZipFile.
+     * 
+     * @return an Enumeration of the zip entries
+     */
+    public Enumeration<? extends ZipEntry> entries() {
+        return new ZFEnum<ZipEntry>();
+    }
+
+    /**
+     * Gets the zip entry with the specified name from this ZipFile.
+     * 
+     * @param entryName
+     *            the name of the entry in the zip file
+     * @return a ZipEntry or null if the entry name does not exist in the zip
+     *         file
+     */
+    public ZipEntry getEntry(String entryName) {
+        if (entryName != null) {
+            ZipEntry entry = getEntryImpl(descriptor, entryName);
+            return entry;
+        }
+        throw new NullPointerException();
+    }
 
-	/**
-	 * Closes this ZipFile.
-	 */
-	public synchronized void close() throws IOException {
-		if (descriptor != -1 && fileName != null) {
-			// Only close initialized instances
-			closeZipImpl(descriptor);
-			if ((mode & OPEN_DELETE) != 0) {
-				AccessController.doPrivileged(new PrivilegedAction<Object>() {
-					public Object run() {
-						new File(fileName).delete();
-						return null;
-					}
-				});
-			}
-		}
-	}
-
-	/**
-	 * Answers all of the zip entries contained in this ZipFile.
-	 * 
-	 * @return an Enumeration of the zip entries
-	 */
-	public Enumeration<? extends ZipEntry> entries() {
-		return new ZFEnum<ZipEntry>();
-	}
-
-	/**
-	 * Gets the zip entry with the specified name from this ZipFile.
-	 * 
-	 * @param entryName
-	 *            the name of the entry in the zip file
-	 * @return a ZipEntry or null if the entry name does not exist in the zip
-	 *         file
-	 */
-	public ZipEntry getEntry(String entryName) {
-		if (entryName != null) {
-			ZipEntry entry = getEntryImpl(descriptor, entryName);
-			return entry;
-		}
-		throw new NullPointerException();
-	}
-
-	/**
-	 * Answers an input stream on the data of the specified ZipEntry.
-	 * 
-	 * @param entry
-	 *            the ZipEntry
-	 * @return an input stream on the ZipEntry data
-	 */
-	public InputStream getInputStream(ZipEntry entry) throws IOException {
-		if(descriptor == -1) {
-			/* the descriptor is set to -1 by native code to indicate the zip was closed */
-			throw new IllegalStateException();
-		}
-		byte[] buf = inflateEntryImpl2(descriptor, entry.getName());
-		if (buf == null) {
+    /**
+     * Answers an input stream on the data of the specified ZipEntry.
+     * 
+     * @param entry
+     *            the ZipEntry
+     * @return an input stream on the ZipEntry data
+     */
+    public InputStream getInputStream(ZipEntry entry) throws IOException {
+        if (descriptor == -1) {
+            /*
+             * the descriptor is set to -1 by native code to indicate the zip
+             * was closed
+             */
+            throw new IllegalStateException();
+        }
+        byte[] buf = inflateEntryImpl2(descriptor, entry.getName());
+        if (buf == null) {
             return null;
         }
-		return new ByteArrayInputStream(buf);
-}
+        return new ByteArrayInputStream(buf);
+    }
 
-	/**
-	 * Gets the file name of this ZipFile.
-	 * 
-	 * @return the file name of this ZipFile
-	 */
-	public String getName() {
-		return fileName;
-	}
-
-	private synchronized native int openZipImpl(byte[] fileName1);
-
-	private native void closeZipImpl(long descriptor1) throws IOException;
-
-	private native ZipEntry getEntryImpl(long descriptor1, String entryName);
-
-	private native byte[] inflateEntryImpl2(long descriptor1, String entryName)
-			throws ZipException;
-
-	/**
-	 * Returns the number of ZipEntries in this ZipFile.
-	 * 
-	 * @return Number of entries in this file
-	 */
-	public int size() {
-		if (size != -1) {
+    /**
+     * Gets the file name of this ZipFile.
+     * 
+     * @return the file name of this ZipFile
+     */
+    public String getName() {
+        return fileName;
+    }
+
+    private synchronized native int openZipImpl(byte[] fileName1);
+
+    private native void closeZipImpl(long descriptor1) throws IOException;
+
+    private native ZipEntry getEntryImpl(long descriptor1, String entryName);
+
+    private native byte[] inflateEntryImpl2(long descriptor1, String entryName)
+            throws ZipException;
+
+    /**
+     * Returns the number of ZipEntries in this ZipFile.
+     * 
+     * @return Number of entries in this file
+     */
+    public int size() {
+        if (size != -1) {
             return size;
         }
 
-		size = 0;
-		Enumeration<?> e = entries();
-		while (e.hasMoreElements()) {
-			size++;
-			e.nextElement();
-		}
-		return size;
-
-	}
-
-	private static native void ntvinit();
-
-	class ZFEnum<T extends ZipEntry> implements Enumeration<T> {
-		private final long nextEntryPointer;
-
-		private T current;
-
-		ZFEnum() {
-			nextEntryPointer = resetZip(descriptor);
-			current = getNextEntry(descriptor, nextEntryPointer);
-		}
-
-		private native long resetZip(long descriptor1);
-
-		private native T getNextEntry(long descriptor1, long nextEntryPointer1);
-
-		public boolean hasMoreElements() {
-			if(descriptor == -1) {
-				/* the descriptor is set to -1 by native code to indicate the zip was closed */
-				throw new IllegalStateException();
-			}
-			return current != null;
-		}
+        size = 0;
+        Enumeration<?> e = entries();
+        while (e.hasMoreElements()) {
+            size++;
+            e.nextElement();
+        }
+        return size;
+
+    }
+
+    private static native void ntvinit();
+
+    class ZFEnum<T extends ZipEntry> implements Enumeration<T> {
+        private final long nextEntryPointer;
+
+        private T current;
+
+        ZFEnum() {
+            nextEntryPointer = resetZip(descriptor);
+            current = getNextEntry(descriptor, nextEntryPointer);
+        }
+
+        private native long resetZip(long descriptor1);
+
+        private native T getNextEntry(long descriptor1, long nextEntryPointer1);
+
+        public boolean hasMoreElements() {
+            if (descriptor == -1) {
+                /*
+                 * the descriptor is set to -1 by native code to indicate the
+                 * zip was closed
+                 */
+                throw new IllegalStateException();
+            }
+            return current != null;
+        }
 
-		public T nextElement() {
-			if (current == null) {
+        public T nextElement() {
+            if (current == null) {
                 throw new NoSuchElementException();
             }
-			T ze = current;
-			current = getNextEntry(descriptor, nextEntryPointer);
-			return ze;
-		}
-	}
+            T ze = current;
+            current = getNextEntry(descriptor, nextEntryPointer);
+            return ze;
+        }
+    }
 }



Mime
View raw message