You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/09/15 04:40:36 UTC
svn commit: r446478 [4/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...
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java Thu Sep 14 19:40:33 2006
@@ -1,189 +1,189 @@
-/* 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.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.harmony.luni.util.Msg;
-
-/**
- * The GZIPInputStream class is used to read data stored in the GZIP format.
- */
-public class GZIPInputStream extends java.util.zip.InflaterInputStream {
- protected CRC32 crc = new CRC32();
-
- protected boolean eos = false;
-
- public final static int GZIP_MAGIC = 0x8b1f;
-
- private static final int FHCRC = 2;
-
- private static final int FEXTRA = 4;
-
- private static final int FNAME = 8;
-
- private static final int FCOMMENT = 16;
-
- /**
- * Construct a GZIPInputStream to read from GZIP data from the underlying
- * stream
- *
- * @param is
- * InputStream to read data from
- */
- public GZIPInputStream(InputStream is) throws IOException {
- this(is, BUF_SIZE);
- }
-
- /**
- * Construct a GZIPInputStream to read from GZIP data from the underlying
- * stream. Set the internal buffer size to size
- *
- * @param is
- * InputStream to read data from
- * @param size
- * Internal read buffer size
- */
- public GZIPInputStream(InputStream is, int size) throws IOException {
- super(is, new Inflater(true), size);
- byte[] header = new byte[10];
- readFully(header, 0, header.length);
- if (getShort(header, 0) != GZIP_MAGIC)
- throw new IOException(Msg.getString("K0020"));
- int flags = header[3];
- boolean hcrc = (flags & FHCRC) != 0;
- if (hcrc)
- crc.update(header, 0, header.length);
- if ((flags & FEXTRA) != 0) {
- readFully(header, 0, 2);
- if (hcrc)
- crc.update(header, 0, 2);
- int length = getShort(header, 0);
- while (length > 0) {
- int max = length > buf.length ? buf.length : length;
- int result = in.read(buf, 0, max);
- if (result == -1)
- throw new EOFException();
- if (hcrc)
- crc.update(buf, 0, result);
- length -= result;
- }
- }
- if ((flags & FNAME) != 0)
- readZeroTerminated(hcrc);
- if ((flags & FCOMMENT) != 0)
- readZeroTerminated(hcrc);
- if (hcrc) {
- readFully(header, 0, 2);
- int crc16 = getShort(header, 0);
- if ((crc.getValue() & 0xffff) != crc16)
- throw new IOException(Msg.getString("K0077"));
- crc.reset();
- }
- }
-
- private long getLong(byte[] buffer, int off) {
- long l = 0;
- l |= (buffer[off] & 0xFF);
- l |= (buffer[off + 1] & 0xFF) << 8;
- l |= (buffer[off + 2] & 0xFF) << 16;
- l |= ((long) (buffer[off + 3] & 0xFF)) << 24;
- return l;
- }
-
- private int getShort(byte[] buffer, int off) {
- return (buffer[off] & 0xFF) | ((buffer[off + 1] & 0xFF) << 8);
- }
-
- /**
- * Reads and decompresses GZIP data from the underlying stream into buf.
- *
- * @param buffer
- * Buffer to receive data
- * @param off
- * Offset in buffer to store data
- * @param nbytes
- * Number of bytes to read
- */
- public int read(byte[] buffer, int off, int nbytes) throws IOException {
- // avoid int overflow, check null buffer
- if (off <= buffer.length && nbytes >= 0 && off >= 0
- && buffer.length - off >= nbytes) {
- int val = super.read(buffer, off, nbytes);
- if (val != -1)
- crc.update(buffer, off, val);
- else if (!eos) {
- eos = true;
- // Get non-compressed bytes read by fill
- int size = 0;
- byte[] b = new byte[8];
- int inB = inf.getTotalIn();
- if (inB > 0) {
- int diff = inB % buf.length;
- if (diff != 0 || len != buf.length) {
- size = len - diff;
- if (size > b.length)
- size = b.length;
- System.arraycopy(buf, diff, b, 0, size);
- }
- }
- readFully(b, size, b.length - size);
- if (getLong(b, 0) != crc.getValue())
- throw new IOException(Msg.getString("K0077"));
- if ((int) getLong(b, 4) != inf.getTotalOut())
- throw new IOException(Msg.getString("K00ae"));
- }
- return val;
- }
- throw new ArrayIndexOutOfBoundsException();
- }
-
- /**
- * Closes this stream and any underlying streams.
- */
- public void close() throws IOException {
- eos = true;
- super.close();
- }
-
- private void readFully(byte[] buffer, int offset, int length)
- throws IOException {
- int result;
- while (length > 0) {
- result = in.read(buffer, offset, length);
- if (result == -1)
- throw new EOFException();
- offset += result;
- length -= result;
- }
- }
-
- private void readZeroTerminated(boolean hcrc) throws IOException {
- int result;
- while ((result = in.read()) > 0) {
- if (hcrc)
- crc.update(result);
- }
- if (result == -1)
- throw new EOFException();
- // Add the zero
- if (hcrc)
- crc.update(result);
- }
-}
+/* 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.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.harmony.luni.util.Msg;
+
+/**
+ * The GZIPInputStream class is used to read data stored in the GZIP format.
+ */
+public class GZIPInputStream extends java.util.zip.InflaterInputStream {
+ protected CRC32 crc = new CRC32();
+
+ protected boolean eos = false;
+
+ public final static int GZIP_MAGIC = 0x8b1f;
+
+ private static final int FHCRC = 2;
+
+ private static final int FEXTRA = 4;
+
+ private static final int FNAME = 8;
+
+ private static final int FCOMMENT = 16;
+
+ /**
+ * Construct a GZIPInputStream to read from GZIP data from the underlying
+ * stream
+ *
+ * @param is
+ * InputStream to read data from
+ */
+ public GZIPInputStream(InputStream is) throws IOException {
+ this(is, BUF_SIZE);
+ }
+
+ /**
+ * Construct a GZIPInputStream to read from GZIP data from the underlying
+ * stream. Set the internal buffer size to size
+ *
+ * @param is
+ * InputStream to read data from
+ * @param size
+ * Internal read buffer size
+ */
+ public GZIPInputStream(InputStream is, int size) throws IOException {
+ super(is, new Inflater(true), size);
+ byte[] header = new byte[10];
+ readFully(header, 0, header.length);
+ if (getShort(header, 0) != GZIP_MAGIC)
+ throw new IOException(Msg.getString("K0020"));
+ int flags = header[3];
+ boolean hcrc = (flags & FHCRC) != 0;
+ if (hcrc)
+ crc.update(header, 0, header.length);
+ if ((flags & FEXTRA) != 0) {
+ readFully(header, 0, 2);
+ if (hcrc)
+ crc.update(header, 0, 2);
+ int length = getShort(header, 0);
+ while (length > 0) {
+ int max = length > buf.length ? buf.length : length;
+ int result = in.read(buf, 0, max);
+ if (result == -1)
+ throw new EOFException();
+ if (hcrc)
+ crc.update(buf, 0, result);
+ length -= result;
+ }
+ }
+ if ((flags & FNAME) != 0)
+ readZeroTerminated(hcrc);
+ if ((flags & FCOMMENT) != 0)
+ readZeroTerminated(hcrc);
+ if (hcrc) {
+ readFully(header, 0, 2);
+ int crc16 = getShort(header, 0);
+ if ((crc.getValue() & 0xffff) != crc16)
+ throw new IOException(Msg.getString("K0077"));
+ crc.reset();
+ }
+ }
+
+ private long getLong(byte[] buffer, int off) {
+ long l = 0;
+ l |= (buffer[off] & 0xFF);
+ l |= (buffer[off + 1] & 0xFF) << 8;
+ l |= (buffer[off + 2] & 0xFF) << 16;
+ l |= ((long) (buffer[off + 3] & 0xFF)) << 24;
+ return l;
+ }
+
+ private int getShort(byte[] buffer, int off) {
+ return (buffer[off] & 0xFF) | ((buffer[off + 1] & 0xFF) << 8);
+ }
+
+ /**
+ * Reads and decompresses GZIP data from the underlying stream into buf.
+ *
+ * @param buffer
+ * Buffer to receive data
+ * @param off
+ * Offset in buffer to store data
+ * @param nbytes
+ * Number of bytes to read
+ */
+ public int read(byte[] buffer, int off, int nbytes) throws IOException {
+ // avoid int overflow, check null buffer
+ if (off <= buffer.length && nbytes >= 0 && off >= 0
+ && buffer.length - off >= nbytes) {
+ int val = super.read(buffer, off, nbytes);
+ if (val != -1)
+ crc.update(buffer, off, val);
+ else if (!eos) {
+ eos = true;
+ // Get non-compressed bytes read by fill
+ int size = 0;
+ byte[] b = new byte[8];
+ int inB = inf.getTotalIn();
+ if (inB > 0) {
+ int diff = inB % buf.length;
+ if (diff != 0 || len != buf.length) {
+ size = len - diff;
+ if (size > b.length)
+ size = b.length;
+ System.arraycopy(buf, diff, b, 0, size);
+ }
+ }
+ readFully(b, size, b.length - size);
+ if (getLong(b, 0) != crc.getValue())
+ throw new IOException(Msg.getString("K0077"));
+ if ((int) getLong(b, 4) != inf.getTotalOut())
+ throw new IOException(Msg.getString("K00ae"));
+ }
+ return val;
+ }
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ /**
+ * Closes this stream and any underlying streams.
+ */
+ public void close() throws IOException {
+ eos = true;
+ super.close();
+ }
+
+ private void readFully(byte[] buffer, int offset, int length)
+ throws IOException {
+ int result;
+ while (length > 0) {
+ result = in.read(buffer, offset, length);
+ if (result == -1)
+ throw new EOFException();
+ offset += result;
+ length -= result;
+ }
+ }
+
+ private void readZeroTerminated(boolean hcrc) throws IOException {
+ int result;
+ while ((result = in.read()) > 0) {
+ if (hcrc)
+ crc.update(result);
+ }
+ if (result == -1)
+ throw new EOFException();
+ // Add the zero
+ if (hcrc)
+ crc.update(result);
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java Thu Sep 14 19:40:33 2006
@@ -1,93 +1,93 @@
-/* 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.IOException;
-import java.io.OutputStream;
-
-/**
- * The GZIPOutputStream class is used to write data to a stream in the GZIP
- * storage format.
- */
-public class GZIPOutputStream extends DeflaterOutputStream {
-
- protected CRC32 crc = new CRC32();
-
- /**
- * Construct a new GZIPOutputStream to write data in GZIP format to the
- * underlying stream.
- *
- * @param os
- * OutputStream to write to
- */
- public GZIPOutputStream(OutputStream os) throws IOException {
- this(os, BUF_SIZE);
- }
-
- /**
- * Construct a new GZIPOutputStream to write data in GZIP format to the
- * underlying stream. Set the internal compression buffer to sise size.
- *
- * @param os
- * OutputStream to write to
- * @param size
- * Internal buffer size
- */
- public GZIPOutputStream(OutputStream os, int size) throws IOException {
- super(os, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size);
- writeShort(GZIPInputStream.GZIP_MAGIC);
- out.write(Deflater.DEFLATED);
- out.write(0); // flags
- writeLong(0); // mod time
- out.write(0); // extra flags
- out.write(0); // operating system
- }
-
- /**
- * Indicates to the stream that all data has been written out, and any GZIP
- * terminal data can now be output.
- */
- public void finish() throws IOException {
- super.finish();
- writeLong(crc.getValue());
- writeLong(crc.tbytes);
- }
-
- /**
- * Write up to nbytes of data from buf, starting at offset off, to the
- * underlying stream in GZIP format.
- */
- public void write(byte[] buffer, int off, int nbytes) throws IOException {
- super.write(buffer, off, nbytes);
- crc.update(buffer, off, nbytes);
- }
-
- private int writeShort(int i) throws IOException {
- out.write(i & 0xFF);
- out.write((i >> 8) & 0xFF);
- return i;
- }
-
- private long writeLong(long i) throws IOException {
- // Write out the long value as an unsigned int
- out.write((int) (i & 0xFF));
- out.write((int) (i >> 8) & 0xFF);
- out.write((int) (i >> 16) & 0xFF);
- out.write((int) (i >> 24) & 0xFF);
- return i;
- }
-}
+/* 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.IOException;
+import java.io.OutputStream;
+
+/**
+ * The GZIPOutputStream class is used to write data to a stream in the GZIP
+ * storage format.
+ */
+public class GZIPOutputStream extends DeflaterOutputStream {
+
+ protected CRC32 crc = new CRC32();
+
+ /**
+ * Construct a new GZIPOutputStream to write data in GZIP format to the
+ * underlying stream.
+ *
+ * @param os
+ * OutputStream to write to
+ */
+ public GZIPOutputStream(OutputStream os) throws IOException {
+ this(os, BUF_SIZE);
+ }
+
+ /**
+ * Construct a new GZIPOutputStream to write data in GZIP format to the
+ * underlying stream. Set the internal compression buffer to sise size.
+ *
+ * @param os
+ * OutputStream to write to
+ * @param size
+ * Internal buffer size
+ */
+ public GZIPOutputStream(OutputStream os, int size) throws IOException {
+ super(os, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size);
+ writeShort(GZIPInputStream.GZIP_MAGIC);
+ out.write(Deflater.DEFLATED);
+ out.write(0); // flags
+ writeLong(0); // mod time
+ out.write(0); // extra flags
+ out.write(0); // operating system
+ }
+
+ /**
+ * Indicates to the stream that all data has been written out, and any GZIP
+ * terminal data can now be output.
+ */
+ public void finish() throws IOException {
+ super.finish();
+ writeLong(crc.getValue());
+ writeLong(crc.tbytes);
+ }
+
+ /**
+ * Write up to nbytes of data from buf, starting at offset off, to the
+ * underlying stream in GZIP format.
+ */
+ public void write(byte[] buffer, int off, int nbytes) throws IOException {
+ super.write(buffer, off, nbytes);
+ crc.update(buffer, off, nbytes);
+ }
+
+ private int writeShort(int i) throws IOException {
+ out.write(i & 0xFF);
+ out.write((i >> 8) & 0xFF);
+ return i;
+ }
+
+ private long writeLong(long i) throws IOException {
+ // Write out the long value as an unsigned int
+ out.write((int) (i & 0xFF));
+ out.write((int) (i >> 8) & 0xFF);
+ out.write((int) (i >> 16) & 0xFF);
+ out.write((int) (i >> 24) & 0xFF);
+ return i;
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java Thu Sep 14 19:40:33 2006
@@ -1,344 +1,344 @@
-/* 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;
-
-import org.apache.harmony.luni.util.Msg;
-
-
-/**
- * The Inflater class is used to decompress bytes using the DEFLATE compression
- * algorithm. Inflation is performed by the ZLIB compression library.
- *
- * @see DeflaterOutputStream
- * @see Inflater
- */
-public class Inflater {
-
- private boolean finished; // Set by the inflateImpl native
-
- private boolean needsDictionary; // Set by the inflateImpl native
-
- private long streamHandle = -1;
-
- int inRead;
-
- int inLength;
-
- // Fill in the JNI id caches
- private static native void oneTimeInitialization();
-
- static {
- oneTimeInitialization();
- }
-
- /**
- * Release any resources associated with this Inflater. Any unused
- * input/output is discarded. This is also called by the finalize method.
- */
- public synchronized void end() {
- if (streamHandle != -1) {
- endImpl(streamHandle);
- inRead = 0;
- inLength = 0;
- streamHandle = -1;
- }
- }
-
- private native synchronized void endImpl(long handle);
-
- protected void finalize() {
- end();
- }
-
- /**
- * Indicates if the Inflater has inflated the entire deflated stream. If
- * deflated bytes remain and needsInput returns true this method will return
- * false. This method should be called after all deflated input is supplied
- * to the Inflater.
- *
- * @return True if all input has been inflated, false otherwise
- */
- public synchronized boolean finished() {
- return finished;
- }
-
- /**
- * Returns the Adler32 checksum of either all bytes inflated, or the
- * checksum of the preset dictionary if one has been supplied.
- *
- * @return The Adler32 checksum associated with this Inflater.
- */
- public synchronized int getAdler() {
- if (streamHandle == -1) {
- throw new IllegalStateException();
- }
- return getAdlerImpl(streamHandle);
- }
-
- private native synchronized int getAdlerImpl(long handle);
-
- /**
- * Returns the number of bytes of current input remaining to be read by the
- * inflater
- *
- * @return Number of bytes of unread input.
- */
- public synchronized int getRemaining() {
- return inLength - inRead;
- }
-
- /**
- * Returns total number of bytes of input read by the Inflater.
- *
- * @return Total bytes read
- */
- public synchronized int getTotalIn() {
- if (streamHandle == -1) {
- throw new IllegalStateException();
- }
- long totalIn = getTotalInImpl(streamHandle);
- return (totalIn <= Integer.MAX_VALUE ? (int) totalIn
- : Integer.MAX_VALUE);
- }
-
- private synchronized native long getTotalInImpl(long handle);
-
- /**
- * Returns total number of bytes of input output by the Inflater.
- *
- * @return Total bytes output
- */
- public synchronized int getTotalOut() {
- if (streamHandle == -1) {
- throw new IllegalStateException();
- }
- long totalOut = getTotalOutImpl(streamHandle);
- return (totalOut <= Integer.MAX_VALUE ? (int) totalOut
- : Integer.MAX_VALUE);
- }
-
- private native synchronized long getTotalOutImpl(long handle);
-
- /**
- * Inflates bytes from current input and stores them in buf.
- *
- * @param buf
- * Buffer to output inflated bytes
- * @return Number of bytes inflated
- * @exception DataFormatException
- * If the underlying stream is corrupted or was not DEFLATED
- *
- */
- public int inflate(byte[] buf) throws DataFormatException {
- return inflate(buf, 0, buf.length);
- }
-
- /**
- * Inflates up to nbytes bytes from current input and stores them in buf
- * starting at off.
- *
- * @param buf
- * Buffer to output inflated bytes
- * @param off
- * Offset in buffer into which to store inflated bytes
- * @param nbytes
- * Number of inflated bytes to store
- * @exception DataFormatException
- * If the underlying stream is corrupted or was not DEFLATED
- * @return Number of bytes inflated
- */
- public synchronized int inflate(byte[] buf, int off, int nbytes)
- throws DataFormatException {
- // avoid int overflow, check null buf
- if (off <= buf.length && nbytes >= 0 && off >= 0
- && buf.length - off >= nbytes) {
- if (streamHandle == -1) {
- throw new IllegalStateException();
- }
-
- boolean neededDict = needsDictionary;
- needsDictionary = false;
- int result = inflateImpl(buf, off, nbytes, streamHandle);
- if (needsDictionary && neededDict) {
- throw new DataFormatException(Msg.getString("K0324"));
- }
- return result;
- }
- throw new ArrayIndexOutOfBoundsException();
- }
-
- private native synchronized int inflateImpl(byte[] buf, int off,
- int nbytes, long handle);
-
- /**
- * Constructs a new Inflater instance.
- */
- public Inflater() {
- this(false);
- }
-
- /**
- * Constructs a new Inflater instance. If noHeader is true the Inflater will
- * not attempt to read a ZLIB header.
- *
- * @param noHeader
- * If true, read a ZLIB header from input.
- */
- public Inflater(boolean noHeader) {
- streamHandle = createStream(noHeader);
- }
-
- /**
- * Indicates whether the input bytes were compressed with a preset
- * dictionary. This method should be called prior to inflate() to determine
- * if a dictionary is required. If so setDictionary() should be called with
- * the appropriate dictionary prior to calling inflate().
- *
- * @return true if a preset dictionary is required for inflation.
- * @see #setDictionary(byte[])
- * @see #setDictionary(byte[], int, int)
- */
- public synchronized boolean needsDictionary() {
- return needsDictionary;
- }
-
- public synchronized boolean needsInput() {
- return inRead == inLength;
- }
-
- /**
- * Resets the Inflater.
- */
- public synchronized void reset() {
- if (streamHandle == -1) {
- throw new NullPointerException();
- }
- finished = false;
- needsDictionary = false;
- inLength = inRead = 0;
- resetImpl(streamHandle);
- }
-
- private native synchronized void resetImpl(long handle);
-
- /**
- * Sets the preset dictionary to be used for inflation to buf.
- * needsDictioanry() can be called to determine whether the current input
- * was deflated using a preset dictionary.
- *
- * @param buf
- * The buffer containing the dictionary bytes
- * @see #needsDictionary
- */
- public synchronized void setDictionary(byte[] buf) {
- setDictionary(buf, 0, buf.length);
- }
-
- public synchronized void setDictionary(byte[] buf, int off, int nbytes) {
- if (streamHandle == -1) {
- 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 current input to buf. This method should only be called if
- * needsInput() returns true.
- *
- * @param buf
- * input buffer
- * @see #needsInput
- */
- public synchronized void setInput(byte[] buf) {
- setInput(buf, 0, buf.length);
- }
-
- /**
- * Sets the current input to the region of buf starting at off and ending at
- * nbytes - 1. This method should only be called if needsInput() returns
- * true.
- *
- * @param buf
- * input buffer
- * @param off
- * offset to read from in buffer
- * @param nbytes
- * number of bytes to read
- * @see #needsInput
- */
- public synchronized void setInput(byte[] buf, int off, int nbytes) {
- if (streamHandle == -1) {
- throw new IllegalStateException();
- }
- // avoid int overflow, check null buf
- if (off <= buf.length && nbytes >= 0 && off >= 0
- && buf.length - off >= nbytes) {
- inRead = 0;
- inLength = nbytes;
- setInputImpl(buf, off, nbytes, streamHandle);
- } else {
- throw new ArrayIndexOutOfBoundsException();
- }
- }
-
- /**
- * Returns a long int of total number of bytes of input read by the
- * Inflater.
- * This method performs the same as getTotalIn except it returns a
- * long value instead of an integer
- *
- * @see getTotalIn
- * @return Total bytes read
- */
- public synchronized long getBytesRead() {
- // Throw NPE here
- if (streamHandle == -1) {
- throw new NullPointerException();
- }
- return getTotalInImpl(streamHandle);
- }
-
- /**
- * Returns a long int of total number of bytes of input output by the
- * Inflater.
- * This method performs the same as getTotalOut except it returns a
- * long value instead of an integer
- *
- * @see getTotalOut
- * @return Total bytes output
- */
- public synchronized long getBytesWritten() {
- // Throw NPE here
- if (streamHandle == -1) {
- throw new NullPointerException();
- }
- return getTotalOutImpl(streamHandle);
- }
-
- private native synchronized void setInputImpl(byte[] buf, int off,
- int nbytes, long handle);
-
- private native long createStream(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;
+
+import org.apache.harmony.luni.util.Msg;
+
+
+/**
+ * The Inflater class is used to decompress bytes using the DEFLATE compression
+ * algorithm. Inflation is performed by the ZLIB compression library.
+ *
+ * @see DeflaterOutputStream
+ * @see Inflater
+ */
+public class Inflater {
+
+ private boolean finished; // Set by the inflateImpl native
+
+ private boolean needsDictionary; // Set by the inflateImpl native
+
+ private long streamHandle = -1;
+
+ int inRead;
+
+ int inLength;
+
+ // Fill in the JNI id caches
+ private static native void oneTimeInitialization();
+
+ static {
+ oneTimeInitialization();
+ }
+
+ /**
+ * Release any resources associated with this Inflater. Any unused
+ * input/output is discarded. This is also called by the finalize method.
+ */
+ public synchronized void end() {
+ if (streamHandle != -1) {
+ endImpl(streamHandle);
+ inRead = 0;
+ inLength = 0;
+ streamHandle = -1;
+ }
+ }
+
+ private native synchronized void endImpl(long handle);
+
+ protected void finalize() {
+ end();
+ }
+
+ /**
+ * Indicates if the Inflater has inflated the entire deflated stream. If
+ * deflated bytes remain and needsInput returns true this method will return
+ * false. This method should be called after all deflated input is supplied
+ * to the Inflater.
+ *
+ * @return True if all input has been inflated, false otherwise
+ */
+ public synchronized boolean finished() {
+ return finished;
+ }
+
+ /**
+ * Returns the Adler32 checksum of either all bytes inflated, or the
+ * checksum of the preset dictionary if one has been supplied.
+ *
+ * @return The Adler32 checksum associated with this Inflater.
+ */
+ public synchronized int getAdler() {
+ if (streamHandle == -1) {
+ throw new IllegalStateException();
+ }
+ return getAdlerImpl(streamHandle);
+ }
+
+ private native synchronized int getAdlerImpl(long handle);
+
+ /**
+ * Returns the number of bytes of current input remaining to be read by the
+ * inflater
+ *
+ * @return Number of bytes of unread input.
+ */
+ public synchronized int getRemaining() {
+ return inLength - inRead;
+ }
+
+ /**
+ * Returns total number of bytes of input read by the Inflater.
+ *
+ * @return Total bytes read
+ */
+ public synchronized int getTotalIn() {
+ if (streamHandle == -1) {
+ throw new IllegalStateException();
+ }
+ long totalIn = getTotalInImpl(streamHandle);
+ return (totalIn <= Integer.MAX_VALUE ? (int) totalIn
+ : Integer.MAX_VALUE);
+ }
+
+ private synchronized native long getTotalInImpl(long handle);
+
+ /**
+ * Returns total number of bytes of input output by the Inflater.
+ *
+ * @return Total bytes output
+ */
+ public synchronized int getTotalOut() {
+ if (streamHandle == -1) {
+ throw new IllegalStateException();
+ }
+ long totalOut = getTotalOutImpl(streamHandle);
+ return (totalOut <= Integer.MAX_VALUE ? (int) totalOut
+ : Integer.MAX_VALUE);
+ }
+
+ private native synchronized long getTotalOutImpl(long handle);
+
+ /**
+ * Inflates bytes from current input and stores them in buf.
+ *
+ * @param buf
+ * Buffer to output inflated bytes
+ * @return Number of bytes inflated
+ * @exception DataFormatException
+ * If the underlying stream is corrupted or was not DEFLATED
+ *
+ */
+ public int inflate(byte[] buf) throws DataFormatException {
+ return inflate(buf, 0, buf.length);
+ }
+
+ /**
+ * Inflates up to nbytes bytes from current input and stores them in buf
+ * starting at off.
+ *
+ * @param buf
+ * Buffer to output inflated bytes
+ * @param off
+ * Offset in buffer into which to store inflated bytes
+ * @param nbytes
+ * Number of inflated bytes to store
+ * @exception DataFormatException
+ * If the underlying stream is corrupted or was not DEFLATED
+ * @return Number of bytes inflated
+ */
+ public synchronized int inflate(byte[] buf, int off, int nbytes)
+ throws DataFormatException {
+ // avoid int overflow, check null buf
+ if (off <= buf.length && nbytes >= 0 && off >= 0
+ && buf.length - off >= nbytes) {
+ if (streamHandle == -1) {
+ throw new IllegalStateException();
+ }
+
+ boolean neededDict = needsDictionary;
+ needsDictionary = false;
+ int result = inflateImpl(buf, off, nbytes, streamHandle);
+ if (needsDictionary && neededDict) {
+ throw new DataFormatException(Msg.getString("K0324"));
+ }
+ return result;
+ }
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ private native synchronized int inflateImpl(byte[] buf, int off,
+ int nbytes, long handle);
+
+ /**
+ * Constructs a new Inflater instance.
+ */
+ public Inflater() {
+ this(false);
+ }
+
+ /**
+ * Constructs a new Inflater instance. If noHeader is true the Inflater will
+ * not attempt to read a ZLIB header.
+ *
+ * @param noHeader
+ * If true, read a ZLIB header from input.
+ */
+ public Inflater(boolean noHeader) {
+ streamHandle = createStream(noHeader);
+ }
+
+ /**
+ * Indicates whether the input bytes were compressed with a preset
+ * dictionary. This method should be called prior to inflate() to determine
+ * if a dictionary is required. If so setDictionary() should be called with
+ * the appropriate dictionary prior to calling inflate().
+ *
+ * @return true if a preset dictionary is required for inflation.
+ * @see #setDictionary(byte[])
+ * @see #setDictionary(byte[], int, int)
+ */
+ public synchronized boolean needsDictionary() {
+ return needsDictionary;
+ }
+
+ public synchronized boolean needsInput() {
+ return inRead == inLength;
+ }
+
+ /**
+ * Resets the Inflater.
+ */
+ public synchronized void reset() {
+ if (streamHandle == -1) {
+ throw new NullPointerException();
+ }
+ finished = false;
+ needsDictionary = false;
+ inLength = inRead = 0;
+ resetImpl(streamHandle);
+ }
+
+ private native synchronized void resetImpl(long handle);
+
+ /**
+ * Sets the preset dictionary to be used for inflation to buf.
+ * needsDictioanry() can be called to determine whether the current input
+ * was deflated using a preset dictionary.
+ *
+ * @param buf
+ * The buffer containing the dictionary bytes
+ * @see #needsDictionary
+ */
+ public synchronized void setDictionary(byte[] buf) {
+ setDictionary(buf, 0, buf.length);
+ }
+
+ public synchronized void setDictionary(byte[] buf, int off, int nbytes) {
+ if (streamHandle == -1) {
+ 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 current input to buf. This method should only be called if
+ * needsInput() returns true.
+ *
+ * @param buf
+ * input buffer
+ * @see #needsInput
+ */
+ public synchronized void setInput(byte[] buf) {
+ setInput(buf, 0, buf.length);
+ }
+
+ /**
+ * Sets the current input to the region of buf starting at off and ending at
+ * nbytes - 1. This method should only be called if needsInput() returns
+ * true.
+ *
+ * @param buf
+ * input buffer
+ * @param off
+ * offset to read from in buffer
+ * @param nbytes
+ * number of bytes to read
+ * @see #needsInput
+ */
+ public synchronized void setInput(byte[] buf, int off, int nbytes) {
+ if (streamHandle == -1) {
+ throw new IllegalStateException();
+ }
+ // avoid int overflow, check null buf
+ if (off <= buf.length && nbytes >= 0 && off >= 0
+ && buf.length - off >= nbytes) {
+ inRead = 0;
+ inLength = nbytes;
+ setInputImpl(buf, off, nbytes, streamHandle);
+ } else {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ }
+
+ /**
+ * Returns a long int of total number of bytes of input read by the
+ * Inflater.
+ * This method performs the same as getTotalIn except it returns a
+ * long value instead of an integer
+ *
+ * @see getTotalIn
+ * @return Total bytes read
+ */
+ public synchronized long getBytesRead() {
+ // Throw NPE here
+ if (streamHandle == -1) {
+ throw new NullPointerException();
+ }
+ return getTotalInImpl(streamHandle);
+ }
+
+ /**
+ * Returns a long int of total number of bytes of input output by the
+ * Inflater.
+ * This method performs the same as getTotalOut except it returns a
+ * long value instead of an integer
+ *
+ * @see getTotalOut
+ * @return Total bytes output
+ */
+ public synchronized long getBytesWritten() {
+ // Throw NPE here
+ if (streamHandle == -1) {
+ throw new NullPointerException();
+ }
+ return getTotalOutImpl(streamHandle);
+ }
+
+ private native synchronized void setInputImpl(byte[] buf, int off,
+ int nbytes, long handle);
+
+ private native long createStream(boolean noHeader1);
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java Thu Sep 14 19:40:33 2006
@@ -1,278 +1,278 @@
-/* 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.zip;
-
-
-import java.io.EOFException;
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.harmony.luni.util.Msg;
-
-/**
- * InflaterOuputStream read data which has been compressed using the DEFLATE
- * compression method.
- *
- * @see Inflater
- * @see DeflaterOutputStream
- */
-public class InflaterInputStream extends FilterInputStream {
-
- protected Inflater inf;
-
- protected byte[] buf;
-
- protected int len;
-
- boolean closed;
-
- boolean eof;
-
- static final int BUF_SIZE = 512;
-
- /**
- * Constructs a new InflaterOutputStream on is
- *
- * @param is The InputStream to read data from
- */
- public InflaterInputStream(InputStream is) {
- this(is, new Inflater(), BUF_SIZE);
- }
-
- /**
- * Constructs a new InflaterOutputStream on is, using the Inflater provided
- * in inf.
- *
- * @param is
- * The InputStream to read data from
- * @param inf
- * The Inflater to use for decompression
- */
- public InflaterInputStream(InputStream is, Inflater inf) {
- this(is, inf, BUF_SIZE);
- }
-
- /**
- * Constructs a new InflaterOutputStream on is, using the Inflater provided
- * in inf. The size of the inflation buffer is determined by bsize.
- *
- * @param is
- * The InputStream to read data from
- * @param inf
- * The Inflater to use for decompression
- * @param bsize
- * size of the inflation buffer
- */
- public InflaterInputStream(InputStream is, Inflater inf, int bsize) {
- super(is);
- if (is == null || inf == null) {
- throw new NullPointerException();
- }
- if (bsize <= 0) {
- throw new IllegalArgumentException();
- }
- this.inf = inf;
- buf = new byte[bsize];
- }
-
- /**
- * Reads a single byte of decompressed data.
- *
- * @return byte read
- * @throws IOException
- * If an error occurs reading
- */
- public int read() throws IOException {
- byte[] b = new byte[1];
- if (read(b, 0, 1) == -1) {
- return -1;
- }
- return b[0] & 0xff;
- }
-
- /**
- * Reads up to nbytes of decompressed data and stores it in buf starting at
- * off.
- *
- * @param buffer
- * Buffer to store into
- * @param off
- * offset in buffer to store at
- * @param nbytes
- * number of bytes to store
- * @return Number of uncompressed bytes read
- * @throws IOException
- * If an error occurs reading
- */
- public int read(byte[] buffer, int off, int nbytes) throws IOException {
- /* [MSG "K0059", "Stream is closed"] */
- if (closed) {
- throw new IOException(Msg.getString("K0059"));
- }
-
- if (null == buffer) {
- throw new NullPointerException();
- }
-
- if (off < 0 || nbytes < 0 || off + nbytes > buffer.length) {
- throw new IndexOutOfBoundsException();
- }
-
- if (nbytes == 0) {
- return 0;
- }
-
- if (inf.finished()) {
- eof = true;
- return -1;
- }
-
- // avoid int overflow, check null buffer
- if (off <= buffer.length && nbytes >= 0 && off >= 0
- && buffer.length - off >= nbytes) {
- do {
- if (inf.needsInput()) {
- fill();
- }
- int result;
- try {
- result = inf.inflate(buffer, off, nbytes);
- } catch (DataFormatException e) {
- if (len == -1) {
- throw new EOFException();
- }
- throw (IOException)(new IOException().initCause(e));
- }
- if (result > 0) {
- return result;
- } else if (inf.finished()) {
- eof = true;
- return -1;
- } else if (inf.needsDictionary()) {
- return -1;
- } else if (len == -1) {
- throw new EOFException();
- // If result == 0, fill() and try again
- }
- } while (true);
- }
- throw new ArrayIndexOutOfBoundsException();
- }
-
- protected void fill() throws IOException {
- if (closed) {
- throw new IOException(Msg.getString("K0059"));
- }
- if ((len = in.read(buf)) > 0) {
- inf.setInput(buf, 0, len);
- }
- }
-
- /**
- * Skips up to nbytes of uncompressed data.
- *
- * @param nbytes
- * Number of bytes to skip
- * @return Number of uncompressed bytes skipped
- * @throws IOException
- * If an error occurs skipping
- */
- public long skip(long nbytes) throws IOException {
- if (nbytes >= 0) {
- long count = 0, rem = 0;
- while (count < nbytes) {
- int x = read(buf, 0,
- (rem = nbytes - count) > buf.length ? buf.length
- : (int) rem);
- if (x == -1) {
- eof = true;
- return count;
- }
- count += x;
- }
- return count;
- }
- throw new IllegalArgumentException();
- }
-
- /**
- * Returns 0 if this stream has been closed, 1 otherwise.
- *
- * @throws IOException
- * If an error occurs
- */
- public int available() throws IOException {
- if (closed) {
- throw new IOException(Msg.getString("K0059"));
- }
- if (eof) {
- return 0;
- }
- return 1;
- }
-
- /**
- * Closes the stream
- *
- * @throws IOException
- * If an error occurs closing the stream
- */
- public void close() throws IOException {
- if (!closed) {
- inf.end();
- closed = true;
- eof = true;
- super.close();
- }
- }
-
- /**
- * Marks the current position in the stream.
- *
- * This implementation overrides the supertype implementation to do nothing
- * at all.
- *
- * @param readlimit
- * of no use
- */
- public void mark(int readlimit) {
- // do nothing
- }
-
- /**
- * Reset the position of the stream to the last mark position.
- *
- * This implementation overrides the supertype implementation and always
- * throws an {@link IOException IOException} when called.
- *
- * @throws IOException
- * if the method is called
- */
- public void reset() throws IOException{
- throw new IOException();
- }
-
- /**
- * Answers whether the receiver implements mark semantics. This type
- * does not support mark, so always responds <code>false</code>.
- * @return false
- */
- public boolean markSupported() {
- return false;
- }
-
-}
+/* 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.zip;
+
+
+import java.io.EOFException;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.harmony.luni.util.Msg;
+
+/**
+ * InflaterOuputStream read data which has been compressed using the DEFLATE
+ * compression method.
+ *
+ * @see Inflater
+ * @see DeflaterOutputStream
+ */
+public class InflaterInputStream extends FilterInputStream {
+
+ protected Inflater inf;
+
+ protected byte[] buf;
+
+ protected int len;
+
+ boolean closed;
+
+ boolean eof;
+
+ static final int BUF_SIZE = 512;
+
+ /**
+ * Constructs a new InflaterOutputStream on is
+ *
+ * @param is The InputStream to read data from
+ */
+ public InflaterInputStream(InputStream is) {
+ this(is, new Inflater(), BUF_SIZE);
+ }
+
+ /**
+ * Constructs a new InflaterOutputStream on is, using the Inflater provided
+ * in inf.
+ *
+ * @param is
+ * The InputStream to read data from
+ * @param inf
+ * The Inflater to use for decompression
+ */
+ public InflaterInputStream(InputStream is, Inflater inf) {
+ this(is, inf, BUF_SIZE);
+ }
+
+ /**
+ * Constructs a new InflaterOutputStream on is, using the Inflater provided
+ * in inf. The size of the inflation buffer is determined by bsize.
+ *
+ * @param is
+ * The InputStream to read data from
+ * @param inf
+ * The Inflater to use for decompression
+ * @param bsize
+ * size of the inflation buffer
+ */
+ public InflaterInputStream(InputStream is, Inflater inf, int bsize) {
+ super(is);
+ if (is == null || inf == null) {
+ throw new NullPointerException();
+ }
+ if (bsize <= 0) {
+ throw new IllegalArgumentException();
+ }
+ this.inf = inf;
+ buf = new byte[bsize];
+ }
+
+ /**
+ * Reads a single byte of decompressed data.
+ *
+ * @return byte read
+ * @throws IOException
+ * If an error occurs reading
+ */
+ public int read() throws IOException {
+ byte[] b = new byte[1];
+ if (read(b, 0, 1) == -1) {
+ return -1;
+ }
+ return b[0] & 0xff;
+ }
+
+ /**
+ * Reads up to nbytes of decompressed data and stores it in buf starting at
+ * off.
+ *
+ * @param buffer
+ * Buffer to store into
+ * @param off
+ * offset in buffer to store at
+ * @param nbytes
+ * number of bytes to store
+ * @return Number of uncompressed bytes read
+ * @throws IOException
+ * If an error occurs reading
+ */
+ public int read(byte[] buffer, int off, int nbytes) throws IOException {
+ /* [MSG "K0059", "Stream is closed"] */
+ if (closed) {
+ throw new IOException(Msg.getString("K0059"));
+ }
+
+ if (null == buffer) {
+ throw new NullPointerException();
+ }
+
+ if (off < 0 || nbytes < 0 || off + nbytes > buffer.length) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ if (nbytes == 0) {
+ return 0;
+ }
+
+ if (inf.finished()) {
+ eof = true;
+ return -1;
+ }
+
+ // avoid int overflow, check null buffer
+ if (off <= buffer.length && nbytes >= 0 && off >= 0
+ && buffer.length - off >= nbytes) {
+ do {
+ if (inf.needsInput()) {
+ fill();
+ }
+ int result;
+ try {
+ result = inf.inflate(buffer, off, nbytes);
+ } catch (DataFormatException e) {
+ if (len == -1) {
+ throw new EOFException();
+ }
+ throw (IOException)(new IOException().initCause(e));
+ }
+ if (result > 0) {
+ return result;
+ } else if (inf.finished()) {
+ eof = true;
+ return -1;
+ } else if (inf.needsDictionary()) {
+ return -1;
+ } else if (len == -1) {
+ throw new EOFException();
+ // If result == 0, fill() and try again
+ }
+ } while (true);
+ }
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ protected void fill() throws IOException {
+ if (closed) {
+ throw new IOException(Msg.getString("K0059"));
+ }
+ if ((len = in.read(buf)) > 0) {
+ inf.setInput(buf, 0, len);
+ }
+ }
+
+ /**
+ * Skips up to nbytes of uncompressed data.
+ *
+ * @param nbytes
+ * Number of bytes to skip
+ * @return Number of uncompressed bytes skipped
+ * @throws IOException
+ * If an error occurs skipping
+ */
+ public long skip(long nbytes) throws IOException {
+ if (nbytes >= 0) {
+ long count = 0, rem = 0;
+ while (count < nbytes) {
+ int x = read(buf, 0,
+ (rem = nbytes - count) > buf.length ? buf.length
+ : (int) rem);
+ if (x == -1) {
+ eof = true;
+ return count;
+ }
+ count += x;
+ }
+ return count;
+ }
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * Returns 0 if this stream has been closed, 1 otherwise.
+ *
+ * @throws IOException
+ * If an error occurs
+ */
+ public int available() throws IOException {
+ if (closed) {
+ throw new IOException(Msg.getString("K0059"));
+ }
+ if (eof) {
+ return 0;
+ }
+ return 1;
+ }
+
+ /**
+ * Closes the stream
+ *
+ * @throws IOException
+ * If an error occurs closing the stream
+ */
+ public void close() throws IOException {
+ if (!closed) {
+ inf.end();
+ closed = true;
+ eof = true;
+ super.close();
+ }
+ }
+
+ /**
+ * Marks the current position in the stream.
+ *
+ * This implementation overrides the supertype implementation to do nothing
+ * at all.
+ *
+ * @param readlimit
+ * of no use
+ */
+ public void mark(int readlimit) {
+ // do nothing
+ }
+
+ /**
+ * Reset the position of the stream to the last mark position.
+ *
+ * This implementation overrides the supertype implementation and always
+ * throws an {@link IOException IOException} when called.
+ *
+ * @throws IOException
+ * if the method is called
+ */
+ public void reset() throws IOException{
+ throw new IOException();
+ }
+
+ /**
+ * Answers whether the receiver implements mark semantics. This type
+ * does not support mark, so always responds <code>false</code>.
+ * @return false
+ */
+ public boolean markSupported() {
+ return false;
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipConstants.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipConstants.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipConstants.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipConstants.java Thu Sep 14 19:40:33 2006
@@ -1,32 +1,32 @@
-/* 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;
-
-
-interface ZipConstants {
-
- public static final long LOCSIG = 0x4034b50, EXTSIG = 0x8074b50,
- CENSIG = 0x2014b50, ENDSIG = 0x6054b50;
-
- public static final int LOCHDR = 30, EXTHDR = 16, CENHDR = 46, ENDHDR = 22,
- LOCVER = 4, LOCFLG = 6, LOCHOW = 8, LOCTIM = 10, LOCCRC = 14,
- LOCSIZ = 18, LOCLEN = 22, LOCNAM = 26, LOCEXT = 28, EXTCRC = 4,
- EXTSIZ = 8, EXTLEN = 12, CENVEM = 4, CENVER = 6, CENFLG = 8,
- CENHOW = 10, CENTIM = 12, CENCRC = 16, CENSIZ = 20, CENLEN = 24,
- CENNAM = 28, CENEXT = 30, CENCOM = 32, CENDSK = 34, CENATT = 36,
- CENATX = 38, CENOFF = 42, ENDSUB = 8, ENDTOT = 10, ENDSIZ = 12,
- ENDOFF = 16, ENDCOM = 20;
-}
+/* 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;
+
+
+interface ZipConstants {
+
+ public static final long LOCSIG = 0x4034b50, EXTSIG = 0x8074b50,
+ CENSIG = 0x2014b50, ENDSIG = 0x6054b50;
+
+ public static final int LOCHDR = 30, EXTHDR = 16, CENHDR = 46, ENDHDR = 22,
+ LOCVER = 4, LOCFLG = 6, LOCHOW = 8, LOCTIM = 10, LOCCRC = 14,
+ LOCSIZ = 18, LOCLEN = 22, LOCNAM = 26, LOCEXT = 28, EXTCRC = 4,
+ EXTSIZ = 8, EXTLEN = 12, CENVEM = 4, CENVER = 6, CENFLG = 8,
+ CENHOW = 10, CENTIM = 12, CENCRC = 16, CENSIZ = 20, CENLEN = 24,
+ CENNAM = 28, CENEXT = 30, CENCOM = 32, CENDSK = 34, CENATT = 36,
+ CENATX = 38, CENOFF = 42, ENDSUB = 8, ENDTOT = 10, ENDSIZ = 12,
+ ENDOFF = 16, ENDCOM = 20;
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipEntry.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipEntry.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipEntry.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipEntry.java Thu Sep 14 19:40:33 2006
@@ -1,338 +1,338 @@
-/* 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.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-/**
- * ZipEntry represents an entry in a zip file.
- *
- * @see ZipFile
- * @see ZipInputStream
- */
-public class ZipEntry implements ZipConstants, Cloneable {
- String name, comment;
-
- long compressedSize = -1, crc = -1, size = -1, dataOffset = -1;
-
- int compressionMethod = -1, time = -1, modDate = -1;
-
- 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)
- throw new NullPointerException();
- if (name.length() > 0xFFFF)
- throw new IllegalArgumentException();
- 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;
- }
-
- long getOffset() {
- return dataOffset;
- }
-
- /**
- * 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)
- this.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)
- 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)
- 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)
- throw new IllegalArgumentException();
- compressionMethod = value;
- }
-
- void setName(String entryName) {
- name = entryName;
- }
-
- void setOffset(long value) {
- dataOffset = 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)
- 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;
- }
- }
-
- /**
- * Answers the string representation of this ZipEntry.
- *
- * @return the string representation of this ZipEntry
- */
- public String toString() {
- 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;
- this.time = (int) modTime;
- this.size = size;
- this.compressedSize = compressedSize;
- this.crc = crc;
- this.compressionMethod = compressionMethod;
- this.modDate = (int) modDate;
- this.dataOffset = offset;
- }
-
- /**
- * Constructs a new ZipEntry using the values obtained from ze.
- *
- * @param ze
- * ZipEntry from which to obtain values.
- */
- public ZipEntry(ZipEntry ze) {
- this.name = ze.name;
- this.comment = ze.comment;
- this.time = ze.time;
- this.size = ze.size;
- this.compressedSize = ze.compressedSize;
- this.crc = ze.crc;
- this.compressionMethod = ze.compressionMethod;
- this.modDate = ze.modDate;
- this.extra = ze.extra;
- this.dataOffset = ze.dataOffset;
- }
-
- /**
- * Returns a shallow copy of this entry
- *
- * @return a copy of this entry
- */
- public Object clone() {
- return new ZipEntry(this);
- }
-
- /**
- * Returns the hashCode for this ZipEntry.
- *
- * @return the hashCode of the entry
- */
- public int hashCode() {
- return name.hashCode();
- }
-}
+/* 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.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+/**
+ * ZipEntry represents an entry in a zip file.
+ *
+ * @see ZipFile
+ * @see ZipInputStream
+ */
+public class ZipEntry implements ZipConstants, Cloneable {
+ String name, comment;
+
+ long compressedSize = -1, crc = -1, size = -1, dataOffset = -1;
+
+ int compressionMethod = -1, time = -1, modDate = -1;
+
+ 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)
+ throw new NullPointerException();
+ if (name.length() > 0xFFFF)
+ throw new IllegalArgumentException();
+ 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;
+ }
+
+ long getOffset() {
+ return dataOffset;
+ }
+
+ /**
+ * 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)
+ this.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)
+ 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)
+ 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)
+ throw new IllegalArgumentException();
+ compressionMethod = value;
+ }
+
+ void setName(String entryName) {
+ name = entryName;
+ }
+
+ void setOffset(long value) {
+ dataOffset = 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)
+ 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;
+ }
+ }
+
+ /**
+ * Answers the string representation of this ZipEntry.
+ *
+ * @return the string representation of this ZipEntry
+ */
+ public String toString() {
+ 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;
+ this.time = (int) modTime;
+ this.size = size;
+ this.compressedSize = compressedSize;
+ this.crc = crc;
+ this.compressionMethod = compressionMethod;
+ this.modDate = (int) modDate;
+ this.dataOffset = offset;
+ }
+
+ /**
+ * Constructs a new ZipEntry using the values obtained from ze.
+ *
+ * @param ze
+ * ZipEntry from which to obtain values.
+ */
+ public ZipEntry(ZipEntry ze) {
+ this.name = ze.name;
+ this.comment = ze.comment;
+ this.time = ze.time;
+ this.size = ze.size;
+ this.compressedSize = ze.compressedSize;
+ this.crc = ze.crc;
+ this.compressionMethod = ze.compressionMethod;
+ this.modDate = ze.modDate;
+ this.extra = ze.extra;
+ this.dataOffset = ze.dataOffset;
+ }
+
+ /**
+ * Returns a shallow copy of this entry
+ *
+ * @return a copy of this entry
+ */
+ public Object clone() {
+ return new ZipEntry(this);
+ }
+
+ /**
+ * Returns the hashCode for this ZipEntry.
+ *
+ * @return the hashCode of the entry
+ */
+ public int hashCode() {
+ return name.hashCode();
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipEntry.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipException.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipException.java Thu Sep 14 19:40:33 2006
@@ -1,50 +1,50 @@
-/* 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.IOException;
-
-/**
- * This runtime exception is thrown by ZipFile and ZipInputStream when the file
- * or stream is not a valid zip file.
- *
- * @see ZipFile
- * @see ZipInputStream
- */
-public class ZipException extends IOException {
-
- 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 and message
- * filled in.
- *
- * @param detailMessage
- * String The detail message for the exception.
- */
- public ZipException(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;
+
+
+import java.io.IOException;
+
+/**
+ * This runtime exception is thrown by ZipFile and ZipInputStream when the file
+ * or stream is not a valid zip file.
+ *
+ * @see ZipFile
+ * @see ZipInputStream
+ */
+public class ZipException extends IOException {
+
+ 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 and message
+ * filled in.
+ *
+ * @param detailMessage
+ * String The detail message for the exception.
+ */
+ public ZipException(String detailMessage) {
+ super(detailMessage);
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipException.java
------------------------------------------------------------------------------
svn:eol-style = native