harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r446478 [3/11] - in /incubator/harmony/enhanced/classlib/trunk/modules/archive: ./ .settings/ META-INF/ make/ src/main/java/java/util/jar/ src/main/java/java/util/zip/ src/main/java/org/apache/harmony/archive/internal/pack200/ src/main/nati...
Date Fri, 15 Sep 2006 02:40:36 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Manifest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Manifest.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Manifest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Manifest.java Thu Sep 14 19:40:33 2006
@@ -1,333 +1,333 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.util.jar;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-import java.security.AccessController;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.harmony.luni.util.PriviAction;
-
-/**
- * The Manifest class is used to obtain attribute information for a JarFile and
- * it's entries.
- * 
- */
-public class Manifest implements Cloneable {
-	private Attributes mainAttributes = new Attributes();
-
-	private HashMap<String, Attributes> entryAttributes = new HashMap<String, Attributes>();
-
-	private HashMap<String, byte[]> chunks;
-
-	/*The data chunk of Main Attributes in the manifest is needed in verification.*/
-	private byte[] mainAttributesChunk;
-	
-	/**
-	 * Constructs a new Manifest instance.
-	 */
-	public Manifest() {
-        super();
-	}
-
-	/**
-	 * Constructs a new Manifest instance using the attributes obtained from is.
-	 * 
-	 * @param is
-	 *            InputStream to parse for attributes
-	 * 
-	 * @throws IOException
-	 *             if an IO error occurs while creating this Manifest
-	 * 
-	 */
-	public Manifest(InputStream is) throws IOException {
-		read(is);
-	}
-
-	Manifest(InputStream is, boolean readChunks) throws IOException {
-		if (readChunks) {
-			chunks = new HashMap<String, byte[]>();
-        }
-		read(is);
-	}
-
-	/**
-	 * Resets the both the mainAttributes as well as the entry Attributes
-	 * associated with this Manifest.
-	 */
-	public void clear() {
-		entryAttributes.clear();
-		mainAttributes.clear();
-	}
-
-	/**
-	 * Returns the Attributes associated with the parameter entry name
-	 * 
-	 * @param name
-	 *            The name of the entry to obtain Attributes for.
-	 * @return The Attributes for the entry or null if the entry does not exist.
-	 */
-	public Attributes getAttributes(String name) {
-		return getEntries().get(name);
-	}
-
-	/**
-	 * Returns a Map containing the Attributes for each entry in the Manifest.
-	 * 
-	 * @return A Map of entry attributes
-	 */
-	public Map<String, Attributes> getEntries() {
-		return entryAttributes;
-	}
-
-	/**
-	 * Returns the main Attributes of the JarFile.
-	 * 
-	 * @return Main Attributes associated with the source JarFile
-	 */
-	public Attributes getMainAttributes() {
-		return mainAttributes;
-	}
-
-	/**
-	 * Constructs a new Manifest instance. The new instance will have the same
-	 * attributes as those found in the parameter Manifest.
-	 * 
-	 * @param man
-	 *            Manifest instance to obtain attributes from
-	 */
-	public Manifest(Manifest man) {
-		mainAttributes = (Attributes) man.mainAttributes.clone();
-		entryAttributes = (HashMap<String, Attributes>) man.entryAttributes.clone();
-	}
-
-	/**
-	 * Creates a copy of this Manifest. The returned Manifest will equal the
-	 * Manifest from which it was cloned.
-	 * 
-	 * @return A copy of the receiver.
-	 */
-	public Object clone() {
-		return new Manifest(this);
-	}
-
-	static class WriteManifest {
-		private static final int LIMIT = 70;
-
-		private static byte[] sepBuf = new byte[] { '\r', '\n' };
-
-		private static Attributes.Name nameAttribute = new Attributes.Name(
-				"Name", false);
-
-		byte[] oneByte = new byte[1];
-
-		char[] oneChar = new char[1];
-
-		private Charset charset;
-
-		private byte[] outBuf = new byte[LIMIT];
-
-		OutputStream os;
-
-		/**
-		 * Writes out a manifest entry.
-		 */
-		private void writeEntry(Attributes.Name name, String value)
-				throws IOException {
-			int offset = 0, limit = LIMIT;
-			byte[] out = (name.toString() + ": ").getBytes("ISO8859_1");
-			if (out.length > limit) {
-				while (out.length - offset >= limit) {
-					int len = out.length - offset;
-					if (len > limit) {
-                        len = limit;
-                    }
-					if (offset > 0) {
-                        os.write(' ');
-                    }
-					os.write(out, offset, len);
-					os.write(sepBuf);
-					offset += len;
-					limit = LIMIT - 1;
-				}
-			}
-			int size = out.length - offset;
-			System.arraycopy(out, offset, outBuf, 0, size);
-			for (int i = 0; i < value.length(); i++) {
-				oneChar[0] = value.charAt(i);
-				byte[] buf;
-				if (oneChar[0] < 128 || charset == null) {
-					oneByte[0] = (byte) oneChar[0];
-					buf = oneByte;
-				} else {
-                    buf = charset.encode(CharBuffer.wrap(oneChar, 0, 1)).array();
-                }
-				if (size + buf.length > limit) {
-					if (limit != LIMIT) {
-                        os.write(' ');
-                    }
-					os.write(outBuf, 0, size);
-					os.write(sepBuf);
-					limit = LIMIT - 1;
-					size = 0;
-				}
-				if (buf.length == 1) {
-                    outBuf[size] = buf[0];
-                } else {
-                    System.arraycopy(buf, 0, outBuf, size, buf.length);
-                }
-				size += buf.length;
-			}
-			if (size > 0) {
-				if (limit != LIMIT) {
-                    os.write(' ');
-                }
-				os.write(outBuf, 0, size);
-				os.write(sepBuf);
-			}
-		}
-
-		/**
-		 * Writes out the attribute information of the receiver to the specified
-		 * OutputStream
-		 * 
-		 * 
-		 * @param manifest
-		 *            the attribute information of the receiver
-		 * @param out
-		 *            The OutputStream to write to.
-		 * 
-		 * @throws IOException
-		 *             If an error occurs writing the Manifest
-		 */
-		void write(Manifest manifest, OutputStream out) throws IOException {
-			os = out;
-			String encoding = AccessController
-					.doPrivileged(new PriviAction<String>("manifest.write.encoding"));
-			if (encoding != null) {
-				if ("".equals(encoding)) {
-                    encoding = "UTF8";
-                }
-				charset = Charset.forName(encoding);				
-			}
-			String version = manifest.mainAttributes
-					.getValue(Attributes.Name.MANIFEST_VERSION);
-			if (version != null) {
-				writeEntry(Attributes.Name.MANIFEST_VERSION, version);
-				Iterator<?> entries = manifest.mainAttributes.keySet().iterator();
-				while (entries.hasNext()) {
-					Attributes.Name name = (Attributes.Name) entries.next();
-					if (!name.equals(Attributes.Name.MANIFEST_VERSION)) {
-                        writeEntry(name, manifest.mainAttributes.getValue(name));
-                    }
-				}
-			}
-			os.write(sepBuf);
-			Iterator<String> i = manifest.entryAttributes.keySet().iterator();
-			while (i.hasNext()) {
-				String key = i.next();
-				writeEntry(nameAttribute, key);
-				Attributes attrib = manifest.entryAttributes.get(key);
-				Iterator<?> entries = attrib.keySet().iterator();
-				while (entries.hasNext()) {
-					Attributes.Name name = (Attributes.Name) entries.next();
-					writeEntry(name, attrib.getValue(name));
-				}
-				os.write(sepBuf);
-			}
-		}
-	}
-
-	/**
-	 * Writes out the attribute information of the receiver to the specified
-	 * OutputStream
-	 * 
-	 * @param os
-	 *            The OutputStream to write to.
-	 * 
-	 * @throws IOException
-	 *             If an error occurs writing the Manifest
-	 */
-	public void write(OutputStream os) throws IOException {
-		new WriteManifest().write(this, os);
-	}
-
-	/**
-	 * Constructs a new Manifest instance obtaining Attribute information from
-	 * the parameter InputStream.
-	 * 
-	 * @param is
-	 *            The InputStream to read from
-	 * @throws IOException
-	 *             If an error occurs reading the Manifest.
-	 */
-	public void read(InputStream is) throws IOException {
-		InitManifest initManifest = new InitManifest(is, mainAttributes, entryAttributes, chunks, null);
-		mainAttributesChunk = initManifest.getMainAttributesChunk();
-	}
-
-	/**
-	 * Returns the hashCode for this instance.
-	 * 
-	 * @return This Manifest's hashCode
-	 */
-	public int hashCode() {
-		return mainAttributes.hashCode() ^ entryAttributes.hashCode();
-	}
-
-	/**
-	 * Determines if the receiver is equal to the parameter Object. Two
-	 * Manifests are equal if they have identical main Attributes as well as
-	 * identical entry Attributes.
-	 * 
-	 * @param o
-	 *            The Object to compare against.
-	 * @return <code>true</code> if the manifests are equal,
-	 *         <code>false</code> otherwise
-	 */
-	public boolean equals(Object o) {
-		if (o == null) {
-            return false;
-        }
-		if (o.getClass() != this.getClass()) {
-            return false;
-        }
-		if (!mainAttributes.equals(((Manifest) o).mainAttributes)) {
-            return false;
-        }
-		return entryAttributes.equals(((Manifest) o).entryAttributes);
-	}
-
-	byte[] getChunk(String name) {
-		return chunks.get(name);
-	}
-
-	void removeChunks() {
-		chunks = null;
-	}
-	
-	byte[] getMainAttributesChunk()
-	{
-		return this.mainAttributesChunk;
-	}
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.util.jar;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.security.AccessController;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.harmony.luni.util.PriviAction;
+
+/**
+ * The Manifest class is used to obtain attribute information for a JarFile and
+ * it's entries.
+ * 
+ */
+public class Manifest implements Cloneable {
+	private Attributes mainAttributes = new Attributes();
+
+	private HashMap<String, Attributes> entryAttributes = new HashMap<String, Attributes>();
+
+	private HashMap<String, byte[]> chunks;
+
+	/*The data chunk of Main Attributes in the manifest is needed in verification.*/
+	private byte[] mainAttributesChunk;
+	
+	/**
+	 * Constructs a new Manifest instance.
+	 */
+	public Manifest() {
+        super();
+	}
+
+	/**
+	 * Constructs a new Manifest instance using the attributes obtained from is.
+	 * 
+	 * @param is
+	 *            InputStream to parse for attributes
+	 * 
+	 * @throws IOException
+	 *             if an IO error occurs while creating this Manifest
+	 * 
+	 */
+	public Manifest(InputStream is) throws IOException {
+		read(is);
+	}
+
+	Manifest(InputStream is, boolean readChunks) throws IOException {
+		if (readChunks) {
+			chunks = new HashMap<String, byte[]>();
+        }
+		read(is);
+	}
+
+	/**
+	 * Resets the both the mainAttributes as well as the entry Attributes
+	 * associated with this Manifest.
+	 */
+	public void clear() {
+		entryAttributes.clear();
+		mainAttributes.clear();
+	}
+
+	/**
+	 * Returns the Attributes associated with the parameter entry name
+	 * 
+	 * @param name
+	 *            The name of the entry to obtain Attributes for.
+	 * @return The Attributes for the entry or null if the entry does not exist.
+	 */
+	public Attributes getAttributes(String name) {
+		return getEntries().get(name);
+	}
+
+	/**
+	 * Returns a Map containing the Attributes for each entry in the Manifest.
+	 * 
+	 * @return A Map of entry attributes
+	 */
+	public Map<String, Attributes> getEntries() {
+		return entryAttributes;
+	}
+
+	/**
+	 * Returns the main Attributes of the JarFile.
+	 * 
+	 * @return Main Attributes associated with the source JarFile
+	 */
+	public Attributes getMainAttributes() {
+		return mainAttributes;
+	}
+
+	/**
+	 * Constructs a new Manifest instance. The new instance will have the same
+	 * attributes as those found in the parameter Manifest.
+	 * 
+	 * @param man
+	 *            Manifest instance to obtain attributes from
+	 */
+	public Manifest(Manifest man) {
+		mainAttributes = (Attributes) man.mainAttributes.clone();
+		entryAttributes = (HashMap<String, Attributes>) man.entryAttributes.clone();
+	}
+
+	/**
+	 * Creates a copy of this Manifest. The returned Manifest will equal the
+	 * Manifest from which it was cloned.
+	 * 
+	 * @return A copy of the receiver.
+	 */
+	public Object clone() {
+		return new Manifest(this);
+	}
+
+	static class WriteManifest {
+		private static final int LIMIT = 70;
+
+		private static byte[] sepBuf = new byte[] { '\r', '\n' };
+
+		private static Attributes.Name nameAttribute = new Attributes.Name(
+				"Name", false);
+
+		byte[] oneByte = new byte[1];
+
+		char[] oneChar = new char[1];
+
+		private Charset charset;
+
+		private byte[] outBuf = new byte[LIMIT];
+
+		OutputStream os;
+
+		/**
+		 * Writes out a manifest entry.
+		 */
+		private void writeEntry(Attributes.Name name, String value)
+				throws IOException {
+			int offset = 0, limit = LIMIT;
+			byte[] out = (name.toString() + ": ").getBytes("ISO8859_1");
+			if (out.length > limit) {
+				while (out.length - offset >= limit) {
+					int len = out.length - offset;
+					if (len > limit) {
+                        len = limit;
+                    }
+					if (offset > 0) {
+                        os.write(' ');
+                    }
+					os.write(out, offset, len);
+					os.write(sepBuf);
+					offset += len;
+					limit = LIMIT - 1;
+				}
+			}
+			int size = out.length - offset;
+			System.arraycopy(out, offset, outBuf, 0, size);
+			for (int i = 0; i < value.length(); i++) {
+				oneChar[0] = value.charAt(i);
+				byte[] buf;
+				if (oneChar[0] < 128 || charset == null) {
+					oneByte[0] = (byte) oneChar[0];
+					buf = oneByte;
+				} else {
+                    buf = charset.encode(CharBuffer.wrap(oneChar, 0, 1)).array();
+                }
+				if (size + buf.length > limit) {
+					if (limit != LIMIT) {
+                        os.write(' ');
+                    }
+					os.write(outBuf, 0, size);
+					os.write(sepBuf);
+					limit = LIMIT - 1;
+					size = 0;
+				}
+				if (buf.length == 1) {
+                    outBuf[size] = buf[0];
+                } else {
+                    System.arraycopy(buf, 0, outBuf, size, buf.length);
+                }
+				size += buf.length;
+			}
+			if (size > 0) {
+				if (limit != LIMIT) {
+                    os.write(' ');
+                }
+				os.write(outBuf, 0, size);
+				os.write(sepBuf);
+			}
+		}
+
+		/**
+		 * Writes out the attribute information of the receiver to the specified
+		 * OutputStream
+		 * 
+		 * 
+		 * @param manifest
+		 *            the attribute information of the receiver
+		 * @param out
+		 *            The OutputStream to write to.
+		 * 
+		 * @throws IOException
+		 *             If an error occurs writing the Manifest
+		 */
+		void write(Manifest manifest, OutputStream out) throws IOException {
+			os = out;
+			String encoding = AccessController
+					.doPrivileged(new PriviAction<String>("manifest.write.encoding"));
+			if (encoding != null) {
+				if ("".equals(encoding)) {
+                    encoding = "UTF8";
+                }
+				charset = Charset.forName(encoding);				
+			}
+			String version = manifest.mainAttributes
+					.getValue(Attributes.Name.MANIFEST_VERSION);
+			if (version != null) {
+				writeEntry(Attributes.Name.MANIFEST_VERSION, version);
+				Iterator<?> entries = manifest.mainAttributes.keySet().iterator();
+				while (entries.hasNext()) {
+					Attributes.Name name = (Attributes.Name) entries.next();
+					if (!name.equals(Attributes.Name.MANIFEST_VERSION)) {
+                        writeEntry(name, manifest.mainAttributes.getValue(name));
+                    }
+				}
+			}
+			os.write(sepBuf);
+			Iterator<String> i = manifest.entryAttributes.keySet().iterator();
+			while (i.hasNext()) {
+				String key = i.next();
+				writeEntry(nameAttribute, key);
+				Attributes attrib = manifest.entryAttributes.get(key);
+				Iterator<?> entries = attrib.keySet().iterator();
+				while (entries.hasNext()) {
+					Attributes.Name name = (Attributes.Name) entries.next();
+					writeEntry(name, attrib.getValue(name));
+				}
+				os.write(sepBuf);
+			}
+		}
+	}
+
+	/**
+	 * Writes out the attribute information of the receiver to the specified
+	 * OutputStream
+	 * 
+	 * @param os
+	 *            The OutputStream to write to.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs writing the Manifest
+	 */
+	public void write(OutputStream os) throws IOException {
+		new WriteManifest().write(this, os);
+	}
+
+	/**
+	 * Constructs a new Manifest instance obtaining Attribute information from
+	 * the parameter InputStream.
+	 * 
+	 * @param is
+	 *            The InputStream to read from
+	 * @throws IOException
+	 *             If an error occurs reading the Manifest.
+	 */
+	public void read(InputStream is) throws IOException {
+		InitManifest initManifest = new InitManifest(is, mainAttributes, entryAttributes, chunks, null);
+		mainAttributesChunk = initManifest.getMainAttributesChunk();
+	}
+
+	/**
+	 * Returns the hashCode for this instance.
+	 * 
+	 * @return This Manifest's hashCode
+	 */
+	public int hashCode() {
+		return mainAttributes.hashCode() ^ entryAttributes.hashCode();
+	}
+
+	/**
+	 * Determines if the receiver is equal to the parameter Object. Two
+	 * Manifests are equal if they have identical main Attributes as well as
+	 * identical entry Attributes.
+	 * 
+	 * @param o
+	 *            The Object to compare against.
+	 * @return <code>true</code> if the manifests are equal,
+	 *         <code>false</code> otherwise
+	 */
+	public boolean equals(Object o) {
+		if (o == null) {
+            return false;
+        }
+		if (o.getClass() != this.getClass()) {
+            return false;
+        }
+		if (!mainAttributes.equals(((Manifest) o).mainAttributes)) {
+            return false;
+        }
+		return entryAttributes.equals(((Manifest) o).entryAttributes);
+	}
+
+	byte[] getChunk(String name) {
+		return chunks.get(name);
+	}
+
+	void removeChunks() {
+		chunks = null;
+	}
+	
+	byte[] getMainAttributesChunk()
+	{
+		return this.mainAttributesChunk;
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Manifest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Adler32.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Adler32.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Adler32.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Adler32.java Thu Sep 14 19:40:33 2006
@@ -1,85 +1,85 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.util.zip;
-
-
-/**
- * The Adler32 class is used to compute the Adler32 Checksum from a set of data.
- */
-public class Adler32 implements java.util.zip.Checksum {
-
-	private long adler = 1;
-
-	/**
-	 * Returns the Adler32 checksum for all input received
-	 * 
-	 * @return The checksum for this instance
-	 */
-	public long getValue() {
-		return adler;
-	}
-
-	/**
-	 * Reset this instance to its initial checksum
-	 */
-	public void reset() {
-		adler = 1;
-	}
-
-	/**
-	 * Update this Adler32 checksum using val.
-	 * 
-	 * @param i
-	 *            byte to update checksum with
-	 */
-	public void update(int i) {
-		adler = updateByteImpl(i, adler);
-	}
-
-	/**
-	 * Update this Adler32 checksum using the contents of buf.
-	 * 
-	 * @param buf
-	 *            bytes to update checksum with
-	 */
-	public void update(byte[] buf) {
-		update(buf, 0, buf.length);
-	}
-
-	/**
-	 * Update this Adler32 checksum with the contents of buf, starting from
-	 * offset and using nbytes of data.
-	 * 
-	 * @param buf
-	 *            bufffer to obtain dat from
-	 * @param off
-	 *            offset i buf to conpy from
-	 * @param nbytes
-	 *            number of bytes from buf to use
-	 */
-	public void update(byte[] buf, int off, int nbytes) {
-		// avoid int overflow, check null buf
-		if (off <= buf.length && nbytes >= 0 && off >= 0
-				&& buf.length - off >= nbytes)
-			adler = updateImpl(buf, off, nbytes, adler);
-		else
-			throw new ArrayIndexOutOfBoundsException();
-	}
-
-	private native long updateImpl(byte[] buf, int off, int nbytes, long adler1);
-
-	private native long updateByteImpl(int val, long adler1);
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.util.zip;
+
+
+/**
+ * The Adler32 class is used to compute the Adler32 Checksum from a set of data.
+ */
+public class Adler32 implements java.util.zip.Checksum {
+
+	private long adler = 1;
+
+	/**
+	 * Returns the Adler32 checksum for all input received
+	 * 
+	 * @return The checksum for this instance
+	 */
+	public long getValue() {
+		return adler;
+	}
+
+	/**
+	 * Reset this instance to its initial checksum
+	 */
+	public void reset() {
+		adler = 1;
+	}
+
+	/**
+	 * Update this Adler32 checksum using val.
+	 * 
+	 * @param i
+	 *            byte to update checksum with
+	 */
+	public void update(int i) {
+		adler = updateByteImpl(i, adler);
+	}
+
+	/**
+	 * Update this Adler32 checksum using the contents of buf.
+	 * 
+	 * @param buf
+	 *            bytes to update checksum with
+	 */
+	public void update(byte[] buf) {
+		update(buf, 0, buf.length);
+	}
+
+	/**
+	 * Update this Adler32 checksum with the contents of buf, starting from
+	 * offset and using nbytes of data.
+	 * 
+	 * @param buf
+	 *            bufffer to obtain dat from
+	 * @param off
+	 *            offset i buf to conpy from
+	 * @param nbytes
+	 *            number of bytes from buf to use
+	 */
+	public void update(byte[] buf, int off, int nbytes) {
+		// avoid int overflow, check null buf
+		if (off <= buf.length && nbytes >= 0 && off >= 0
+				&& buf.length - off >= nbytes)
+			adler = updateImpl(buf, off, nbytes, adler);
+		else
+			throw new ArrayIndexOutOfBoundsException();
+	}
+
+	private native long updateImpl(byte[] buf, int off, int nbytes, long adler1);
+
+	private native long updateByteImpl(int val, long adler1);
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Adler32.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CRC32.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CRC32.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CRC32.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CRC32.java Thu Sep 14 19:40:33 2006
@@ -1,86 +1,86 @@
-/* Copyright 1998, 2002 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.util.zip;
-
-
-/**
- * The CRC32 class is used to compute a CRC32 Checksum from a set of data.
- */
-public class CRC32 implements java.util.zip.Checksum {
-
-	private long crc = 0L;
-
-	long tbytes = 0L;
-
-	/**
-	 * Returns the CRC32 Checksum for all input received.
-	 * 
-	 * @return The checksum for this instance
-	 */
-	public long getValue() {
-		return crc;
-	}
-
-	/**
-	 * Returns the CRC32 checksum to it initial state.
-	 */
-	public void reset() {
-		tbytes = crc = 0;
-
-	}
-
-	/**
-	 * Updates this Checksum with value val
-	 */
-	public void update(int val) {
-		crc = updateByteImpl((byte) val, crc);
-	}
-
-	/**
-	 * Updates this Checksum with the bytes contained in buffer buf.
-	 * 
-	 * @param buf
-	 *            Buffer to update Checksum
-	 */
-	public void update(byte[] buf) {
-		update(buf, 0, buf.length);
-	}
-
-	/**
-	 * Updates this Checksum with nbytes of data from buffer buf, starting at
-	 * offset off.
-	 * 
-	 * @param buf
-	 *            Buffer to update Checksum
-	 * @param off
-	 *            Offest in buf to obtain data from
-	 * @param nbytes
-	 *            Number of bytes to read from buf
-	 */
-	public void update(byte[] buf, int off, int nbytes) {
-		// avoid int overflow, check null buf
-		if (off <= buf.length && nbytes >= 0 && off >= 0
-				&& buf.length - off >= nbytes) {
-			tbytes += nbytes;
-			crc = updateImpl(buf, off, nbytes, crc);
-		} else
-			throw new ArrayIndexOutOfBoundsException();
-	}
-
-	private native long updateImpl(byte[] buf, int off, int nbytes, long crc1);
-
-	private native long updateByteImpl(byte val, long crc1);
-}
+/* Copyright 1998, 2002 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.util.zip;
+
+
+/**
+ * The CRC32 class is used to compute a CRC32 Checksum from a set of data.
+ */
+public class CRC32 implements java.util.zip.Checksum {
+
+	private long crc = 0L;
+
+	long tbytes = 0L;
+
+	/**
+	 * Returns the CRC32 Checksum for all input received.
+	 * 
+	 * @return The checksum for this instance
+	 */
+	public long getValue() {
+		return crc;
+	}
+
+	/**
+	 * Returns the CRC32 checksum to it initial state.
+	 */
+	public void reset() {
+		tbytes = crc = 0;
+
+	}
+
+	/**
+	 * Updates this Checksum with value val
+	 */
+	public void update(int val) {
+		crc = updateByteImpl((byte) val, crc);
+	}
+
+	/**
+	 * Updates this Checksum with the bytes contained in buffer buf.
+	 * 
+	 * @param buf
+	 *            Buffer to update Checksum
+	 */
+	public void update(byte[] buf) {
+		update(buf, 0, buf.length);
+	}
+
+	/**
+	 * Updates this Checksum with nbytes of data from buffer buf, starting at
+	 * offset off.
+	 * 
+	 * @param buf
+	 *            Buffer to update Checksum
+	 * @param off
+	 *            Offest in buf to obtain data from
+	 * @param nbytes
+	 *            Number of bytes to read from buf
+	 */
+	public void update(byte[] buf, int off, int nbytes) {
+		// avoid int overflow, check null buf
+		if (off <= buf.length && nbytes >= 0 && off >= 0
+				&& buf.length - off >= nbytes) {
+			tbytes += nbytes;
+			crc = updateImpl(buf, off, nbytes, crc);
+		} else
+			throw new ArrayIndexOutOfBoundsException();
+	}
+
+	private native long updateImpl(byte[] buf, int off, int nbytes, long crc1);
+
+	private native long updateByteImpl(byte val, long crc1);
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CRC32.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedInputStream.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedInputStream.java Thu Sep 14 19:40:33 2006
@@ -1,106 +1,106 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.util.zip;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * The CheckedInputStream class is used to maintain a running Checksum of all
- * data read from a stream.
- */
-public class CheckedInputStream extends java.io.FilterInputStream {
-
-	private Checksum check;
-
-	/**
-	 * Constructs a new CheckedInputStream on InputStream is. The Checksum will
-	 * be calculated using the algorithm implemented by csum.
-	 * 
-	 * @param is
-	 *            InputStream to calculate checksum from
-	 * @param csum
-	 *            Type of Checksum to calculate
-	 */
-	public CheckedInputStream(InputStream is, Checksum csum) {
-		super(is);
-		check = csum;
-	}
-
-	/**
-	 * Reads a byte of data from the underlying stream and recomputes the
-	 * Checksum with the byte data.
-	 * 
-	 * @return -1 if end of stream, a single byte value otherwise
-	 */
-	public int read() throws IOException {
-		int x = in.read();
-		if (x != -1) {
-			check.update(x);
-		}
-		return x;
-	}
-
-	/**
-	 * Reads up to nbytes of data from the underlying stream, storing it in buf,
-	 * starting at offset off. The Checksum is updated with the bytes read.
-	 * 
-	 * @return Number of bytes read, -1 if end of stream
-	 */
-	public int read(byte[] buf, int off, int nbytes) throws IOException {
-		int x = in.read(buf, off, nbytes);
-		if (x != -1)
-			check.update(buf, off, x);
-		return x;
-	}
-
-	/**
-	 * Returns the Checksum calculated on the stream thus far.
-	 * 
-	 * @return A java.util.zip.Checksum
-	 */
-	public Checksum getChecksum() {
-		return check;
-	}
-
-	/**
-	 * Skip upto nbytes of data on the underlying stream. Any skipped bytes are
-	 * added to the running Checksum value.
-	 * 
-	 * @param nbytes
-	 *            long Number of bytes to skip
-	 * @return Number of bytes skipped
-	 */
-	public long skip(long nbytes) throws IOException {
-		if (nbytes < 1) {
-			return 0;
-		}
-		long skipped = 0;
-		byte[] b = new byte[2048];
-		int x, v;
-		while (skipped != nbytes) {
-			x = in.read(b, 0,
-					(v = (int) (nbytes - skipped)) > b.length ? b.length : v);
-			if (x == -1) {
-				return skipped;
-			}
-			check.update(b, 0, x);
-			skipped += x;
-		}
-		return skipped;
-	}
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.util.zip;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * The CheckedInputStream class is used to maintain a running Checksum of all
+ * data read from a stream.
+ */
+public class CheckedInputStream extends java.io.FilterInputStream {
+
+	private Checksum check;
+
+	/**
+	 * Constructs a new CheckedInputStream on InputStream is. The Checksum will
+	 * be calculated using the algorithm implemented by csum.
+	 * 
+	 * @param is
+	 *            InputStream to calculate checksum from
+	 * @param csum
+	 *            Type of Checksum to calculate
+	 */
+	public CheckedInputStream(InputStream is, Checksum csum) {
+		super(is);
+		check = csum;
+	}
+
+	/**
+	 * Reads a byte of data from the underlying stream and recomputes the
+	 * Checksum with the byte data.
+	 * 
+	 * @return -1 if end of stream, a single byte value otherwise
+	 */
+	public int read() throws IOException {
+		int x = in.read();
+		if (x != -1) {
+			check.update(x);
+		}
+		return x;
+	}
+
+	/**
+	 * Reads up to nbytes of data from the underlying stream, storing it in buf,
+	 * starting at offset off. The Checksum is updated with the bytes read.
+	 * 
+	 * @return Number of bytes read, -1 if end of stream
+	 */
+	public int read(byte[] buf, int off, int nbytes) throws IOException {
+		int x = in.read(buf, off, nbytes);
+		if (x != -1)
+			check.update(buf, off, x);
+		return x;
+	}
+
+	/**
+	 * Returns the Checksum calculated on the stream thus far.
+	 * 
+	 * @return A java.util.zip.Checksum
+	 */
+	public Checksum getChecksum() {
+		return check;
+	}
+
+	/**
+	 * Skip upto nbytes of data on the underlying stream. Any skipped bytes are
+	 * added to the running Checksum value.
+	 * 
+	 * @param nbytes
+	 *            long Number of bytes to skip
+	 * @return Number of bytes skipped
+	 */
+	public long skip(long nbytes) throws IOException {
+		if (nbytes < 1) {
+			return 0;
+		}
+		long skipped = 0;
+		byte[] b = new byte[2048];
+		int x, v;
+		while (skipped != nbytes) {
+			x = in.read(b, 0,
+					(v = (int) (nbytes - skipped)) > b.length ? b.length : v);
+			if (x == -1) {
+				return skipped;
+			}
+			check.update(b, 0, x);
+			skipped += x;
+		}
+		return skipped;
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedOutputStream.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedOutputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedOutputStream.java Thu Sep 14 19:40:33 2006
@@ -1,86 +1,86 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.util.zip;
-
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * The CheckedOutputStream class is used to maintain a running Checksum of all
- * data written to a stream.
- */
-public class CheckedOutputStream extends java.io.FilterOutputStream {
-
-	private Checksum check;
-
-	/**
-	 * Constructs a new CheckedOutputStream on OutputStream os. The Checksum
-	 * will be calculated using the algorithm implemented by csum.
-	 * 
-	 * @param os
-	 *            OutputStream to calculate checksum from
-	 * @param cs
-	 *            Type of Checksum to calculate
-	 */
-	public CheckedOutputStream(OutputStream os, Checksum cs) {
-		super(os);
-		check = cs;
-	}
-
-	/**
-	 * Returns the Checksum calculated on the stream thus far.
-	 * 
-	 * @return A java.util.zip.Checksum
-	 */
-	public Checksum getChecksum() {
-		return check;
-	}
-
-	/**
-	 * Writes byte value val to the underlying stream. The Checksum is updated
-	 * with val.
-	 * 
-	 * @param val
-	 *            Value of the byte to write out
-	 * 
-	 * @throws IOException
-	 *             if an IO error has occured
-	 */
-	public void write(int val) throws IOException {
-		out.write(val);
-		check.update(val);
-	}
-
-	/**
-	 * Writes nbytes of data from buf starting at offset off to the underlying
-	 * stream. The Checksum is updated with the bytes written.
-	 * 
-	 * @param buf
-	 *            data to write out
-	 * @param off
-	 *            the start offset of the data
-	 * @param nbytes
-	 *            number of bytes to write out
-	 * 
-	 * @throws IOException
-	 *             if an IO error has occured
-	 */
-	public void write(byte[] buf, int off, int nbytes) throws IOException {
-		out.write(buf, off, nbytes);
-		check.update(buf, off, nbytes);
-	}
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.util.zip;
+
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * The CheckedOutputStream class is used to maintain a running Checksum of all
+ * data written to a stream.
+ */
+public class CheckedOutputStream extends java.io.FilterOutputStream {
+
+	private Checksum check;
+
+	/**
+	 * Constructs a new CheckedOutputStream on OutputStream os. The Checksum
+	 * will be calculated using the algorithm implemented by csum.
+	 * 
+	 * @param os
+	 *            OutputStream to calculate checksum from
+	 * @param cs
+	 *            Type of Checksum to calculate
+	 */
+	public CheckedOutputStream(OutputStream os, Checksum cs) {
+		super(os);
+		check = cs;
+	}
+
+	/**
+	 * Returns the Checksum calculated on the stream thus far.
+	 * 
+	 * @return A java.util.zip.Checksum
+	 */
+	public Checksum getChecksum() {
+		return check;
+	}
+
+	/**
+	 * Writes byte value val to the underlying stream. The Checksum is updated
+	 * with val.
+	 * 
+	 * @param val
+	 *            Value of the byte to write out
+	 * 
+	 * @throws IOException
+	 *             if an IO error has occured
+	 */
+	public void write(int val) throws IOException {
+		out.write(val);
+		check.update(val);
+	}
+
+	/**
+	 * Writes nbytes of data from buf starting at offset off to the underlying
+	 * stream. The Checksum is updated with the bytes written.
+	 * 
+	 * @param buf
+	 *            data to write out
+	 * @param off
+	 *            the start offset of the data
+	 * @param nbytes
+	 *            number of bytes to write out
+	 * 
+	 * @throws IOException
+	 *             if an IO error has occured
+	 */
+	public void write(byte[] buf, int off, int nbytes) throws IOException {
+		out.write(buf, off, nbytes);
+		check.update(buf, off, nbytes);
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedOutputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Checksum.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Checksum.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Checksum.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Checksum.java Thu Sep 14 19:40:33 2006
@@ -1,27 +1,27 @@
-/* Copyright 1998, 2002 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.util.zip;
-
-
-public interface Checksum {
-	public long getValue();
-
-	public void reset();
-
-	public void update(int val);
-
-	public void update(byte[] buf, int off, int nbytes);
-}
+/* Copyright 1998, 2002 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.util.zip;
+
+
+public interface Checksum {
+	public long getValue();
+
+	public void reset();
+
+	public void update(int val);
+
+	public void update(byte[] buf, int off, int nbytes);
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Checksum.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DataFormatException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DataFormatException.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DataFormatException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DataFormatException.java Thu Sep 14 19:40:33 2006
@@ -1,44 +1,44 @@
-/* Copyright 1998, 2002 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.util.zip;
-
-/**
- * DataFormatException is used to indicate an error in the format of a
- * particular data stream.
- */
-public class DataFormatException extends Exception {
-
-    private static final long serialVersionUID = 2219632870893641452L;
-
-    /**
-     * Constructs a new instance of this class with its walkback filled in.
-     * 
-     */
-    public DataFormatException() {
-        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 DataFormatException(String detailMessage) {
-        super(detailMessage);
-    }
-}
+/* Copyright 1998, 2002 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.util.zip;
+
+/**
+ * DataFormatException is used to indicate an error in the format of a
+ * particular data stream.
+ */
+public class DataFormatException extends Exception {
+
+    private static final long serialVersionUID = 2219632870893641452L;
+
+    /**
+     * Constructs a new instance of this class with its walkback filled in.
+     * 
+     */
+    public DataFormatException() {
+        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 DataFormatException(String detailMessage) {
+        super(detailMessage);
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DataFormatException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java Thu Sep 14 19:40:33 2006
@@ -1,422 +1,422 @@
-/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.util.zip;
-
-
-/**
- * The Deflater class is used to compress bytes using the DEFLATE compression
- * algorithm. Deflation is performed by the ZLIB compression library.
- * 
- * @see DeflaterOutputStream
- * @see Inflater
- */
-public class Deflater {
-
-	public static final int BEST_COMPRESSION = 9;
-
-	public static final int BEST_SPEED = 1;
-
-	public static final int DEFAULT_COMPRESSION = -1;
-
-	public static final int DEFAULT_STRATEGY = 0;
-
-	public static final int DEFLATED = 8;
-
-	public static final int FILTERED = 1;
-
-	public static final int HUFFMAN_ONLY = 2;
-
-	public static final int NO_COMPRESSION = 0;
-
-	private static final int Z_NO_FLUSH = 0;
-
-	private static final int Z_FINISH = 4;
-
-	private int flushParm = Z_NO_FLUSH;
-
-	private boolean finished;
-
-	int compressLevel = DEFAULT_COMPRESSION;
-
-	int strategy = DEFAULT_STRATEGY;
-
-	long streamHandle = -1;
-
-	byte[] inputBuffer;
-
-	int inRead = 0, inLength = 0;
-
-	// Fill in the JNI id caches
-	private static native void oneTimeInitialization();
-
-	static {
-		oneTimeInitialization();
-	}
-
-	/**
-	 * Deflates data into the supplied buffer
-	 * 
-	 * @param buf
-	 *            buffer to store compressed data
-	 * 
-	 * @return number of bytes of compressed data stored
-	 * 
-	 */
-	public int deflate(byte[] buf) {
-		return deflate(buf, 0, buf.length);
-	}
-
-	/**
-	 * Deflates data into the supplied buffer using the region from off to
-	 * nbytes - 1.
-	 * 
-	 * @param buf
-	 *            buffer to store compressed data
-	 * @param off
-	 *            offset inf buf to start storing data
-	 * @param nbytes
-	 *            number of bytes of compressed data to store in buf
-	 * 
-	 * @return number of bytes of compressed data stored
-	 * 
-	 */
-	public synchronized int deflate(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) {
-            return deflateImpl(buf, off, nbytes, streamHandle, flushParm);
-        }
-		throw new ArrayIndexOutOfBoundsException();
-	}
-
-	private native synchronized int deflateImpl(byte[] buf, int off,
-			int nbytes, long handle, int flushParm1);
-
-	private synchronized native void endImpl(long handle);
-
-	/**
-	 * Frees all resources held onto by this Deflater. Any unused input or output
-	 * is discarded. This is also called from the finalize method.
-	 * 
-	 * @see #finalize
-	 */
-	public synchronized void end() {
-		if (streamHandle != -1) {
-			endImpl(streamHandle);
-			inputBuffer = null;
-			streamHandle = -1;
-		}
-	}
-
-	protected void finalize() {
-		end();
-	}
-
-	/**
-	 * Indicates to the Deflater that all uncompressed input has been provided
-	 * to it.
-	 * 
-	 * @see #finished
-	 */
-	public synchronized void finish() {
-		flushParm = Z_FINISH;
-	}
-
-	/**
-	 * Returns whether or not all provided data has been successfully
-	 * compressed.
-	 * 
-	 * @return true if all data has been compressed, false otherwise
-	 */
-	public synchronized boolean finished() {
-		return finished;
-	}
-
-	/**
-	 * Returns the Adler32 checksum of uncompressed data currently read. If a
-	 * preset dictionary is used getAdler() will return the Adler32 checksum of
-	 * the dictionary used.
-	 * 
-	 * @return The Adler32 checksum of uncompressed data or preset dictionary if
-	 *         used
-	 * 
-	 * @see #setDictionary(byte[])
-	 * @see #setDictionary(byte[], int, int)
-	 */
-	public synchronized int getAdler() {
-		if (streamHandle == -1) {
-            throw new IllegalStateException();
-        }
-
-		return getAdlerImpl(streamHandle);
-	}
-
-	private synchronized native int getAdlerImpl(long handle);
-
-	/**
-	 * Returns the total number of bytes of input consumed by the deflater.
-	 * 
-	 * @return number of bytes of input read.
-	 */
-	public synchronized int getTotalIn() {
-		if (streamHandle == -1) {
-            throw new IllegalStateException();
-        }
-
-		return (int)getTotalInImpl(streamHandle);
-	}
-
-	private native synchronized long getTotalInImpl(long handle);
-
-	/**
-	 * Returns the total number of compressed bytes output by this Deflater.
-	 * 
-	 * @return number of compressed bytes output.
-	 */
-	public synchronized int getTotalOut() {
-		if (streamHandle == -1) {
-            throw new IllegalStateException();
-        }
-
-		return (int)getTotalOutImpl(streamHandle);
-	}
-
-	private synchronized native long getTotalOutImpl(long handle);
-
-	/**
-	 * Indicates whether or not all bytes of uncompressed input have been
-	 * consumed by the Deflater. If needsInput() answers true setInput() must be
-	 * called before deflation can continue. If all bytes of uncompressed data
-	 * have been provided to the Deflater finish() must be called to ensure the
-	 * compressed data is output.
-	 * 
-	 * @return True if input is required for deflation to continue, false
-	 *         otherwise
-	 * @see #finished()
-	 * @see #setInput(byte[])
-	 * @see #setInput(byte[], int, int)
-	 */
-	public boolean needsInput() {
-		if (inputBuffer == null) {
-            return true;
-        }
-		return inRead == inLength;
-	}
-
-	/**
-	 * Resets the <code>Deflater</code> to accept new input without affecting
-	 * any previously made settings for the compression strategy or level. This
-	 * operation <i>must</i> be called after <code>finished()</code> returns
-	 * <code>true</code> if the <code>Deflater</code> is to be reused.
-	 * 
-	 * @see #finished
-	 */
-	public synchronized void reset() {
-		if (streamHandle == -1) {
-            throw new NullPointerException();
-        }
-
-		flushParm = Z_NO_FLUSH;
-		finished = false;
-		resetImpl(streamHandle);
-		inputBuffer = null;
-	}
-
-	private native synchronized void resetImpl(long handle);
-
-	public void setDictionary(byte[] buf) {
-		setDictionary(buf, 0, buf.length);
-	}
-
-	/**
-	 * Sets the dictionary to be used for compression by this Deflater.
-	 * setDictionary() can only be called if this Deflater supports the writing
-	 * of ZLIB headers. This is the default behaviour but can be overridden
-	 * using Deflater(int, boolean).
-	 * 
-	 * @see Deflater#Deflater(int, boolean)
-	 */
-	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) {
-            setDictionaryImpl(buf, off, nbytes, streamHandle);
-        } else {
-            throw new ArrayIndexOutOfBoundsException();
-        }
-	}
-
-	private native synchronized void setDictionaryImpl(byte[] buf, int off,
-			int nbytes, long handle);
-
-	/**
-	 * Sets the input buffer the Deflater will use to extract uncompressed bytes
-	 * for later compression.
-	 */
-	public void setInput(byte[] buf) {
-		setInput(buf, 0, buf.length);
-	}
-
-	/**
-	 * Sets the input buffer the Deflater will use to extract uncompressed bytes
-	 * for later compression. Input will be taken from the buffer region
-	 * starting at off and ending at nbytes - 1.
-	 */
-	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) {
-			inLength = nbytes;
-			inRead = 0;
-			if (inputBuffer == null) {
-                setLevelsImpl(compressLevel, strategy, streamHandle);
-            }
-			inputBuffer = buf;
-			setInputImpl(buf, off, nbytes, streamHandle);
-		} else {
-            throw new ArrayIndexOutOfBoundsException();
-        }
-	}
-
-	private native synchronized void setLevelsImpl(int level, int strategy,
-			long handle);
-
-	private native synchronized void setInputImpl(byte[] buf, int off,
-			int nbytes, long handle);
-
-	/**
-	 * Sets the compression level to be used when compressing data. The
-	 * compression level must be a value between 0 and 9. This value must be set
-	 * prior to calling setInput().
-	 * 
-	 * @param level
-	 *            compression level to use
-	 * @exception IllegalArgumentException
-	 *                If the compression level is invalid.
-	 */
-	public synchronized void setLevel(int level) {
-		if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) {
-            throw new IllegalArgumentException();
-        }
-		if (inputBuffer != null) {
-            throw new IllegalStateException();
-        }
-		compressLevel = level;
-	}
-
-	/**
-	 * Sets the compression strategy to be used. The strategy must be one of
-	 * FILTERED, HUFFMAN_ONLY or DEFAULT_STRATEGY.This value must be set prior
-	 * to calling setInput().
-	 * 
-	 * @param strategy
-	 *            compression strategy to use
-	 * @exception IllegalArgumentException
-	 *                If the strategy specified is not one of FILTERED,
-	 *                HUFFMAN_ONLY or DEFAULT_STRATEGY.
-	 */
-	public synchronized void setStrategy(int strategy) {
-		if (strategy < DEFAULT_STRATEGY || strategy > HUFFMAN_ONLY) {
-            throw new IllegalArgumentException();
-        }
-		if (inputBuffer != null) {
-            throw new IllegalStateException();
-        }
-		this.strategy = strategy;
-	}
-
-	/**
-	 * Constructs a new Deflater instance with default compression level and
-	 * strategy.
-	 */
-	public Deflater() {
-		this(DEFAULT_COMPRESSION, false);
-	}
-
-	/**
-	 * Constructs a new Deflater instance with compression level level and
-	 * default compression strategy. If the noHeader parameter is specified then
-	 * no ZLIB header will be written as part of the compressed output. The
-	 * compression level specified must be between 0 and 9.
-	 * 
-	 * @param level
-	 *            the compression level to use
-	 * @param noHeader
-	 *            if true do not write the ZLIB header
-	 */
-	public Deflater(int level, boolean noHeader) {
-		if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) {
-            throw new IllegalArgumentException();
-        }
-		compressLevel = level;
-		streamHandle = createStream(compressLevel, strategy, noHeader);
-	}
-
-	/**
-	 * Constructs a new Deflater instance with compression level level and
-	 * default compression strategy. THe compression level provided must be
-	 * between 0 and 9.
-	 * 
-	 * @param level
-	 *            the compression level to use
-	 */
-	public Deflater(int level) {
-		this(level, false);
-	}
-	
-    /**
-	 * Returns a long int of total number of bytes read by the Deflater. This
-	 * method performs the same as getTotalIn except it returns a long value
-	 * instead of an integer
-	 * 
-	 * @see getTotalIn
-	 * @return bytes exactly read by deflater
-	 */
-	public synchronized long getBytesRead() {
-		// Throw NPE here
-		if (streamHandle == -1) {
-            throw new NullPointerException();
-        }
-		return getTotalInImpl(streamHandle);
-	}
-
-	/**
-	 * Returns a long int of total number of bytes of read by the Deflater. This
-	 * method performs the same as getTotalOut except it returns a long value
-	 * instead of an integer
-	 * 
-	 * @see getTotalOut
-	 * @return bytes exactly write by deflater
-	 */
-    public synchronized long getBytesWritten() {
-        // Throw NPE here
-        if (streamHandle == -1) {
-            throw new NullPointerException();
-        }
-        return getTotalOutImpl(streamHandle);
-    }
-
-	private native long createStream(int level, int strategy1, boolean noHeader1);
-}
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.util.zip;
+
+
+/**
+ * The Deflater class is used to compress bytes using the DEFLATE compression
+ * algorithm. Deflation is performed by the ZLIB compression library.
+ * 
+ * @see DeflaterOutputStream
+ * @see Inflater
+ */
+public class Deflater {
+
+	public static final int BEST_COMPRESSION = 9;
+
+	public static final int BEST_SPEED = 1;
+
+	public static final int DEFAULT_COMPRESSION = -1;
+
+	public static final int DEFAULT_STRATEGY = 0;
+
+	public static final int DEFLATED = 8;
+
+	public static final int FILTERED = 1;
+
+	public static final int HUFFMAN_ONLY = 2;
+
+	public static final int NO_COMPRESSION = 0;
+
+	private static final int Z_NO_FLUSH = 0;
+
+	private static final int Z_FINISH = 4;
+
+	private int flushParm = Z_NO_FLUSH;
+
+	private boolean finished;
+
+	int compressLevel = DEFAULT_COMPRESSION;
+
+	int strategy = DEFAULT_STRATEGY;
+
+	long streamHandle = -1;
+
+	byte[] inputBuffer;
+
+	int inRead = 0, inLength = 0;
+
+	// Fill in the JNI id caches
+	private static native void oneTimeInitialization();
+
+	static {
+		oneTimeInitialization();
+	}
+
+	/**
+	 * Deflates data into the supplied buffer
+	 * 
+	 * @param buf
+	 *            buffer to store compressed data
+	 * 
+	 * @return number of bytes of compressed data stored
+	 * 
+	 */
+	public int deflate(byte[] buf) {
+		return deflate(buf, 0, buf.length);
+	}
+
+	/**
+	 * Deflates data into the supplied buffer using the region from off to
+	 * nbytes - 1.
+	 * 
+	 * @param buf
+	 *            buffer to store compressed data
+	 * @param off
+	 *            offset inf buf to start storing data
+	 * @param nbytes
+	 *            number of bytes of compressed data to store in buf
+	 * 
+	 * @return number of bytes of compressed data stored
+	 * 
+	 */
+	public synchronized int deflate(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) {
+            return deflateImpl(buf, off, nbytes, streamHandle, flushParm);
+        }
+		throw new ArrayIndexOutOfBoundsException();
+	}
+
+	private native synchronized int deflateImpl(byte[] buf, int off,
+			int nbytes, long handle, int flushParm1);
+
+	private synchronized native void endImpl(long handle);
+
+	/**
+	 * Frees all resources held onto by this Deflater. Any unused input or output
+	 * is discarded. This is also called from the finalize method.
+	 * 
+	 * @see #finalize
+	 */
+	public synchronized void end() {
+		if (streamHandle != -1) {
+			endImpl(streamHandle);
+			inputBuffer = null;
+			streamHandle = -1;
+		}
+	}
+
+	protected void finalize() {
+		end();
+	}
+
+	/**
+	 * Indicates to the Deflater that all uncompressed input has been provided
+	 * to it.
+	 * 
+	 * @see #finished
+	 */
+	public synchronized void finish() {
+		flushParm = Z_FINISH;
+	}
+
+	/**
+	 * Returns whether or not all provided data has been successfully
+	 * compressed.
+	 * 
+	 * @return true if all data has been compressed, false otherwise
+	 */
+	public synchronized boolean finished() {
+		return finished;
+	}
+
+	/**
+	 * Returns the Adler32 checksum of uncompressed data currently read. If a
+	 * preset dictionary is used getAdler() will return the Adler32 checksum of
+	 * the dictionary used.
+	 * 
+	 * @return The Adler32 checksum of uncompressed data or preset dictionary if
+	 *         used
+	 * 
+	 * @see #setDictionary(byte[])
+	 * @see #setDictionary(byte[], int, int)
+	 */
+	public synchronized int getAdler() {
+		if (streamHandle == -1) {
+            throw new IllegalStateException();
+        }
+
+		return getAdlerImpl(streamHandle);
+	}
+
+	private synchronized native int getAdlerImpl(long handle);
+
+	/**
+	 * Returns the total number of bytes of input consumed by the deflater.
+	 * 
+	 * @return number of bytes of input read.
+	 */
+	public synchronized int getTotalIn() {
+		if (streamHandle == -1) {
+            throw new IllegalStateException();
+        }
+
+		return (int)getTotalInImpl(streamHandle);
+	}
+
+	private native synchronized long getTotalInImpl(long handle);
+
+	/**
+	 * Returns the total number of compressed bytes output by this Deflater.
+	 * 
+	 * @return number of compressed bytes output.
+	 */
+	public synchronized int getTotalOut() {
+		if (streamHandle == -1) {
+            throw new IllegalStateException();
+        }
+
+		return (int)getTotalOutImpl(streamHandle);
+	}
+
+	private synchronized native long getTotalOutImpl(long handle);
+
+	/**
+	 * Indicates whether or not all bytes of uncompressed input have been
+	 * consumed by the Deflater. If needsInput() answers true setInput() must be
+	 * called before deflation can continue. If all bytes of uncompressed data
+	 * have been provided to the Deflater finish() must be called to ensure the
+	 * compressed data is output.
+	 * 
+	 * @return True if input is required for deflation to continue, false
+	 *         otherwise
+	 * @see #finished()
+	 * @see #setInput(byte[])
+	 * @see #setInput(byte[], int, int)
+	 */
+	public boolean needsInput() {
+		if (inputBuffer == null) {
+            return true;
+        }
+		return inRead == inLength;
+	}
+
+	/**
+	 * Resets the <code>Deflater</code> to accept new input without affecting
+	 * any previously made settings for the compression strategy or level. This
+	 * operation <i>must</i> be called after <code>finished()</code> returns
+	 * <code>true</code> if the <code>Deflater</code> is to be reused.
+	 * 
+	 * @see #finished
+	 */
+	public synchronized void reset() {
+		if (streamHandle == -1) {
+            throw new NullPointerException();
+        }
+
+		flushParm = Z_NO_FLUSH;
+		finished = false;
+		resetImpl(streamHandle);
+		inputBuffer = null;
+	}
+
+	private native synchronized void resetImpl(long handle);
+
+	public void setDictionary(byte[] buf) {
+		setDictionary(buf, 0, buf.length);
+	}
+
+	/**
+	 * Sets the dictionary to be used for compression by this Deflater.
+	 * setDictionary() can only be called if this Deflater supports the writing
+	 * of ZLIB headers. This is the default behaviour but can be overridden
+	 * using Deflater(int, boolean).
+	 * 
+	 * @see Deflater#Deflater(int, boolean)
+	 */
+	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) {
+            setDictionaryImpl(buf, off, nbytes, streamHandle);
+        } else {
+            throw new ArrayIndexOutOfBoundsException();
+        }
+	}
+
+	private native synchronized void setDictionaryImpl(byte[] buf, int off,
+			int nbytes, long handle);
+
+	/**
+	 * Sets the input buffer the Deflater will use to extract uncompressed bytes
+	 * for later compression.
+	 */
+	public void setInput(byte[] buf) {
+		setInput(buf, 0, buf.length);
+	}
+
+	/**
+	 * Sets the input buffer the Deflater will use to extract uncompressed bytes
+	 * for later compression. Input will be taken from the buffer region
+	 * starting at off and ending at nbytes - 1.
+	 */
+	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) {
+			inLength = nbytes;
+			inRead = 0;
+			if (inputBuffer == null) {
+                setLevelsImpl(compressLevel, strategy, streamHandle);
+            }
+			inputBuffer = buf;
+			setInputImpl(buf, off, nbytes, streamHandle);
+		} else {
+            throw new ArrayIndexOutOfBoundsException();
+        }
+	}
+
+	private native synchronized void setLevelsImpl(int level, int strategy,
+			long handle);
+
+	private native synchronized void setInputImpl(byte[] buf, int off,
+			int nbytes, long handle);
+
+	/**
+	 * Sets the compression level to be used when compressing data. The
+	 * compression level must be a value between 0 and 9. This value must be set
+	 * prior to calling setInput().
+	 * 
+	 * @param level
+	 *            compression level to use
+	 * @exception IllegalArgumentException
+	 *                If the compression level is invalid.
+	 */
+	public synchronized void setLevel(int level) {
+		if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) {
+            throw new IllegalArgumentException();
+        }
+		if (inputBuffer != null) {
+            throw new IllegalStateException();
+        }
+		compressLevel = level;
+	}
+
+	/**
+	 * Sets the compression strategy to be used. The strategy must be one of
+	 * FILTERED, HUFFMAN_ONLY or DEFAULT_STRATEGY.This value must be set prior
+	 * to calling setInput().
+	 * 
+	 * @param strategy
+	 *            compression strategy to use
+	 * @exception IllegalArgumentException
+	 *                If the strategy specified is not one of FILTERED,
+	 *                HUFFMAN_ONLY or DEFAULT_STRATEGY.
+	 */
+	public synchronized void setStrategy(int strategy) {
+		if (strategy < DEFAULT_STRATEGY || strategy > HUFFMAN_ONLY) {
+            throw new IllegalArgumentException();
+        }
+		if (inputBuffer != null) {
+            throw new IllegalStateException();
+        }
+		this.strategy = strategy;
+	}
+
+	/**
+	 * Constructs a new Deflater instance with default compression level and
+	 * strategy.
+	 */
+	public Deflater() {
+		this(DEFAULT_COMPRESSION, false);
+	}
+
+	/**
+	 * Constructs a new Deflater instance with compression level level and
+	 * default compression strategy. If the noHeader parameter is specified then
+	 * no ZLIB header will be written as part of the compressed output. The
+	 * compression level specified must be between 0 and 9.
+	 * 
+	 * @param level
+	 *            the compression level to use
+	 * @param noHeader
+	 *            if true do not write the ZLIB header
+	 */
+	public Deflater(int level, boolean noHeader) {
+		if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) {
+            throw new IllegalArgumentException();
+        }
+		compressLevel = level;
+		streamHandle = createStream(compressLevel, strategy, noHeader);
+	}
+
+	/**
+	 * Constructs a new Deflater instance with compression level level and
+	 * default compression strategy. THe compression level provided must be
+	 * between 0 and 9.
+	 * 
+	 * @param level
+	 *            the compression level to use
+	 */
+	public Deflater(int level) {
+		this(level, false);
+	}
+	
+    /**
+	 * Returns a long int of total number of bytes read by the Deflater. This
+	 * method performs the same as getTotalIn except it returns a long value
+	 * instead of an integer
+	 * 
+	 * @see getTotalIn
+	 * @return bytes exactly read by deflater
+	 */
+	public synchronized long getBytesRead() {
+		// Throw NPE here
+		if (streamHandle == -1) {
+            throw new NullPointerException();
+        }
+		return getTotalInImpl(streamHandle);
+	}
+
+	/**
+	 * Returns a long int of total number of bytes of read by the Deflater. This
+	 * method performs the same as getTotalOut except it returns a long value
+	 * instead of an integer
+	 * 
+	 * @see getTotalOut
+	 * @return bytes exactly write by deflater
+	 */
+    public synchronized long getBytesWritten() {
+        // Throw NPE here
+        if (streamHandle == -1) {
+            throw new NullPointerException();
+        }
+        return getTotalOutImpl(streamHandle);
+    }
+
+	private native long createStream(int level, int strategy1, boolean noHeader1);
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java Thu Sep 14 19:40:33 2006
@@ -1,170 +1,170 @@
-/* Copyright 1998, 2002 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.util.zip;
-
-
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.apache.harmony.luni.util.Msg;
-
-/**
- * The DeflaterOutputStream class implements a stream filter for the writing of
- * compressed data to a stream. Compression is performed by an instance of
- * Deflater.
- */
-public class DeflaterOutputStream extends FilterOutputStream {
-	static final int BUF_SIZE = 512;
-
-	protected byte[] buf;
-
-	protected Deflater def;
-
-	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)
-			throw new NullPointerException();
-		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.
-	 */
-	public void close() throws IOException {
-		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)
-			return;
-		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;
-	}
-
-	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.
-	 */
-	public void write(byte[] buffer, int off, int nbytes) throws IOException {
-		if (done)
-			throw new IOException(Msg.getString("K0007"));
-		// 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
-			throw new ArrayIndexOutOfBoundsException();
-	}
-}
+/* Copyright 1998, 2002 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.util.zip;
+
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.harmony.luni.util.Msg;
+
+/**
+ * The DeflaterOutputStream class implements a stream filter for the writing of
+ * compressed data to a stream. Compression is performed by an instance of
+ * Deflater.
+ */
+public class DeflaterOutputStream extends FilterOutputStream {
+	static final int BUF_SIZE = 512;
+
+	protected byte[] buf;
+
+	protected Deflater def;
+
+	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)
+			throw new NullPointerException();
+		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.
+	 */
+	public void close() throws IOException {
+		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)
+			return;
+		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;
+	}
+
+	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.
+	 */
+	public void write(byte[] buffer, int off, int nbytes) throws IOException {
+		if (done)
+			throw new IOException(Msg.getString("K0007"));
+		// 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
+			throw new ArrayIndexOutOfBoundsException();
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message