harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r556825 [3/10] - in /harmony/enhanced/classlib/branches/java6/modules: archive/src/main/java/java/util/jar/ archive/src/main/java/java/util/zip/ archive/src/main/java/org/apache/harmony/archive/internal/nls/ archive/src/main/java/org/apache...
Date Tue, 17 Jul 2007 06:31:04 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipEntry.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipEntry.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipEntry.java Mon Jul 16 23:30:22 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/branches/java6/modules/archive/src/main/java/java/util/zip/ZipException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipException.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipException.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipException.java Mon Jul 16 23:30:22 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/branches/java6/modules/archive/src/main/java/java/util/zip/ZipFile.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipFile.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipFile.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipFile.java Mon Jul 16 23:30:22 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;
+        }
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipInputStream.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipInputStream.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipInputStream.java Mon Jul 16 23:30:22 2007
@@ -17,7 +17,6 @@
 
 package java.util.zip;
 
-
 import java.io.EOFException;
 import java.io.IOException;
 import java.io.InputStream;
@@ -35,48 +34,48 @@
  * @see ZipFile
  */
 public class ZipInputStream extends InflaterInputStream implements ZipConstants {
-	static final int DEFLATED = 8;
+    static final int DEFLATED = 8;
 
-	static final int STORED = 0;
+    static final int STORED = 0;
 
-	static final int ZIPDataDescriptorFlag = 8;
+    static final int ZIPDataDescriptorFlag = 8;
 
-	static final int ZIPLocalHeaderVersionNeeded = 20;
+    static final int ZIPLocalHeaderVersionNeeded = 20;
 
-	private boolean zipClosed = false;
+    private boolean zipClosed = false;
 
-	private boolean entriesEnd = false;
+    private boolean entriesEnd = false;
 
-	private boolean hasDD = false;
+    private boolean hasDD = false;
 
-	private int entryIn = 0;
+    private int entryIn = 0;
 
-	private int inRead, lastRead = 0;
+    private int inRead, lastRead = 0;
 
-	ZipEntry currentEntry;
+    ZipEntry currentEntry;
 
-	private final byte[] hdrBuf = new byte[LOCHDR - LOCVER];
+    private final byte[] hdrBuf = new byte[LOCHDR - LOCVER];
 
-	private final CRC32 crc = new CRC32();
+    private final CRC32 crc = new CRC32();
 
-	private byte[] nameBuf = new byte[256];
+    private byte[] nameBuf = new byte[256];
 
-	private char[] charBuf = new char[256];
+    private char[] charBuf = new char[256];
 
-	/**
-	 * Constructs a new ZipInputStream on the specified input stream.
-	 * 
-	 * @param stream
-	 *            the input stream
-	 */
-	public ZipInputStream(InputStream stream) {
-		super(new PushbackInputStream(stream, BUF_SIZE), new Inflater(true));
-		if (stream == null) {
+    /**
+     * Constructs a new ZipInputStream on the specified input stream.
+     * 
+     * @param stream
+     *            the input stream
+     */
+    public ZipInputStream(InputStream stream) {
+        super(new PushbackInputStream(stream, BUF_SIZE), new Inflater(true));
+        if (stream == null) {
             throw new NullPointerException();
         }
-	}
+    }
 
-	/**
+    /**
      * Closes this ZipInputStream.
      */
     @Override
@@ -88,283 +87,283 @@
         }
     }
 
-	/**
-	 * Closes the current zip entry and positions to read the next entry.
-	 */
-	public void closeEntry() throws IOException {
-		if (zipClosed) {
+    /**
+     * Closes the current zip entry and positions to read the next entry.
+     */
+    public void closeEntry() throws IOException {
+        if (zipClosed) {
             throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$
         }
-		if (currentEntry == null) {
+        if (currentEntry == null) {
             return;
         }
-		if (currentEntry instanceof java.util.jar.JarEntry) {
-			Attributes temp = ((JarEntry) currentEntry).getAttributes();
-			if (temp != null && temp.containsKey("hidden")) { //$NON-NLS-1$
+        if (currentEntry instanceof java.util.jar.JarEntry) {
+            Attributes temp = ((JarEntry) currentEntry).getAttributes();
+            if (temp != null && temp.containsKey("hidden")) { //$NON-NLS-1$
                 return;
             }
-		}
-		// Ensure all entry bytes are read
-		skip(Long.MAX_VALUE);
-		int inB, out;
-		if (currentEntry.compressionMethod == DEFLATED) {
-			inB = inf.getTotalIn();
-			out = inf.getTotalOut();
-		} else {
-			inB = inRead;
-			out = inRead;
-		}
-		int diff = 0;
-		// Pushback any required bytes
-		if ((diff = entryIn - inB) != 0) {
+        }
+        // Ensure all entry bytes are read
+        skip(Long.MAX_VALUE);
+        int inB, out;
+        if (currentEntry.compressionMethod == DEFLATED) {
+            inB = inf.getTotalIn();
+            out = inf.getTotalOut();
+        } else {
+            inB = inRead;
+            out = inRead;
+        }
+        int diff = 0;
+        // Pushback any required bytes
+        if ((diff = entryIn - inB) != 0) {
             ((PushbackInputStream) in).unread(buf, len - diff, diff);
         }
 
-		if (hasDD) {
-			in.read(hdrBuf, 0, EXTHDR);
-			if (getLong(hdrBuf, 0) != EXTSIG) {
+        if (hasDD) {
+            in.read(hdrBuf, 0, EXTHDR);
+            if (getLong(hdrBuf, 0) != EXTSIG) {
                 throw new ZipException(Messages.getString("archive.1F")); //$NON-NLS-1$
             }
-			currentEntry.crc = getLong(hdrBuf, EXTCRC);
-			currentEntry.compressedSize = getLong(hdrBuf, EXTSIZ);
-			currentEntry.size = getLong(hdrBuf, EXTLEN);
-		}
-		if (currentEntry.crc != crc.getValue()) {
+            currentEntry.crc = getLong(hdrBuf, EXTCRC);
+            currentEntry.compressedSize = getLong(hdrBuf, EXTSIZ);
+            currentEntry.size = getLong(hdrBuf, EXTLEN);
+        }
+        if (currentEntry.crc != crc.getValue()) {
             throw new ZipException(Messages.getString("archive.20")); //$NON-NLS-1$
         }
-		if (currentEntry.compressedSize != inB || currentEntry.size != out) {
+        if (currentEntry.compressedSize != inB || currentEntry.size != out) {
             throw new ZipException(Messages.getString("archive.21")); //$NON-NLS-1$
         }
 
-		inf.reset();
-		lastRead = inRead = entryIn = len = 0;
-		crc.reset();
-		currentEntry = null;
-	}
-
-	/**
-	 * Reads the next zip entry from this ZipInputStream.
-	 */
-	public ZipEntry getNextEntry() throws IOException {
-		if (currentEntry != null) {
+        inf.reset();
+        lastRead = inRead = entryIn = len = 0;
+        crc.reset();
+        currentEntry = null;
+    }
+
+    /**
+     * Reads the next zip entry from this ZipInputStream.
+     */
+    public ZipEntry getNextEntry() throws IOException {
+        if (currentEntry != null) {
             closeEntry();
         }
-		if (entriesEnd) {
+        if (entriesEnd) {
             return null;
         }
 
-		int x = 0, count = 0;
-		while (count != 4) {
-			count += x = in.read(hdrBuf, count, 4 - count);
-			if (x == -1) {
+        int x = 0, count = 0;
+        while (count != 4) {
+            count += x = in.read(hdrBuf, count, 4 - count);
+            if (x == -1) {
                 return null;
             }
-		}
-		long hdr = getLong(hdrBuf, 0);
-		if (hdr == CENSIG) {
-			entriesEnd = true;
-			return null;
-		}
-		if (hdr != LOCSIG) {
+        }
+        long hdr = getLong(hdrBuf, 0);
+        if (hdr == CENSIG) {
+            entriesEnd = true;
+            return null;
+        }
+        if (hdr != LOCSIG) {
             return null;
         }
 
-		// Read the local header
-		count = 0;
-		while (count != (LOCHDR - LOCVER)) {
-			count += x = in.read(hdrBuf, count, (LOCHDR - LOCVER) - count);
-			if (x == -1) {
+        // Read the local header
+        count = 0;
+        while (count != (LOCHDR - LOCVER)) {
+            count += x = in.read(hdrBuf, count, (LOCHDR - LOCVER) - count);
+            if (x == -1) {
                 throw new EOFException();
             }
-		}
-		int version = getShort(hdrBuf, 0) & 0xff;
-		if (version > ZIPLocalHeaderVersionNeeded) {
+        }
+        int version = getShort(hdrBuf, 0) & 0xff;
+        if (version > ZIPLocalHeaderVersionNeeded) {
             throw new ZipException(Messages.getString("archive.22")); //$NON-NLS-1$
         }
-		int flags = getShort(hdrBuf, LOCFLG - LOCVER);
-		hasDD = ((flags & ZIPDataDescriptorFlag) == ZIPDataDescriptorFlag);
-		int cetime = getShort(hdrBuf, LOCTIM - LOCVER);
-		int cemodDate = getShort(hdrBuf, LOCTIM - LOCVER + 2);
-		int cecompressionMethod = getShort(hdrBuf, LOCHOW - LOCVER);
-		long cecrc = 0, cecompressedSize = 0, cesize = -1;
-		if (!hasDD) {
-			cecrc = getLong(hdrBuf, LOCCRC - LOCVER);
-			cecompressedSize = getLong(hdrBuf, LOCSIZ - LOCVER);
-			cesize = getLong(hdrBuf, LOCLEN - LOCVER);
-		}
-		int flen = getShort(hdrBuf, LOCNAM - LOCVER);
-		if (flen == 0) {
+        int flags = getShort(hdrBuf, LOCFLG - LOCVER);
+        hasDD = ((flags & ZIPDataDescriptorFlag) == ZIPDataDescriptorFlag);
+        int cetime = getShort(hdrBuf, LOCTIM - LOCVER);
+        int cemodDate = getShort(hdrBuf, LOCTIM - LOCVER + 2);
+        int cecompressionMethod = getShort(hdrBuf, LOCHOW - LOCVER);
+        long cecrc = 0, cecompressedSize = 0, cesize = -1;
+        if (!hasDD) {
+            cecrc = getLong(hdrBuf, LOCCRC - LOCVER);
+            cecompressedSize = getLong(hdrBuf, LOCSIZ - LOCVER);
+            cesize = getLong(hdrBuf, LOCLEN - LOCVER);
+        }
+        int flen = getShort(hdrBuf, LOCNAM - LOCVER);
+        if (flen == 0) {
             throw new ZipException(Messages.getString("archive.23")); //$NON-NLS-1$
         }
-		int elen = getShort(hdrBuf, LOCEXT - LOCVER);
+        int elen = getShort(hdrBuf, LOCEXT - LOCVER);
 
-		count = 0;
-		if (flen > nameBuf.length) {
-			nameBuf = new byte[flen];
-			charBuf = new char[flen];
-		}
-		while (count != flen) {
-			count += x = in.read(nameBuf, count, flen - count);
-			if (x == -1) {
+        count = 0;
+        if (flen > nameBuf.length) {
+            nameBuf = new byte[flen];
+            charBuf = new char[flen];
+        }
+        while (count != flen) {
+            count += x = in.read(nameBuf, count, flen - count);
+            if (x == -1) {
                 throw new EOFException();
             }
-		}
-		currentEntry = createZipEntry(Util.convertUTF8WithBuf(nameBuf, charBuf,
-				0, flen));
-		currentEntry.time = cetime;
-		currentEntry.modDate = cemodDate;
-		currentEntry.setMethod(cecompressionMethod);
-		if (cesize != -1) {
-			currentEntry.setCrc(cecrc);
-			currentEntry.setSize(cesize);
-			currentEntry.setCompressedSize(cecompressedSize);
-		}
-		if (elen > 0) {
-			count = 0;
-			byte[] e = new byte[elen];
-			while (count != elen) {
-				count += x = in.read(e, count, elen - count);
-				if (x == -1) {
+        }
+        currentEntry = createZipEntry(Util.convertUTF8WithBuf(nameBuf, charBuf,
+                0, flen));
+        currentEntry.time = cetime;
+        currentEntry.modDate = cemodDate;
+        currentEntry.setMethod(cecompressionMethod);
+        if (cesize != -1) {
+            currentEntry.setCrc(cecrc);
+            currentEntry.setSize(cesize);
+            currentEntry.setCompressedSize(cecompressedSize);
+        }
+        if (elen > 0) {
+            count = 0;
+            byte[] e = new byte[elen];
+            while (count != elen) {
+                count += x = in.read(e, count, elen - count);
+                if (x == -1) {
                     throw new EOFException();
                 }
-			}
-			currentEntry.setExtra(e);
-		}
-		return currentEntry;
-	}
-
-	/* Read 4 bytes from the buffer and store it as an int */
-
-	/**
-	 * Reads up to the specified number of uncompressed bytes into the buffer
-	 * starting at the offset.
-	 * 
-	 * @param buffer
-	 *            a byte array
-	 * @param start
-	 *            the starting offset into the buffer
-	 * @param length
-	 *            the number of bytes to read
-	 * @return the number of bytes read
-	 */
-	@Override
+            }
+            currentEntry.setExtra(e);
+        }
+        return currentEntry;
+    }
+
+    /* Read 4 bytes from the buffer and store it as an int */
+
+    /**
+     * Reads up to the specified number of uncompressed bytes into the buffer
+     * starting at the offset.
+     * 
+     * @param buffer
+     *            a byte array
+     * @param start
+     *            the starting offset into the buffer
+     * @param length
+     *            the number of bytes to read
+     * @return the number of bytes read
+     */
+    @Override
     public int read(byte[] buffer, int start, int length) throws IOException {
-		if (zipClosed) {
+        if (zipClosed) {
             throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$
         }
-		if (inf.finished() || currentEntry == null) {
+        if (inf.finished() || currentEntry == null) {
             return -1;
         }
-		// avoid int overflow, check null buffer
-		if (start <= buffer.length && length >= 0 && start >= 0
-				&& buffer.length - start >= length) {
-			if (currentEntry.compressionMethod == STORED) {
-				int csize = (int) currentEntry.size;
-				if (inRead >= csize) {
+        // avoid int overflow, check null buffer
+        if (start <= buffer.length && length >= 0 && start >= 0
+                && buffer.length - start >= length) {
+            if (currentEntry.compressionMethod == STORED) {
+                int csize = (int) currentEntry.size;
+                if (inRead >= csize) {
                     return -1;
                 }
-				if (lastRead >= len) {
-					lastRead = 0;
-					if ((len = in.read(buf)) == -1) {
+                if (lastRead >= len) {
+                    lastRead = 0;
+                    if ((len = in.read(buf)) == -1) {
                         return -1;
                     }
-					entryIn += len;
-				}
-				int toRead = length > len ? len - lastRead : length;
-				if ((csize - inRead) < toRead) {
+                    entryIn += len;
+                }
+                int toRead = length > len ? len - lastRead : length;
+                if ((csize - inRead) < toRead) {
                     toRead = csize - inRead;
                 }
-				System.arraycopy(buf, lastRead, buffer, start, toRead);
-				lastRead += toRead;
-				inRead += toRead;
-				crc.update(buffer, start, toRead);
-				return toRead;
-			}
-			if (inf.needsInput()) {
-				fill();
-				if (len > 0) {
+                System.arraycopy(buf, lastRead, buffer, start, toRead);
+                lastRead += toRead;
+                inRead += toRead;
+                crc.update(buffer, start, toRead);
+                return toRead;
+            }
+            if (inf.needsInput()) {
+                fill();
+                if (len > 0) {
                     entryIn += len;
                 }
-			}
-			int read = 0;
-			try {
-				read = inf.inflate(buffer, start, length);
-			} catch (DataFormatException e) {
-				throw new ZipException(e.getMessage());
-			}
-			if (read == 0 && inf.finished()) {
+            }
+            int read = 0;
+            try {
+                read = inf.inflate(buffer, start, length);
+            } catch (DataFormatException e) {
+                throw new ZipException(e.getMessage());
+            }
+            if (read == 0 && inf.finished()) {
                 return -1;
             }
-			crc.update(buffer, start, read);
-			return read;
-		}
-		throw new ArrayIndexOutOfBoundsException();
-	}
-
-	/**
-	 * Skips up to the specified number of bytes in the current zip entry.
-	 * 
-	 * @param value
-	 *            the number of bytes to skip
-	 * @return the number of bytes skipped
-	 */
-	@Override
+            crc.update(buffer, start, read);
+            return read;
+        }
+        throw new ArrayIndexOutOfBoundsException();
+    }
+
+    /**
+     * Skips up to the specified number of bytes in the current zip entry.
+     * 
+     * @param value
+     *            the number of bytes to skip
+     * @return the number of bytes skipped
+     */
+    @Override
     public long skip(long value) throws IOException {
-		if (value >= 0) {
-			long skipped = 0;
-			byte[] b = new byte[1024];
-			while (skipped != value) {
-				long rem = value - skipped;
-				int x = read(b, 0, (int) (b.length > rem ? rem : b.length));
-				if (x == -1) {
+        if (value >= 0) {
+            long skipped = 0;
+            byte[] b = new byte[1024];
+            while (skipped != value) {
+                long rem = value - skipped;
+                int x = read(b, 0, (int) (b.length > rem ? rem : b.length));
+                if (x == -1) {
                     return skipped;
                 }
-				skipped += x;
-			}
-			return skipped;
-		}
+                skipped += x;
+            }
+            return skipped;
+        }
         throw new IllegalArgumentException();
-}
+    }
 
-	/**
-	 * Answers 1 if the EOF has been reached, otherwise returns 0.
-	 * 
-	 * @return 0 after EOF of current entry, 1 otherwise
-	 */
-	@Override
+    /**
+     * Answers 1 if the EOF has been reached, otherwise returns 0.
+     * 
+     * @return 0 after EOF of current entry, 1 otherwise
+     */
+    @Override
     public int available() throws IOException {
-		if (zipClosed) {
+        if (zipClosed) {
             throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$
         }
-		if (currentEntry == null) {
+        if (currentEntry == null) {
             return 1;
         }
-		if (currentEntry.compressionMethod == STORED) {
-			if (inRead >= currentEntry.size) {
+        if (currentEntry.compressionMethod == STORED) {
+            if (inRead >= currentEntry.size) {
                 return 0;
             }
-		} else {
-			if (inf.finished()) {
+        } else {
+            if (inf.finished()) {
                 return 0;
             }
-		}
-		return 1;
-	}
-
-	protected ZipEntry createZipEntry(String name) {
-		return new ZipEntry(name);
-	}
-
-	private int getShort(byte[] buffer, int off) {
-		return (buffer[off] & 0xFF) | ((buffer[off + 1] & 0xFF) << 8);
-	}
-
-	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;
-	}
+        }
+        return 1;
+    }
+
+    protected ZipEntry createZipEntry(String name) {
+        return new ZipEntry(name);
+    }
+
+    private int getShort(byte[] buffer, int off) {
+        return (buffer[off] & 0xFF) | ((buffer[off + 1] & 0xFF) << 8);
+    }
+
+    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;
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java Mon Jul 16 23:30:22 2007
@@ -17,7 +17,6 @@
 
 package java.util.zip;
 
-
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -33,392 +32,393 @@
  * @see ZipEntry
  */
 public class ZipOutputStream extends DeflaterOutputStream implements
-		ZipConstants {
+        ZipConstants {
 
-	public static final int DEFLATED = 8;
+    public static final int DEFLATED = 8;
 
-	public static final int STORED = 0;
+    public static final int STORED = 0;
 
-	static final int ZIPDataDescriptorFlag = 8;
+    static final int ZIPDataDescriptorFlag = 8;
 
-	static final int ZIPLocalHeaderVersionNeeded = 20;
+    static final int ZIPLocalHeaderVersionNeeded = 20;
 
-	private String comment;
+    private String comment;
 
-	private final Vector<String> entries = new Vector<String>();
+    private final Vector<String> entries = new Vector<String>();
 
-	private int compressMethod = DEFLATED;
+    private int compressMethod = DEFLATED;
 
-	private int compressLevel = Deflater.DEFAULT_COMPRESSION;
+    private int compressLevel = Deflater.DEFAULT_COMPRESSION;
 
-	private ByteArrayOutputStream cDir = new ByteArrayOutputStream();
+    private ByteArrayOutputStream cDir = new ByteArrayOutputStream();
 
-	private ZipEntry currentEntry;
+    private ZipEntry currentEntry;
 
-	private final CRC32 crc = new CRC32();
+    private final CRC32 crc = new CRC32();
 
-	private int offset = 0, curOffset = 0, nameLength;
+    private int offset = 0, curOffset = 0, nameLength;
 
-	private byte[] nameBytes;
+    private byte[] nameBytes;
 
-	/**
-	 * Constructs a new ZipOutputStream on p1
-	 * 
-	 * @param p1
-	 *            OutputStream The InputStream to output to
-	 */
-	public ZipOutputStream(OutputStream p1) {
-		super(p1, new Deflater(Deflater.DEFAULT_COMPRESSION, true));
-	}
+    /**
+     * Constructs a new ZipOutputStream on p1
+     * 
+     * @param p1
+     *            OutputStream The InputStream to output to
+     */
+    public ZipOutputStream(OutputStream p1) {
+        super(p1, new Deflater(Deflater.DEFAULT_COMPRESSION, true));
+    }
 
-	/**
-	 * Closes the current ZipEntry if any. Closes the underlying output stream.
-	 * If the stream is already closed this method does nothing.
-	 * 
-	 * @exception IOException
-	 *                If an error occurs closing the stream
-	 */
-	@Override
+    /**
+     * Closes the current ZipEntry if any. Closes the underlying output stream.
+     * If the stream is already closed this method does nothing.
+     * 
+     * @exception IOException
+     *                If an error occurs closing the stream
+     */
+    @Override
     public void close() throws IOException {
-		if (out != null) {
-			finish();
-			out.close();
-			out = null;
-		}
-	}
-
-	/**
-	 * Closes the current ZipEntry. Any entry terminal data is written to the
-	 * underlying stream.
-	 * 
-	 * @exception IOException
-	 *                If an error occurs closing the entry
-	 */
-	public void closeEntry() throws IOException {
-		if (cDir == null) {
+        if (out != null) {
+            finish();
+            out.close();
+            out = null;
+        }
+    }
+
+    /**
+     * Closes the current ZipEntry. Any entry terminal data is written to the
+     * underlying stream.
+     * 
+     * @exception IOException
+     *                If an error occurs closing the entry
+     */
+    public void closeEntry() throws IOException {
+        if (cDir == null) {
             throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$
         }
-		if (currentEntry == null) {
+        if (currentEntry == null) {
             return;
         }
-		if (currentEntry.getMethod() == DEFLATED) {
-			super.finish();
-		}
-
-		// Verify values for STORED types
-		if (currentEntry.getMethod() == STORED) {
-			if (crc.getValue() != currentEntry.crc) {
+        if (currentEntry.getMethod() == DEFLATED) {
+            super.finish();
+        }
+
+        // Verify values for STORED types
+        if (currentEntry.getMethod() == STORED) {
+            if (crc.getValue() != currentEntry.crc) {
                 throw new ZipException(Messages.getString("archive.20")); //$NON-NLS-1$
             }
-			if (currentEntry.size != crc.tbytes) {
+            if (currentEntry.size != crc.tbytes) {
                 throw new ZipException(Messages.getString("archive.21")); //$NON-NLS-1$
             }
-		}
-		curOffset = LOCHDR;
+        }
+        curOffset = LOCHDR;
 
-		// Write the DataDescriptor
-		if (currentEntry.getMethod() != STORED) {
-			curOffset += EXTHDR;
-			writeLong(out, EXTSIG);
-			writeLong(out, currentEntry.crc = crc.getValue());
-			writeLong(out, currentEntry.compressedSize = def.getTotalOut());
-			writeLong(out, currentEntry.size = def.getTotalIn());
-		}
-		// Update the CentralDirectory
-		writeLong(cDir, CENSIG);
-		writeShort(cDir, ZIPLocalHeaderVersionNeeded); // Version created
-		writeShort(cDir, ZIPLocalHeaderVersionNeeded); // Version to extract
-		writeShort(cDir, currentEntry.getMethod() == STORED ? 0
-				: ZIPDataDescriptorFlag);
-		writeShort(cDir, currentEntry.getMethod());
-		writeShort(cDir, currentEntry.time);
-		writeShort(cDir, currentEntry.modDate);
-		writeLong(cDir, crc.getValue());
-		if (currentEntry.getMethod() == DEFLATED) {
-			curOffset += writeLong(cDir, def.getTotalOut());
-			writeLong(cDir, def.getTotalIn());
-		} else {
-			curOffset += writeLong(cDir, crc.tbytes);
-			writeLong(cDir, crc.tbytes);
-		}
-		curOffset += writeShort(cDir, nameLength);
-		if (currentEntry.extra != null) {
+        // Write the DataDescriptor
+        if (currentEntry.getMethod() != STORED) {
+            curOffset += EXTHDR;
+            writeLong(out, EXTSIG);
+            writeLong(out, currentEntry.crc = crc.getValue());
+            writeLong(out, currentEntry.compressedSize = def.getTotalOut());
+            writeLong(out, currentEntry.size = def.getTotalIn());
+        }
+        // Update the CentralDirectory
+        writeLong(cDir, CENSIG);
+        writeShort(cDir, ZIPLocalHeaderVersionNeeded); // Version created
+        writeShort(cDir, ZIPLocalHeaderVersionNeeded); // Version to extract
+        writeShort(cDir, currentEntry.getMethod() == STORED ? 0
+                : ZIPDataDescriptorFlag);
+        writeShort(cDir, currentEntry.getMethod());
+        writeShort(cDir, currentEntry.time);
+        writeShort(cDir, currentEntry.modDate);
+        writeLong(cDir, crc.getValue());
+        if (currentEntry.getMethod() == DEFLATED) {
+            curOffset += writeLong(cDir, def.getTotalOut());
+            writeLong(cDir, def.getTotalIn());
+        } else {
+            curOffset += writeLong(cDir, crc.tbytes);
+            writeLong(cDir, crc.tbytes);
+        }
+        curOffset += writeShort(cDir, nameLength);
+        if (currentEntry.extra != null) {
             curOffset += writeShort(cDir, currentEntry.extra.length);
         } else {
             writeShort(cDir, 0);
         }
-		String c;
-		if ((c = currentEntry.getComment()) != null) {
+        String c;
+        if ((c = currentEntry.getComment()) != null) {
             writeShort(cDir, c.length());
         } else {
             writeShort(cDir, 0);
         }
-		writeShort(cDir, 0); // Disk Start
-		writeShort(cDir, 0); // Internal File Attributes
-		writeLong(cDir, 0); // External File Attributes
-		writeLong(cDir, offset);
-		cDir.write(nameBytes);
-		nameBytes = null;
-		if (currentEntry.extra != null) {
+        writeShort(cDir, 0); // Disk Start
+        writeShort(cDir, 0); // Internal File Attributes
+        writeLong(cDir, 0); // External File Attributes
+        writeLong(cDir, offset);
+        cDir.write(nameBytes);
+        nameBytes = null;
+        if (currentEntry.extra != null) {
             cDir.write(currentEntry.extra);
         }
-		offset += curOffset;
-		if (c != null) {
+        offset += curOffset;
+        if (c != null) {
             cDir.write(c.getBytes());
         }
-		currentEntry = null;
-		crc.reset();
-		def.reset();
-		done = false;
-	}
-
-	/**
-	 * Indicates that all entries have been written to the stream. Any terminal
-	 * ZipFile information is written to the underlying stream.
-	 * 
-	 * @exception IOException
-	 *                If an error occurs while finishing
-	 */
-	@Override
+        currentEntry = null;
+        crc.reset();
+        def.reset();
+        done = false;
+    }
+
+    /**
+     * Indicates that all entries have been written to the stream. Any terminal
+     * ZipFile information is written to the underlying stream.
+     * 
+     * @exception IOException
+     *                If an error occurs while finishing
+     */
+    @Override
     public void finish() throws IOException {
-		if (out == null) {
+        if (out == null) {
             throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$
         }
-		if (cDir == null) {
+        if (cDir == null) {
             return;
         }
-		if (entries.size() == 0) {
+        if (entries.size() == 0) {
             throw new ZipException(Messages.getString("archive.28")); //$NON-NLS-1$;
         }
-		if (currentEntry != null) {
+        if (currentEntry != null) {
             closeEntry();
         }
-		int cdirSize = cDir.size();
-		// Write Central Dir End
-		writeLong(cDir, ENDSIG);
-		writeShort(cDir, 0); // Disk Number
-		writeShort(cDir, 0); // Start Disk
-		writeShort(cDir, entries.size()); // Number of entries
-		writeShort(cDir, entries.size()); // Number of entries
-		writeLong(cDir, cdirSize); // Size of central dir
-		writeLong(cDir, offset); // Offset of central dir
-		if (comment != null) {
-			writeShort(cDir, comment.length());
-			cDir.write(comment.getBytes());
-		} else {
+        int cdirSize = cDir.size();
+        // Write Central Dir End
+        writeLong(cDir, ENDSIG);
+        writeShort(cDir, 0); // Disk Number
+        writeShort(cDir, 0); // Start Disk
+        writeShort(cDir, entries.size()); // Number of entries
+        writeShort(cDir, entries.size()); // Number of entries
+        writeLong(cDir, cdirSize); // Size of central dir
+        writeLong(cDir, offset); // Offset of central dir
+        if (comment != null) {
+            writeShort(cDir, comment.length());
+            cDir.write(comment.getBytes());
+        } else {
             writeShort(cDir, 0);
         }
-		// Write the central dir
-		out.write(cDir.toByteArray());
-		cDir = null;
-
-	}
-
-	/**
-	 * Writes entry information for ze to the underlying stream. Data associated
-	 * with the entry can then be written using write(). After data is written
-	 * closeEntry() must be called to complete the storing of ze on the
-	 * underlying stream.
-	 * 
-	 * @param ze
-	 *            ZipEntry to store
-	 * @exception IOException
-	 *                If an error occurs storing the entry
-	 * @see #write
-	 */
-	public void putNextEntry(ZipEntry ze) throws java.io.IOException {
+        // Write the central dir
+        out.write(cDir.toByteArray());
+        cDir = null;
+
+    }
+
+    /**
+     * Writes entry information for ze to the underlying stream. Data associated
+     * with the entry can then be written using write(). After data is written
+     * closeEntry() must be called to complete the storing of ze on the
+     * underlying stream.
+     * 
+     * @param ze
+     *            ZipEntry to store
+     * @exception IOException
+     *                If an error occurs storing the entry
+     * @see #write
+     */
+    public void putNextEntry(ZipEntry ze) throws java.io.IOException {
         if (currentEntry != null) {
             closeEntry();
         }
-		if (ze.getMethod() == STORED
-				|| (compressMethod == STORED && ze.getMethod() == -1)) {
-			if (ze.crc == -1) {
+        if (ze.getMethod() == STORED
+                || (compressMethod == STORED && ze.getMethod() == -1)) {
+            if (ze.crc == -1) {
                 /* [MSG "archive.20", "Crc mismatch"] */
                 throw new ZipException(Messages.getString("archive.20")); //$NON-NLS-1$
             }
-			if (ze.size == -1 && ze.compressedSize == -1) {
+            if (ze.size == -1 && ze.compressedSize == -1) {
                 /* [MSG "archive.21", "Size mismatch"] */
                 throw new ZipException(Messages.getString("archive.21")); //$NON-NLS-1$
             }
-			if (ze.size != ze.compressedSize && ze.compressedSize != -1
-					&& ze.size != -1) {
+            if (ze.size != ze.compressedSize && ze.compressedSize != -1
+                    && ze.size != -1) {
                 /* [MSG "archive.21", "Size mismatch"] */
                 throw new ZipException(Messages.getString("archive.21")); //$NON-NLS-1$
             }
-		}
+        }
         /* [MSG "archive.1E", "Stream is closed"] */
-		if (cDir == null) {
+        if (cDir == null) {
             throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$
         }
-		if (entries.contains(ze.name)) {
+        if (entries.contains(ze.name)) {
             /* [MSG "archive.29", "Entry already exists: {0}"] */
             throw new ZipException(Messages.getString("archive.29", ze.name)); //$NON-NLS-1$
         }
-		nameLength = utf8Count(ze.name);
-		if (nameLength > 0xffff) {
+        nameLength = utf8Count(ze.name);
+        if (nameLength > 0xffff) {
             /* [MSG "archive.2A", "Name too long: {0}"] */
-            throw new IllegalArgumentException(Messages.getString("archive.2A", ze.name)); //$NON-NLS-1$
+            throw new IllegalArgumentException(Messages.getString(
+                    "archive.2A", ze.name)); //$NON-NLS-1$
         }
 
-		def.setLevel(compressLevel);
-		currentEntry = ze;
-		entries.add(currentEntry.name);
-		if (currentEntry.getMethod() == -1) {
+        def.setLevel(compressLevel);
+        currentEntry = ze;
+        entries.add(currentEntry.name);
+        if (currentEntry.getMethod() == -1) {
             currentEntry.setMethod(compressMethod);
         }
-		writeLong(out, LOCSIG); // Entry header
-		writeShort(out, ZIPLocalHeaderVersionNeeded); // Extraction version
-		writeShort(out, currentEntry.getMethod() == STORED ? 0
-				: ZIPDataDescriptorFlag);
-		writeShort(out, currentEntry.getMethod());
-		if (currentEntry.getTime() == -1) {
+        writeLong(out, LOCSIG); // Entry header
+        writeShort(out, ZIPLocalHeaderVersionNeeded); // Extraction version
+        writeShort(out, currentEntry.getMethod() == STORED ? 0
+                : ZIPDataDescriptorFlag);
+        writeShort(out, currentEntry.getMethod());
+        if (currentEntry.getTime() == -1) {
             currentEntry.setTime(System.currentTimeMillis());
         }
-		writeShort(out, currentEntry.time);
-		writeShort(out, currentEntry.modDate);
+        writeShort(out, currentEntry.time);
+        writeShort(out, currentEntry.modDate);
 
-		if (currentEntry.getMethod() == STORED) {
-			if (currentEntry.size == -1) {
+        if (currentEntry.getMethod() == STORED) {
+            if (currentEntry.size == -1) {
                 currentEntry.size = currentEntry.compressedSize;
             } else if (currentEntry.compressedSize == -1) {
                 currentEntry.compressedSize = currentEntry.size;
             }
-			writeLong(out, currentEntry.crc);
-			writeLong(out, currentEntry.size);
-			writeLong(out, currentEntry.size);
-		} else {
-			writeLong(out, 0);
-			writeLong(out, 0);
-			writeLong(out, 0);
-		}
-		writeShort(out, nameLength);
-		if (currentEntry.extra != null) {
+            writeLong(out, currentEntry.crc);
+            writeLong(out, currentEntry.size);
+            writeLong(out, currentEntry.size);
+        } else {
+            writeLong(out, 0);
+            writeLong(out, 0);
+            writeLong(out, 0);
+        }
+        writeShort(out, nameLength);
+        if (currentEntry.extra != null) {
             writeShort(out, currentEntry.extra.length);
         } else {
             writeShort(out, 0);
         }
-		nameBytes = toUTF8Bytes(currentEntry.name, nameLength);
-		out.write(nameBytes);
-		if (currentEntry.extra != null) {
+        nameBytes = toUTF8Bytes(currentEntry.name, nameLength);
+        out.write(nameBytes);
+        if (currentEntry.extra != null) {
             out.write(currentEntry.extra);
         }
-	}
+    }
 
-	/**
-	 * Sets the ZipFile comment associated with the file being written.
-	 * 
-	 */
-	public void setComment(String comment) {
-		if (comment.length() > 0xFFFF) {
+    /**
+     * Sets the ZipFile comment associated with the file being written.
+     * 
+     */
+    public void setComment(String comment) {
+        if (comment.length() > 0xFFFF) {
             throw new IllegalArgumentException(Messages.getString("archive.2B")); //$NON-NLS-1$
         }
-		this.comment = comment;
-	}
+        this.comment = comment;
+    }
 
-	/**
-	 * Sets the compression level to be used for writing entry data. This level
-	 * may be set on a per entry basis. level must have a value between 0 and
-	 * 10.
-	 * 
-	 */
-	public void setLevel(int level) {
-		if (level < Deflater.DEFAULT_COMPRESSION
-				|| level > Deflater.BEST_COMPRESSION) {
+    /**
+     * Sets the compression level to be used for writing entry data. This level
+     * may be set on a per entry basis. level must have a value between 0 and
+     * 10.
+     * 
+     */
+    public void setLevel(int level) {
+        if (level < Deflater.DEFAULT_COMPRESSION
+                || level > Deflater.BEST_COMPRESSION) {
             throw new IllegalArgumentException();
         }
-		compressLevel = level;
-	}
+        compressLevel = level;
+    }
 
-	/**
-	 * Sets the compression method to be used when compressing entry data.
-	 * method must be one of STORED or DEFLATED.
-	 * 
-	 * @param method
-	 *            Compression method to use
-	 */
-	public void setMethod(int method) {
-		if (method != STORED && method != DEFLATED) {
+    /**
+     * Sets the compression method to be used when compressing entry data.
+     * method must be one of STORED or DEFLATED.
+     * 
+     * @param method
+     *            Compression method to use
+     */
+    public void setMethod(int method) {
+        if (method != STORED && method != DEFLATED) {
             throw new IllegalArgumentException();
         }
-		compressMethod = method;
+        compressMethod = method;
 
-	}
+    }
 
-	private long writeLong(OutputStream os, long i) throws java.io.IOException {
-		// Write out the long value as an unsigned int
-		os.write((int) (i & 0xFF));
-		os.write((int) (i >> 8) & 0xFF);
-		os.write((int) (i >> 16) & 0xFF);
-		os.write((int) (i >> 24) & 0xFF);
-		return i;
-	}
-
-	private int writeShort(OutputStream os, int i) throws java.io.IOException {
-		os.write(i & 0xFF);
-		os.write((i >> 8) & 0xFF);
-		return i;
-
-	}
-
-	/**
-	 * Writes data for the current entry to the underlying stream.
-	 * 
-	 * @exception IOException
-	 *                If an error occurs writing to the stream
-	 */
-	@Override
+    private long writeLong(OutputStream os, long i) throws java.io.IOException {
+        // Write out the long value as an unsigned int
+        os.write((int) (i & 0xFF));
+        os.write((int) (i >> 8) & 0xFF);
+        os.write((int) (i >> 16) & 0xFF);
+        os.write((int) (i >> 24) & 0xFF);
+        return i;
+    }
+
+    private int writeShort(OutputStream os, int i) throws java.io.IOException {
+        os.write(i & 0xFF);
+        os.write((i >> 8) & 0xFF);
+        return i;
+
+    }
+
+    /**
+     * Writes data for the current entry to the underlying stream.
+     * 
+     * @exception IOException
+     *                If an error occurs writing to the stream
+     */
+    @Override
     public void write(byte[] buffer, int off, int nbytes)
-			throws java.io.IOException {
-		// avoid int overflow, check null buf
-		if ((off < 0 || (nbytes < 0) || off > buffer.length)
-				|| (buffer.length - off < nbytes)) {
-			throw new IndexOutOfBoundsException();
-		}
+            throws java.io.IOException {
+        // avoid int overflow, check null buf
+        if ((off < 0 || (nbytes < 0) || off > buffer.length)
+                || (buffer.length - off < nbytes)) {
+            throw new IndexOutOfBoundsException();
+        }
 
-		if (currentEntry == null) {
+        if (currentEntry == null) {
             /* [MSG "archive.2C", "No active entry"] */
             throw new ZipException(Messages.getString("archive.2C")); //$NON-NLS-1$
         }
 
-		if (currentEntry.getMethod() == STORED) {
+        if (currentEntry.getMethod() == STORED) {
             out.write(buffer, off, nbytes);
         } else {
             super.write(buffer, off, nbytes);
         }
-		crc.update(buffer, off, nbytes);
-	}
+        crc.update(buffer, off, nbytes);
+    }
 
-	static int utf8Count(String value) {
-		int total = 0;
-		for (int i = value.length(); --i >= 0;) {
-			char ch = value.charAt(i);
-			if (ch < 0x80) {
+    static int utf8Count(String value) {
+        int total = 0;
+        for (int i = value.length(); --i >= 0;) {
+            char ch = value.charAt(i);
+            if (ch < 0x80) {
                 total++;
             } else if (ch < 0x800) {
                 total += 2;
             } else {
                 total += 3;
             }
-		}
-		return total;
-	}
-
-	static byte[] toUTF8Bytes(String value, int length) {
-		byte[] result = new byte[length];
-		int pos = result.length;
-		for (int i = value.length(); --i >= 0;) {
-			char ch = value.charAt(i);
-			if (ch < 0x80) {
+        }
+        return total;
+    }
+
+    static byte[] toUTF8Bytes(String value, int length) {
+        byte[] result = new byte[length];
+        int pos = result.length;
+        for (int i = value.length(); --i >= 0;) {
+            char ch = value.charAt(i);
+            if (ch < 0x80) {
                 result[--pos] = (byte) ch;
             } else if (ch < 0x800) {
-				result[--pos] = (byte) (0x80 | (ch & 0x3f));
-				result[--pos] = (byte) (0xc0 | (ch >> 6));
-			} else {
-				result[--pos] = (byte) (0x80 | (ch & 0x3f));
-				result[--pos] = (byte) (0x80 | ((ch >> 6) & 0x3f));
-				result[--pos] = (byte) (0xe0 | (ch >> 12));
-			}
-		}
-		return result;
-	}
+                result[--pos] = (byte) (0x80 | (ch & 0x3f));
+                result[--pos] = (byte) (0xc0 | (ch >> 6));
+            } else {
+                result[--pos] = (byte) (0x80 | (ch & 0x3f));
+                result[--pos] = (byte) (0x80 | ((ch >> 6) & 0x3f));
+                result[--pos] = (byte) (0xe0 | (ch >> 12));
+            }
+        }
+        return result;
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/Messages.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/Messages.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/Messages.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/Messages.java Mon Jul 16 23:30:22 2007
@@ -23,7 +23,6 @@
 
 package org.apache.harmony.archive.internal.nls;
 
-
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Locale;
@@ -138,13 +137,13 @@
             try {
                 format = bundle.getString(msg);
             } catch (MissingResourceException e) {
-                //ignore
+                // ignore
             }
         }
 
         return format(format, args);
     }
-    
+
     /**
      * Generates a formatted text string given a source string containing
      * "argument markers" of the form "{argNum}" where each argNum must be in
@@ -167,7 +166,7 @@
         String[] argStrings = new String[args.length];
         for (int i = 0; i < args.length; ++i) {
             if (args[i] == null)
-                argStrings[i] = "<null>";	//$NON-NLS-1$
+                argStrings[i] = "<null>"; //$NON-NLS-1$
             else
                 argStrings[i] = args[i].toString();
         }
@@ -191,16 +190,16 @@
                             10);
                     if (argnum < 0 || format.charAt(i + 2) != '}') {
                         // Bad format, just print and loop.
-						answer.append(format.substring(lastI, i + 1));
-						lastI = i + 1;
+                        answer.append(format.substring(lastI, i + 1));
+                        lastI = i + 1;
                     } else {
                         // Got a good one!
                         answer.append(format.substring(lastI, i));
                         if (argnum >= argStrings.length)
-                            answer.append("<missing argument>");	//$NON-NLS-1$
+                            answer.append("<missing argument>"); //$NON-NLS-1$
                         else
                             answer.append(argStrings[argnum]);
-						lastI = i + 3;
+                        lastI = i + 3;
                     }
                 }
             }
@@ -224,11 +223,12 @@
                     .doPrivileged(new PrivilegedAction<Object>() {
                         public Object run() {
                             return ResourceBundle.getBundle(resource, locale,
-                                    loader != null ? loader : ClassLoader.getSystemClassLoader());
+                                    loader != null ? loader : ClassLoader
+                                            .getSystemClassLoader());
                         }
                     });
         } catch (MissingResourceException e) {
-            //ignore
+            // ignore
         }
         return null;
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/util/Util.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/util/Util.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/util/Util.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/util/Util.java Mon Jul 16 23:30:22 2007
@@ -65,19 +65,19 @@
         }
         return buffer.toString();
     }
-    
-    public static final boolean equalsIgnoreCase(String s1, String s2){
+
+    public static final boolean equalsIgnoreCase(String s1, String s2) {
         if (s1 == s2) {
             return true;
         }
-        
+
         if (s1 == null || s2 == null || s1.length() != s2.length()) {
             return false;
         }
 
         char c1, c2;
-        
-        for (int i=0; i< s1.length(); i++) {
+
+        for (int i = 0; i < s1.length(); i++) {
             if ((c1 = s1.charAt(i)) != (c2 = s2.charAt(i))
                     && toASCIIUpperCase(c1) != toASCIIUpperCase(c2)) {
                 return false;

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/image/BufferedImage.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/image/BufferedImage.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/image/BufferedImage.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/image/BufferedImage.java Mon Jul 16 23:30:22 2007
@@ -596,7 +596,7 @@
             return true;
         }
         // awt.226=Both tileX and tileY are not equal to 0
-        throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.226")); //$NON-NLS-1$
+        throw new IllegalArgumentException(Messages.getString("awt.226")); //$NON-NLS-1$
     }
 
     public void releaseWritableTile(int tileX, int tileY) {

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/ParsingTables.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/ParsingTables.cpp?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/ParsingTables.cpp (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/ParsingTables.cpp Mon Jul 16 23:30:22 2007
@@ -377,21 +377,21 @@
 						}
 						subFamilyName[j] = 0;
 
-/*#ifdef WIN32
+//#ifdef WIN32
 
-#define COMPARE_IT		(!_wcsicmp((fwchar_t *)subFamilyName,L"Italic"))
-#define COMPARE_BD		(!_wcsicmp((fwchar_t *)subFamilyName,L"Bold"))
-#define COMPARE_BDIT	(!_wcsicmp((fwchar_t *)subFamilyName,L"Bold Italic"))
-#define COMPARE_REG		(!_wcsicmp((fwchar_t *)subFamilyName,L"Regular") || !_wcsicmp((fwchar_t *)subFamilyName,L"Normal"))
+#define COMPARE_IT		(!fwcscmp((ufshort *)subFamilyName,"Italic"))
+#define COMPARE_BD		(!fwcscmp((ufshort *)subFamilyName,"Bold"))
+#define COMPARE_BDIT	(!fwcscmp((ufshort *)subFamilyName,"Bold Italic"))
+#define COMPARE_REG		(!fwcscmp((ufshort *)subFamilyName,"Regular") || !fwcscmp((fwchar_t *)subFamilyName,"Normal"))
 
-#else*/
+/*#else
 
 #define COMPARE_IT		(compare((fwchar_t *)subFamilyName, "Italic"))
 #define COMPARE_BD		(compare((fwchar_t *)subFamilyName, "Bold"))
 #define COMPARE_BDIT	(compare((fwchar_t *)subFamilyName, "Bold Italic"))
 #define COMPARE_REG		(compare((fwchar_t *)subFamilyName, "Regular") || compare((fwchar_t *)subFamilyName, "Normal"))
 
-//#endif
+#endif*/
 
 						if COMPARE_IT
 						{

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/TypeDefinition.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/TypeDefinition.cpp?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/TypeDefinition.cpp (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/TypeDefinition.cpp Mon Jul 16 23:30:22 2007
@@ -33,10 +33,29 @@
 	return counter;
 }
 
+fint fwcscmp(fwchar_t* str1, fchar* str2)
+{
+    if (str1 == 0 || str2 == 0)
+        return (fint)(str1 - (fwchar_t*)str2);
+        
+	fwchar_t* tmpstr1 = str1; 
+	fchar* tmpstr2 = str2;
+	while(*tmpstr1 != 0 || *tmpstr2 !=0)
+	{
+        if (*tmpstr1 != (fwchar_t)(*tmpstr2))
+			return -1;
+
+		tmpstr1++;
+		tmpstr2++;
+	}
+
+	return 0;
+}
+
 fint fwcscmp(fwchar_t* str1, fwchar_t* str2)
 {
     if (str1 == 0 || str2 == 0)
-        return str1 - str2;
+        return (fint)(str1 - str2);
         
 	fwchar_t* tmpstr1 = str1; 
 	fwchar_t* tmpstr2 = str2;

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/TypeDefinition.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/TypeDefinition.h?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/TypeDefinition.h (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/TypeDefinition.h Mon Jul 16 23:30:22 2007
@@ -30,6 +30,7 @@
 typedef unsigned short fwchar_t;
 
 fint fwcslen(fwchar_t* str);
+fint fwcscmp(fwchar_t* str1, fchar* str2);
 fint fwcscmp(fwchar_t* str1, fwchar_t* str2);
 
 #endif

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/test/api/java/common/java/awt/image/BufferedImageTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/test/api/java/common/java/awt/image/BufferedImageTest.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/test/api/java/common/java/awt/image/BufferedImageTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/test/api/java/common/java/awt/image/BufferedImageTest.java Mon Jul 16 23:30:22 2007
@@ -28,12 +28,14 @@
     
     public final void testGetWritableTile(){
         BufferedImage bi = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
-        WritableRaster tile = null;
-        try{
-            tile = bi.getWritableTile(1, 1);
-            assertTrue(true);
-        }catch(ArrayIndexOutOfBoundsException e){
-            fail("Unexpected ArrayIndexOutOfBoundsException was thrown");
+        bi.getWritableTile(1, 1);
+        
+        //Regression test for HARMONY-1658
+        BufferedImage img = new BufferedImage(10, 16, BufferedImage.TYPE_4BYTE_ABGR);
+        try {
+            img.isTileWritable(1,1);
+            fail("IllegalArgumentException is expected");
+        } catch (IllegalArgumentException iae) {
         }
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/beans/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/META-INF/MANIFEST.MF?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/META-INF/MANIFEST.MF (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/META-INF/MANIFEST.MF Mon Jul 16 23:30:22 2007
@@ -24,10 +24,11 @@
  java.util,
  java.util.regex;resolution:=optional,
  javax.accessibility;resolution:=optional,
+ javax.xml.parsers,
  org.apache.harmony.kernel.vm,
+ org.apache.harmony.testframework.serialization;hy_usage=test;resolution:=optional,
  org.xml.sax,
  org.xml.sax.helpers,
- org.apache.harmony.testframework.serialization;hy_usage=test;resolution:=optional,
  tests.util;hy_usage=test;resolution:=optional
 Export-Package: java.beans,
  java.beans.beancontext

Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/Beans.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/Beans.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/Beans.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/Beans.java Mon Jul 16 23:30:22 2007
@@ -116,10 +116,12 @@
         guiAvailable = isGuiAvailable;
     }
 
-    public static synchronized void setDesignTime(boolean isDesignTime)
+    public static void setDesignTime(boolean isDesignTime)
             throws SecurityException {
         checkPropertiesAccess();
-        designTime = isDesignTime;
+        synchronized(Beans.class){
+            designTime = isDesignTime;
+        }
     }
 
     public static synchronized boolean isGuiAvailable() {



Mime
View raw message