harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r350181 [53/198] - in /incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core: ./ depends/ depends/files/ depends/jars/ depends/libs/ depends/libs/linux.IA32/ depends/libs/win.IA32/ depends/oss/ depends/oss/linux.IA32/ depends/oss/win.I...
Date Thu, 01 Dec 2005 06:04:00 GMT
Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/Inflater.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/Inflater.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/Inflater.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/Inflater.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,305 @@
+/* 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;
+
+
+/**
+ * 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 = false; // Set by the inflateImpl native
+
+	private boolean needsDictionary = false; // Set by the inflateImpl native
+
+	private boolean noHeader = false;
+
+	private long streamHandle = -1;
+
+	private byte[] inputBuffer = null;
+
+	int inRead = 0, inLength = 0;
+
+	// Fill in the JNI id caches
+	private static native void oneTimeInitialization();
+
+	static {
+		oneTimeInitialization();
+	}
+
+	/**
+	 * Release any resources associated with this Inflater. Any unused
+	 * input/ouput is discarded. This is also called by the finalize method.
+	 */
+	public synchronized void end() {
+		if (streamHandle != -1) {
+			endImpl(streamHandle);
+			inRead = 0;
+			inputBuffer = null;
+			inLength = 0;
+			streamHandle = -1;
+		}
+	}
+
+	private native synchronized void endImpl(long handle);
+
+	protected void finalize() {
+		end();
+	}
+
+	/**
+	 * Indicates if the Inflater has inflated the entire defalted 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 associayted 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 unred 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();
+
+		return getTotalInImpl(streamHandle);
+	}
+
+	private synchronized native int 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();
+
+		return getTotalOutImpl(streamHandle);
+	}
+
+	private native synchronized int 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 wcih 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(com.ibm.oti.util.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) {
+		this.noHeader = 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() {
+		if (inputBuffer == null)
+			throw new IllegalStateException();
+		return needsDictionary;
+	}
+
+	public synchronized boolean needsInput() {
+		return inRead == inLength;
+	}
+
+	/**
+	 * Resets the Inflater.
+	 */
+	public synchronized void reset() {
+		if (streamHandle == -1)
+			throw new NullPointerException();
+		inputBuffer = null;
+		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
+	 *            offest 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) {
+			inputBuffer = buf;
+			inRead = 0;
+			inLength = nbytes;
+			setInputImpl(buf, off, nbytes, streamHandle);
+		} else
+			throw new ArrayIndexOutOfBoundsException();
+	}
+
+	private native synchronized void setInputImpl(byte[] buf, int off,
+			int nbytes, long handle);
+
+	private native long createStream(boolean noHeader1);
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/InflaterInputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/InflaterInputStream.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/InflaterInputStream.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/InflaterInputStream.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,231 @@
+/* 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 com.ibm.oti.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 = false;
+
+	boolean eof = false;
+
+	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 dsize 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
+	 *            sie 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
+	 * @exception 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
+	 * @exception 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) {
+			if (nbytes == 0)
+				return 0;
+			do {
+				if (inf.needsInput())
+					fill();
+				int result;
+				try {
+					result = inf.inflate(buffer, off, nbytes);
+				} catch (DataFormatException e) {
+					if (len == -1)
+						throw new EOFException();
+					throw new IOException(e.getMessage());
+				}
+				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
+	 * @exception 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.
+	 * 
+	 * @exception 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
+	 * 
+	 * @exception IOException
+	 *                If an error occurs closing the stream
+	 */
+	public void close() throws IOException {
+		if (!closed) {
+			inf.end();
+			closed = true;
+			eof = true;
+			super.close();
+		}
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipConstants.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipConstants.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipConstants.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipConstants.java Wed Nov 30 21:29:27 2005
@@ -0,0 +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;
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipEntry.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipEntry.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipEntry.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipEntry.java Wed Nov 30 21:29:27 2005
@@ -0,0 +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();
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipException.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipException.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipException.java Wed Nov 30 21:29:27 2005
@@ -0,0 +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 {
+
+	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);
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipFile.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipFile.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipFile.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipFile.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,239 @@
+/* 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.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
+
+import com.ibm.oti.util.Msg;
+import com.ibm.oti.util.Util;
+
+/**
+ * ZipFile is used to read zip entries and their associated data from zip files.
+ * 
+ * @see ZipInputStream
+ * @see ZipEntry
+ */
+
+public class ZipFile implements ZipConstants {
+
+	private String fileName;
+
+	long descriptor = -1;
+
+	private int size = -1;
+
+	private int mode;
+	static {
+		ntvinit();
+	}
+
+	/**
+	 * Open zip file for read.
+	 */
+	public static final int OPEN_READ = 1;
+
+	/**
+	 * Delete zip file when closed.
+	 */
+	public static final int OPEN_DELETE = 4;
+
+	/**
+	 * Constructs a new ZipFile opened on the specified File.
+	 * 
+	 * @param file
+	 *            the File
+	 */
+	public ZipFile(File file) throws ZipException, IOException {
+		this(file.getPath());
+	}
+
+	/**
+	 * Constructs a new ZipFile opened on the specified File using the specified
+	 * mode.
+	 * 
+	 * @param file
+	 *            the File
+	 * @param mode
+	 *            the mode to use, either OPEN_READ or OPEN_READ | OPEN_DELETE
+	 */
+	public ZipFile(File file, int mode) throws IOException {
+		if (mode == OPEN_READ || mode == (OPEN_READ | OPEN_DELETE)) {
+			fileName = file.getPath();
+			SecurityManager security = System.getSecurityManager();
+			if (security != null)
+				security.checkRead(fileName);
+			this.mode = mode;
+			openZip(fileName);
+		} else
+			throw new IllegalArgumentException();
+	}
+
+	/**
+	 * Constructs a new ZipFile opened on the specified file path name.
+	 * 
+	 * @param filename
+	 *            the file path name
+	 */
+	public ZipFile(String filename) throws IOException {
+		SecurityManager security = System.getSecurityManager();
+		if (security != null)
+			security.checkRead(filename);
+		fileName = filename;
+		openZip(fileName);
+	}
+
+	private void openZip(String filename) throws IOException {
+		int result = openZipImpl(Util.getBytes(fileName));
+		if (result != 0) {
+			switch (result) {
+			case 1:
+				throw new ZipException(Msg.getString("K01c3", fileName));
+			case 2:
+				throw new ZipException(Msg.getString("K01c4", fileName));
+			default:
+				throw new OutOfMemoryError();
+			}
+		}
+	}
+
+	protected void finalize() throws IOException {
+		close();
+	}
+
+	/**
+	 * Closes this ZipFile.
+	 */
+	public void close() throws IOException {
+		if (fileName != null) {
+			// Only close initialized instances
+			closeZipImpl();
+			if ((mode & OPEN_DELETE) != 0)
+				new File(fileName).delete();
+		}
+	}
+
+	/**
+	 * Answers all of the zip entries contained in this ZipFile.
+	 * 
+	 * @return an Enumeration of the zip entries
+	 */
+	public Enumeration entries() {
+		return new ZFEnum();
+	}
+
+	/**
+	 * Gets the zip entry with the specified name from this ZipFile.
+	 * 
+	 * @param entryName
+	 *            the name of the entry in the zip file
+	 * @return a ZipEntry or null if the entryname does not exist in the zip
+	 *         file
+	 */
+	public ZipEntry getEntry(String entryName) {
+		if (entryName != null) {
+			ZipEntry entry = getEntryImpl(descriptor, entryName);
+			return entry;
+		}
+		throw new NullPointerException();
+	}
+
+	/**
+	 * Answers an input stream on the data of the specified ZipEntry.
+	 * 
+	 * @param entry
+	 *            the ZipEntry
+	 * @return an input stream on the ZipEntry data
+	 */
+	public InputStream getInputStream(ZipEntry entry) throws IOException {
+		byte[] buf = inflateEntryImpl2(descriptor, entry.getName());
+		if (buf == null)
+			return null;
+		return new ByteArrayInputStream(buf);
+	}
+
+	/**
+	 * Gets the file name of this ZipFile.
+	 * 
+	 * @return the file name of this ZipFile
+	 */
+	public String getName() {
+		return fileName;
+	}
+
+	private synchronized native int openZipImpl(byte[] fileName1);
+
+	private synchronized native void closeZipImpl() throws IOException;
+
+	private native ZipEntry getEntryImpl(long descriptor1, String entryName);
+
+	private native byte[] inflateEntryImpl2(long descriptor1, String entryName)
+			throws ZipException;
+
+	/**
+	 * Returns the number of ZipEntries in this ZipFile.
+	 * 
+	 * @return Number of entries in this file
+	 */
+	public int size() {
+		if (size != -1)
+			return size;
+
+		size = 0;
+		Enumeration e = entries();
+		while (e.hasMoreElements()) {
+			size++;
+			e.nextElement();
+		}
+		return size;
+
+	}
+
+	private static native void ntvinit();
+
+	class ZFEnum implements Enumeration {
+		private long nextEntryPointer;
+
+		private ZipEntry current;
+
+		ZFEnum() {
+			nextEntryPointer = resetZip(descriptor);
+			current = getNextEntry(descriptor, nextEntryPointer);
+		}
+
+		private native long resetZip(long descriptor1);
+
+		private native ZipEntry getNextEntry(long descriptor1,
+				long nextEntryPointer1);
+
+		public boolean hasMoreElements() {
+			return current != null;
+		}
+
+		public Object nextElement() {
+			if (current == null)
+				throw new NoSuchElementException();
+			ZipEntry ze = current;
+			current = getNextEntry(descriptor, nextEntryPointer);
+			return ze;
+		}
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipInputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipInputStream.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipInputStream.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipInputStream.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,330 @@
+/* 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.IOException;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+
+import com.ibm.oti.util.Msg;
+import com.ibm.oti.util.Util;
+
+/**
+ * ZipInputStream is an input stream for reading zip files.
+ * 
+ * @see ZipEntry
+ * @see ZipFile
+ */
+public class ZipInputStream extends InflaterInputStream implements ZipConstants {
+	static final int DEFLATED = 8;
+
+	static final int STORED = 0;
+
+	static final int ZIPDataDescriptorFlag = 8;
+
+	static final int ZIPLocalHeaderVersionNeeded = 20;
+
+	private boolean zipClosed = false;
+
+	private boolean entriesEnd = false;
+
+	private boolean hasDD = false;
+
+	private int entryIn = 0;
+
+	private int inRead, lastRead = 0;
+
+	ZipEntry currentEntry;
+
+	private byte[] hdrBuf = new byte[LOCHDR - LOCVER];
+
+	private CRC32 crc = new CRC32();
+
+	private byte[] nameBuf = new byte[256];
+
+	private char[] charBuf = new char[256];
+
+	/**
+	 * Constructs a new ZipInputStream on the specified input stream.
+	 * 
+	 * @param stream
+	 *            the input stream
+	 */
+	public ZipInputStream(InputStream stream) {
+		super(new PushbackInputStream(stream, BUF_SIZE), new Inflater(true));
+		if (stream == null)
+			throw new NullPointerException();
+	}
+
+	/**
+	 * Closes this ZipInputStream.
+	 */
+	public void close() throws IOException {
+		closeEntry(); // Close the current entry
+		zipClosed = true;
+		super.close();
+	}
+
+	/**
+	 * Closes the current zip entry and positions to read the next entry.
+	 */
+	public void closeEntry() throws IOException {
+		if (zipClosed)
+			throw new IOException(Msg.getString("K0059"));
+		if (currentEntry == null)
+			return;
+		if (currentEntry instanceof java.util.jar.JarEntry) {
+			Attributes temp = ((JarEntry) currentEntry).getAttributes();
+			if (temp != null && temp.containsKey("hidden"))
+				return;
+		}
+		// Ensure all entry bytes are read
+		skip(Long.MAX_VALUE);
+		int inB, out;
+		if (currentEntry.compressionMethod == DEFLATED) {
+			inB = inf.getTotalIn();
+			out = inf.getTotalOut();
+		} else {
+			inB = inRead;
+			out = inRead;
+		}
+		int diff = 0;
+		// Pushback any required bytes
+		if ((diff = entryIn - inB) != 0)
+			((PushbackInputStream) in).unread(buf, len - diff, diff);
+
+		if (hasDD) {
+			in.read(hdrBuf, 0, EXTHDR);
+			if (getLong(hdrBuf, 0) != EXTSIG)
+				throw new ZipException(Msg.getString("K0020"));
+			currentEntry.crc = getLong(hdrBuf, EXTCRC);
+			currentEntry.compressedSize = getLong(hdrBuf, EXTSIZ);
+			currentEntry.size = getLong(hdrBuf, EXTLEN);
+		}
+		if (currentEntry.crc != crc.getValue())
+			throw new ZipException(Msg.getString("K0077"));
+		if (currentEntry.compressedSize != inB || currentEntry.size != out)
+			throw new ZipException(Msg.getString("K00ae"));
+
+		inf.reset();
+		lastRead = inRead = entryIn = len = 0;
+		crc.reset();
+		currentEntry = null;
+	}
+
+	/**
+	 * Reads the next zip entry from this ZipInputStream.
+	 */
+	public ZipEntry getNextEntry() throws IOException {
+		if (currentEntry != null)
+			closeEntry();
+		if (entriesEnd)
+			return null;
+
+		int x = 0, count = 0;
+		while (count != 4) {
+			count += x = in.read(hdrBuf, count, 4 - count);
+			if (x == -1)
+				return null;
+		}
+		long hdr = getLong(hdrBuf, 0);
+		if (hdr == CENSIG) {
+			entriesEnd = true;
+			return null;
+		}
+		if (hdr != LOCSIG)
+			return null;
+
+		// Read the local header
+		count = 0;
+		while (count != (LOCHDR - LOCVER)) {
+			count += x = in.read(hdrBuf, count, (LOCHDR - LOCVER) - count);
+			if (x == -1)
+				throw new EOFException();
+		}
+		int version = getShort(hdrBuf, 0) & 0xff;
+		if (version > ZIPLocalHeaderVersionNeeded)
+			throw new ZipException(Msg.getString("K0008"));
+		int flags = getShort(hdrBuf, LOCFLG - LOCVER);
+		hasDD = ((flags & ZIPDataDescriptorFlag) == ZIPDataDescriptorFlag);
+		int cetime = getShort(hdrBuf, LOCTIM - LOCVER);
+		int cemodDate = getShort(hdrBuf, LOCTIM - LOCVER + 2);
+		int cecompressionMethod = getShort(hdrBuf, LOCHOW - LOCVER);
+		long cecrc = 0, cecompressedSize = 0, cesize = -1;
+		if (!hasDD) {
+			cecrc = getLong(hdrBuf, LOCCRC - LOCVER);
+			cecompressedSize = getLong(hdrBuf, LOCSIZ - LOCVER);
+			cesize = getLong(hdrBuf, LOCLEN - LOCVER);
+		}
+		int flen = getShort(hdrBuf, LOCNAM - LOCVER);
+		if (flen == 0)
+			throw new ZipException(Msg.getString("K000a"));
+		int elen = getShort(hdrBuf, LOCEXT - LOCVER);
+
+		count = 0;
+		if (flen > nameBuf.length) {
+			nameBuf = new byte[flen];
+			charBuf = new char[flen];
+		}
+		while (count != flen) {
+			count += x = in.read(nameBuf, count, flen - count);
+			if (x == -1)
+				throw new EOFException();
+		}
+		currentEntry = createZipEntry(Util.convertUTF8WithBuf(nameBuf, charBuf,
+				0, flen));
+		currentEntry.time = cetime;
+		currentEntry.modDate = cemodDate;
+		currentEntry.setMethod(cecompressionMethod);
+		if (cesize != -1) {
+			currentEntry.setCrc(cecrc);
+			currentEntry.setSize(cesize);
+			currentEntry.setCompressedSize(cecompressedSize);
+		}
+		if (elen > 0) {
+			count = 0;
+			byte[] e = new byte[elen];
+			while (count != elen) {
+				count += x = in.read(e, count, elen - count);
+				if (x == -1)
+					throw new EOFException();
+			}
+			currentEntry.setExtra(e);
+		}
+		return currentEntry;
+	}
+
+	/* Read 4 bytes from the buffer and store it as an int */
+
+	/**
+	 * Reads up to the specified number of uncompressed bytes into the buffer
+	 * starting at the offset.
+	 * 
+	 * @param buffer
+	 *            a byte array
+	 * @param start
+	 *            the starting offset into the buffer
+	 * @param length
+	 *            the number of bytes to read
+	 * @return the number of bytes read
+	 */
+	public int read(byte[] buffer, int start, int length) throws IOException {
+		if (zipClosed)
+			throw new IOException(Msg.getString("K0059"));
+		if (inf.finished() || currentEntry == null)
+			return -1;
+		// avoid int overflow, check null buffer
+		if (start <= buffer.length && length >= 0 && start >= 0
+				&& buffer.length - start >= length) {
+			if (currentEntry.compressionMethod == STORED) {
+				int csize = (int) currentEntry.size;
+				if (inRead >= csize)
+					return -1;
+				if (lastRead >= len) {
+					lastRead = 0;
+					if ((len = in.read(buf)) == -1)
+						return -1;
+					entryIn += len;
+				}
+				int toRead = length > len ? len - lastRead : length;
+				if ((csize - inRead) < toRead)
+					toRead = csize - inRead;
+				System.arraycopy(buf, lastRead, buffer, start, toRead);
+				lastRead += toRead;
+				inRead += toRead;
+				crc.update(buffer, start, toRead);
+				return toRead;
+			}
+			if (inf.needsInput()) {
+				fill();
+				if (len > 0)
+					entryIn += len;
+			}
+			int read = 0;
+			try {
+				read = inf.inflate(buffer, start, length);
+			} catch (DataFormatException e) {
+				throw new ZipException(e.getMessage());
+			}
+			if (read == 0 && inf.finished())
+				return -1;
+			crc.update(buffer, start, read);
+			return read;
+		}
+		throw new ArrayIndexOutOfBoundsException();
+	}
+
+	/**
+	 * Skips up to the specified number of bytes in the current zip entry.
+	 * 
+	 * @param value
+	 *            the number of bytes to skip
+	 * @return the number of bytes skipped
+	 */
+	public long skip(long value) throws IOException {
+		long skipped = 0;
+		int x = 0;
+		byte[] b = new byte[1024];
+		while (skipped != value) {
+			x = read(b, 0, (int) (b.length > value ? value : b.length));
+			if (x == -1)
+				return skipped;
+			skipped += x;
+		}
+		return skipped;
+	}
+
+	/**
+	 * Answers 1 if the EOF has been reached, otherwise returns 0.
+	 * 
+	 * @return 0 after EOF of current entry, 1 otherwise
+	 */
+	public int available() throws IOException {
+		if (zipClosed)
+			throw new IOException(Msg.getString("K0059"));
+		if (currentEntry == null)
+			return 1;
+		if (currentEntry.compressionMethod == STORED) {
+			if (inRead >= currentEntry.size)
+				return 0;
+		} else {
+			if (inf.finished())
+				return 0;
+		}
+		return 1;
+	}
+
+	protected ZipEntry createZipEntry(String name) {
+		return new ZipEntry(name);
+	}
+
+	private int getShort(byte[] buffer, int off) {
+		return (buffer[off] & 0xFF) | ((buffer[off + 1] & 0xFF) << 8);
+	}
+
+	private long getLong(byte[] buffer, int off) {
+		long l = 0;
+		l |= (buffer[off] & 0xFF);
+		l |= (buffer[off + 1] & 0xFF) << 8;
+		l |= (buffer[off + 2] & 0xFF) << 16;
+		l |= ((long) (buffer[off + 3] & 0xFF)) << 24;
+		return l;
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipOutputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipOutputStream.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipOutputStream.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/archive/src/java/util/zip/ZipOutputStream.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,386 @@
+/* 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.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Vector;
+
+import com.ibm.oti.util.Msg;
+
+/**
+ * ZipOuputStream is used to write ZipEntries to the underlying stream. Output
+ * from ZipOutputStream conforms to the ZipFile file format.
+ * 
+ * @see ZipInputStream
+ * @see ZipEntry
+ */
+public class ZipOutputStream extends DeflaterOutputStream implements
+		ZipConstants {
+
+	public static final int DEFLATED = 8;
+
+	public static final int STORED = 0;
+
+	static final int ZIPDataDescriptorFlag = 8;
+
+	static final int ZIPLocalHeaderVersionNeeded = 20;
+
+	private String comment;
+
+	private Vector entries = new Vector();
+
+	private int compressMethod = DEFLATED;
+
+	private int compressLevel = Deflater.DEFAULT_COMPRESSION;
+
+	private ByteArrayOutputStream cDir = new ByteArrayOutputStream();
+
+	private ZipEntry currentEntry;
+
+	private CRC32 crc = new CRC32();
+
+	private int offset = 0, curOffset = 0, nameLength;
+
+	private byte[] nameBytes;
+
+	/**
+	 * Contructs a new ZipOutputStream on p1
+	 * 
+	 * @param p1
+	 *            OutputStream The InputStream to output to
+	 */
+	public ZipOutputStream(OutputStream p1) {
+		super(p1, new Deflater(Deflater.DEFAULT_COMPRESSION, true));
+	}
+
+	/**
+	 * Closes the current ZipEntry if any. Closes the underlying output stream.
+	 * 
+	 * @exception IOException
+	 *                If an error occurs closing the stream
+	 */
+	public void close() throws IOException {
+		finish();
+		out.close();
+		out = null;
+	}
+
+	/**
+	 * Closes the current ZipEntry. Any entry terminal data is written to the
+	 * underlying stream.
+	 * 
+	 * @exception IOException
+	 *                If an error occurs closing the entry
+	 */
+	public void closeEntry() throws IOException {
+		if (cDir == null)
+			throw new IOException(Msg.getString("K0059"));
+		if (currentEntry == null)
+			return;
+		if (currentEntry.getMethod() == DEFLATED) {
+			super.finish();
+		}
+
+		// Verify values for STORED types
+		if (currentEntry.getMethod() == STORED) {
+			if (crc.getValue() != currentEntry.crc)
+				throw new ZipException(Msg.getString("K0077"));
+			if (currentEntry.size != crc.tbytes)
+				throw new ZipException(Msg.getString("K00ae"));
+		}
+		curOffset = LOCHDR;
+
+		// Write the DataDescriptor
+		if (currentEntry.getMethod() != STORED) {
+			curOffset += EXTHDR;
+			writeLong(out, EXTSIG);
+			writeLong(out, currentEntry.crc = crc.getValue());
+			writeLong(out, currentEntry.compressedSize = def.getTotalOut());
+			writeLong(out, currentEntry.size = def.getTotalIn());
+		}
+		// Update the CentralDirectory
+		writeLong(cDir, CENSIG);
+		writeShort(cDir, ZIPLocalHeaderVersionNeeded); // Version created
+		writeShort(cDir, ZIPLocalHeaderVersionNeeded); // Version to extract
+		writeShort(cDir, currentEntry.getMethod() == STORED ? 0
+				: ZIPDataDescriptorFlag);
+		writeShort(cDir, currentEntry.getMethod());
+		writeShort(cDir, currentEntry.time);
+		writeShort(cDir, currentEntry.modDate);
+		writeLong(cDir, crc.getValue());
+		if (currentEntry.getMethod() == DEFLATED) {
+			curOffset += writeLong(cDir, def.getTotalOut());
+			writeLong(cDir, def.getTotalIn());
+		} else {
+			curOffset += writeLong(cDir, crc.tbytes);
+			writeLong(cDir, crc.tbytes);
+		}
+		curOffset += writeShort(cDir, nameLength);
+		if (currentEntry.extra != null)
+			curOffset += writeShort(cDir, currentEntry.extra.length);
+		else
+			writeShort(cDir, 0);
+		String c;
+		if ((c = currentEntry.getComment()) != null)
+			writeShort(cDir, c.length());
+		else
+			writeShort(cDir, 0);
+		writeShort(cDir, 0); // Disk Start
+		writeShort(cDir, 0); // Internal File Attributes
+		writeLong(cDir, 0); // External File Attributes
+		writeLong(cDir, offset);
+		cDir.write(nameBytes);
+		nameBytes = null;
+		if (currentEntry.extra != null)
+			cDir.write(currentEntry.extra);
+		offset += curOffset;
+		if (c != null)
+			cDir.write(c.getBytes());
+		currentEntry = null;
+		crc.reset();
+		def.reset();
+		done = false;
+	}
+
+	/**
+	 * Indicates that all entries have been written to the stream. Any terminal
+	 * Zipfile information is written to the underlying stream.
+	 * 
+	 * @exception IOException
+	 *                If an error occurs while finishing
+	 */
+	public void finish() throws IOException {
+		if (out == null)
+			throw new IOException(Msg.getString("K0059"));
+		if (cDir == null)
+			return;
+		if (entries.size() == 0)
+			throw new ZipException(Msg.getString("K00b6"));
+		if (currentEntry != null)
+			closeEntry();
+		int cdirSize = cDir.size();
+		// Write Central Dir End
+		writeLong(cDir, ENDSIG);
+		writeShort(cDir, 0); // Disk Number
+		writeShort(cDir, 0); // Start Disk
+		writeShort(cDir, entries.size()); // Number of entries
+		writeShort(cDir, entries.size()); // Number of entries
+		writeLong(cDir, cdirSize); // Size of central dir
+		writeLong(cDir, offset); // Offset of central dir
+		if (comment != null) {
+			writeShort(cDir, comment.length());
+			cDir.write(comment.getBytes());
+		} else
+			writeShort(cDir, 0);
+		// Write the central dir
+		out.write(cDir.toByteArray());
+		cDir = null;
+
+	}
+
+	/**
+	 * Writes entry information for ze to the underlying stream. Data associated
+	 * with the entry can then be written using write(). After data is written
+	 * closeEntry() must be called to complete the storing of ze on the
+	 * underlying stream.
+	 * 
+	 * @param ze
+	 *            ZipEntry to store
+	 * @exception IOException
+	 *                If an error occurs storing the entry
+	 * @see #write
+	 */
+	public void putNextEntry(ZipEntry ze) throws java.io.IOException {
+		if (ze.getMethod() == STORED
+				|| (compressMethod == STORED && ze.getMethod() == -1)) {
+			if (ze.crc == -1)
+				/* [MSG "K0077", "Crc mismatch"] */
+				throw new ZipException(Msg.getString("K0077"));
+			if (ze.size == -1 && ze.compressedSize == -1)
+				/* [MSG "K00ae", "Size mismatch"] */
+				throw new ZipException(Msg.getString("K00ae"));
+			if (ze.size != ze.compressedSize && ze.compressedSize != -1
+					&& ze.size != -1)
+				/* [MSG "K00ae", "Size mismatch"] */
+				throw new ZipException(Msg.getString("K00ae"));
+		}
+		/* [MSG "K0059", "Stream is closed"] */
+		if (cDir == null)
+			throw new IOException(Msg.getString("K0059"));
+		if (currentEntry != null)
+			closeEntry();
+		if (entries.contains(ze.name))
+			/* [MSG "K0066", "Entry already exists: {0}"] */
+			throw new ZipException(Msg.getString("K0066", ze.name));
+		nameLength = utf8Count(ze.name);
+		if (nameLength > 0xffff)
+			/* [MSG "K01a7", "Name too long: {0}"] */
+			throw new IllegalArgumentException(Msg.getString("K01a7", ze.name));
+
+		def.setLevel(compressLevel);
+		currentEntry = ze;
+		entries.add(currentEntry.name);
+		if (currentEntry.getMethod() == -1)
+			currentEntry.setMethod(compressMethod);
+		writeLong(out, LOCSIG); // Entry header
+		writeShort(out, ZIPLocalHeaderVersionNeeded); // Extraction version
+		writeShort(out, currentEntry.getMethod() == STORED ? 0
+				: ZIPDataDescriptorFlag);
+		writeShort(out, currentEntry.getMethod());
+		if (currentEntry.getTime() == -1)
+			currentEntry.setTime(System.currentTimeMillis());
+		writeShort(out, currentEntry.time);
+		writeShort(out, currentEntry.modDate);
+
+		if (currentEntry.getMethod() == STORED) {
+			if (currentEntry.size == -1)
+				currentEntry.size = currentEntry.compressedSize;
+			else if (currentEntry.compressedSize == -1)
+				currentEntry.compressedSize = currentEntry.size;
+			writeLong(out, currentEntry.crc);
+			writeLong(out, currentEntry.size);
+			writeLong(out, currentEntry.size);
+		} else {
+			writeLong(out, 0);
+			writeLong(out, 0);
+			writeLong(out, 0);
+		}
+		writeShort(out, nameLength);
+		if (currentEntry.extra != null)
+			writeShort(out, currentEntry.extra.length);
+		else
+			writeShort(out, 0);
+		nameBytes = toUTF8Bytes(currentEntry.name, nameLength);
+		out.write(nameBytes);
+		if (currentEntry.extra != null)
+			out.write(currentEntry.extra);
+	}
+
+	/**
+	 * Sets the ZipFile comment associated with the file being written.
+	 * 
+	 */
+	public void setComment(String comment) {
+		if (comment.length() > 0xFFFF)
+			throw new IllegalArgumentException(Msg.getString("K0068"));
+		this.comment = comment;
+	}
+
+	/**
+	 * Sets the compression level to be used for writing entry data. This level
+	 * may be set on a per entry basis. level must have a value between 0 and
+	 * 10.
+	 * 
+	 */
+	public void setLevel(int level) {
+		if (level < Deflater.DEFAULT_COMPRESSION
+				|| level > Deflater.BEST_COMPRESSION)
+			throw new IllegalArgumentException();
+		compressLevel = level;
+	}
+
+	/**
+	 * Sets the compression method to be used when compressing entry data.
+	 * method must be one of STORED or DEFLATED.
+	 * 
+	 * @param method
+	 *            Compression method to use
+	 */
+	public void setMethod(int method) {
+		if (method != STORED && method != DEFLATED)
+			throw new IllegalArgumentException();
+		compressMethod = method;
+
+	}
+
+	private long writeLong(OutputStream os, long i) throws java.io.IOException {
+		// Write out the long value as an unsigned int
+		os.write((int) (i & 0xFF));
+		os.write((int) (i >> 8) & 0xFF);
+		os.write((int) (i >> 16) & 0xFF);
+		os.write((int) (i >> 24) & 0xFF);
+		return i;
+	}
+
+	private int writeShort(OutputStream os, int i) throws java.io.IOException {
+		os.write(i & 0xFF);
+		os.write((i >> 8) & 0xFF);
+		return i;
+
+	}
+
+	/**
+	 * Writes data for the current entry to the underlying stream.
+	 * 
+	 * @exception IOException
+	 *                If an error occurs writing to the stream
+	 */
+	public void write(byte[] buffer, int off, int nbytes)
+			throws java.io.IOException {
+		// avoid int overflow, check null buf
+		if ((off > buffer.length) || (nbytes < 0) || (off < 0)
+				|| (buffer.length - off < nbytes)) {
+			throw new IndexOutOfBoundsException();
+		}
+
+		if (currentEntry == null) {
+			/* [MSG "K00ab", "No active entry"] */
+			throw new ZipException(Msg.getString("K00ab"));
+		}
+
+		if (currentEntry.getMethod() == STORED)
+			out.write(buffer, off, nbytes);
+		else
+			super.write(buffer, off, nbytes);
+		crc.update(buffer, off, nbytes);
+	}
+
+	static int utf8Count(String value) {
+		int total = 0;
+		for (int i = value.length(); --i >= 0;) {
+			char ch = value.charAt(i);
+			if (ch < 0x80)
+				total++;
+			else if (ch < 0x800)
+				total += 2;
+			else
+				total += 3;
+		}
+		return total;
+	}
+
+	static byte[] toUTF8Bytes(String value, int length) {
+		byte[] result = new byte[length];
+		int pos = result.length;
+		for (int i = value.length(); --i >= 0;) {
+			char ch = value.charAt(i);
+			if (ch < 0x80)
+				result[--pos] = (byte) ch;
+			else if (ch < 0x800) {
+				result[--pos] = (byte) (0x80 | (ch & 0x3f));
+				result[--pos] = (byte) (0xc0 | (ch >> 6));
+			} else {
+				result[--pos] = (byte) (0x80 | (ch & 0x3f));
+				result[--pos] = (byte) (0x80 | ((ch >> 6) & 0x3f));
+				result[--pos] = (byte) (0xe0 | (ch >> 12));
+			}
+		}
+		return result;
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/build.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/build.xml?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/build.xml (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/build.xml Wed Nov 30 21:29:27 2005
@@ -0,0 +1,262 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- 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. -->
+
+<!-- ====================================================================== 
+     build-java-source    
+     Compile the Java source and package in component archives.
+     ====================================================================== -->
+<project name="build-java-source" default="default" basedir=".">
+    <description>
+		Compile the Java source and package in component archives.
+    </description>
+
+    <!-- Users need to set this property to use a different compiler -->
+    <!-- To use the eclipse compiler set the value of the below      -->
+    <!-- property to be "org.eclipse.jdt.core.JDTCompilerAdapter"    -->
+    <!-- This requires that the CLASSPATH of the environment where   -->
+    <!-- this Ant is running includes the Eclipse archives           -->
+    <!-- jdtCompilerAdapter.jar and org.eclipse.jdt.core_3.1.0.jar   -->
+    <property name="build.compiler" value="modern" />
+
+    <property name="build.output" location="../bin" />
+    <property name="depends.jars" location="../depends/jars" />
+    <property name="depends.files" location="../depends/files" />
+    <property name="components.patternsets" location="../depends/patternsets" />
+    <property name="components.output" location="../components" />
+    <property name="target.output" location="../deploy" />
+
+
+    <!-- ================================= 
+          target: default              
+         ================================= -->
+    <target name="default" 
+        description="Compile the Java source and package in component archives." 
+        depends="clean, compile, package, layout" />
+
+
+    <!-- ================================= 
+          target: clean            
+         ================================= -->
+    <target name="clean" depends="clean-bin, clean-layout, clean-package" />
+
+
+    <!-- ================================= 
+          target: clean-bin              
+         ================================= -->
+    <target name="clean-bin" description="Delete all built classes">
+        <delete includeemptydirs="true" failonerror="false">
+            <fileset dir="${build.output}">
+                <include name="**/**" />
+            </fileset>
+        </delete>
+    </target>
+
+    <!-- ================================= 
+          target: clean-package
+         ================================= -->
+    <target name="clean-package" description="Delete all built component jars">
+        <delete includeemptydirs="true" failonerror="false">
+            <fileset dir="${components.output}">
+                <include name="**/**" />
+            </fileset>
+        </delete>
+    </target>
+
+    <!-- ================================= 
+          target: package
+         ================================= -->
+    <target name="package" depends="compile" description="Create component jars">
+        <mkdir dir="${components.output}" />
+
+        <!-- Create archive jar -->
+        <jar destfile="${components.output}/archive.jar" manifest="archive/META-INF/MANIFEST.MF">
+            <fileset dir="${build.output}" 
+                includesfile="${components.patternsets}/archive.txt" 
+                excludesfile="${components.patternsets}/kernel.txt" />
+        </jar>
+
+        <!-- Create luni jar -->
+        <jar destfile="${components.output}/luni.jar" manifest="luni/META-INF/MANIFEST.MF">
+            <fileset dir="${build.output}" 
+                includesfile="${components.patternsets}/luni.txt" 
+                excludesfile="${components.patternsets}/kernel.txt" />
+        </jar>
+
+        <!-- Create nio jar -->
+        <jar destfile="${components.output}/nio.jar" manifest="nio/META-INF/MANIFEST.MF">
+            <fileset dir="${build.output}" 
+                includesfile="${components.patternsets}/nio.txt" 
+                excludesfile="${components.patternsets}/kernel.txt" />
+        </jar>
+
+        <!-- Create nio_char jar -->
+        <jar destfile="${components.output}/nio_char.jar" manifest="nio_char/META-INF/MANIFEST.MF">
+            <fileset dir="${build.output}" 
+                includesfile="${components.patternsets}/nio_char.txt" 
+                excludesfile="${components.patternsets}/kernel.txt" />
+        </jar>
+
+        <!-- Create security jar -->
+        <jar destfile="${components.output}/security.jar" manifest="security/META-INF/MANIFEST.MF">
+            <fileset dir="${build.output}" 
+                includesfile="${components.patternsets}/security.txt" 
+                excludesfile="${components.patternsets}/kernel.txt" />
+        </jar>
+
+        <!-- Create text jar -->
+        <jar destfile="${components.output}/text.jar" manifest="text/META-INF/MANIFEST.MF">
+            <fileset dir="${build.output}" 
+                includesfile="${components.patternsets}/text.txt" 
+                excludesfile="${components.patternsets}/kernel.txt" />
+        </jar>
+
+        <!-- Create math jar -->
+        <jar destfile="${components.output}/math.jar" manifest="math/META-INF/MANIFEST.MF">
+            <fileset dir="${build.output}" 
+                includesfile="${components.patternsets}/math.txt" 
+                excludesfile="${components.patternsets}/kernel.txt" />
+        </jar>
+
+        <!-- Create regex jar -->
+        <jar destfile="${components.output}/regex.jar" manifest="regex/META-INF/MANIFEST.MF">
+            <fileset dir="${build.output}" 
+                includesfile="${components.patternsets}/regex.txt" 
+                excludesfile="${components.patternsets}/kernel.txt" />
+        </jar>
+    </target>
+
+
+    <!-- ================================= 
+          target: compile              
+         ================================= -->
+    <target name="compile" depends="copy-resources" description="Compile the source">
+        <mkdir dir="${build.output}" />
+
+        <javac destdir="${build.output}" source="1.4" target="1.4" debug="on">
+            <src path="kernel/src" />
+            <src path="regex/src" />
+            <src path="math/src" />
+            <src path="archive/src" />
+            <src path="luni/src" />
+            <src path="nio/src" />
+            <src path="nio_char/src" />
+            <src path="security/src" />
+            <src path="text/src" />
+            <classpath location="${build.output}" />
+            <classpath>
+                <fileset dir="${depends.jars}">
+                    <include name="*.jar" />
+                </fileset>
+            </classpath>
+        </javac>
+    </target>
+
+
+    <!-- ================================= 
+          target: copy-resources              
+         ================================= -->
+    <target name="copy-resources" description="Copy non-Java files under src tree to the build output">
+        <mkdir dir="${build.output}" />
+
+        <copy todir="${build.output}" includeemptydirs="false">
+            <fileset dir="archive/src">
+                <exclude name="**/*.java" />
+            </fileset>
+            <fileset dir="luni/src">
+                <exclude name="**/*.java" />
+            </fileset>
+            <fileset dir="nio/src">
+                <exclude name="**/*.java" />
+            </fileset>
+            <fileset dir="nio_char/src">
+                <exclude name="**/*.java" />
+            </fileset>
+            <fileset dir="security/src">
+                <exclude name="**/*.java" />
+            </fileset>
+            <fileset dir="text/src">
+                <exclude name="**/*.java" />
+            </fileset>
+        </copy>
+    </target>
+
+
+    <!-- ================================= 
+          target: layout              
+         ================================= -->
+    <target name="layout" 
+        depends="package" 
+        description="Construct the correct directory structure for the class libs">
+        <!-- Create the structure -->
+        <mkdir dir="${target.output}/jre/bin" />
+        <mkdir dir="${target.output}/jre/lib/boot" />
+        <mkdir dir="${target.output}/jre/lib/ext" />
+        <mkdir dir="${target.output}/jre/lib/security" />
+
+        <!-- Copy across the dependency jars -->
+        <copy todir="${target.output}/jre/lib/boot" overwrite="yes">
+            <fileset dir="${depends.jars}">
+                <patternset includes="*.jar" />
+            </fileset>
+        </copy>
+
+        <!-- Copy across the component jars -->
+        <copy todir="${target.output}/jre/lib/boot" overwrite="yes">
+            <fileset dir="${components.output}">
+                <patternset includes="*.jar" />
+            </fileset>
+        </copy>
+
+        <!-- Copy across the support files -->
+        <copy todir="${target.output}/jre/lib/boot" overwrite="yes">
+            <fileset dir="${depends.files}">
+                <include name="bootclasspath.properties" />
+            </fileset>
+        </copy>
+        <fixcrlf srcdir="${target.output}/jre/lib/boot"
+            includes="bootclasspath.properties" />
+
+        <!-- NLS catalog files -->
+        <copy todir="${target.output}/jre/bin" overwrite="yes">
+            <fileset dir="${depends.files}">
+                <include name="harmony*.properties" />
+            </fileset>
+        </copy>
+
+        <copy todir="${target.output}/jre/lib/security" overwrite="yes">
+            <fileset dir="${depends.files}">
+                <include name="java.policy" />
+                <include name="java.security" />
+            </fileset>
+        </copy>
+    </target>
+
+
+    <!-- ================================= 
+          target: clean-layout              
+         ================================= -->
+    <target name="clean-layout">
+        <delete includeemptydirs="true" failonerror="false">
+            <fileset dir="${target.output}">
+                <include name="**/jre/bin/harmony*.properties" />
+                <include name="**/lib/*.properties" />
+                <include name="**/lib/boot/*" />
+                <include name="**/lib/ext/*" />
+                <include name="**/lib/security/*" />
+            </fileset>
+        </delete>
+    </target>
+</project>

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/META-INF/MANIFEST.MF?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/META-INF/MANIFEST.MF (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/META-INF/MANIFEST.MF Wed Nov 30 21:29:27 2005
@@ -0,0 +1,5 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: kernel
+Bundle-Version: 1.0.0
+Bundle-ClassPath: .
+Export-Package: java.lang, java.lang.reflect, java.lang.ref, java.security, com.ibm.oti.vm

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/com/ibm/oti/vm/VM.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/com/ibm/oti/vm/VM.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/com/ibm/oti/vm/VM.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/com/ibm/oti/vm/VM.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,248 @@
+/* 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 com.ibm.oti.vm;
+
+/**
+ * This class must be implemented by the vm vendor. Represents the running
+ * virtual machine. All VM specific API are implemented on this class.
+ * <p>
+ * Note that all methods in VM are static. There is no singleton instance which
+ * represents the actively running VM.
+ */
+public final class VM {
+
+	/**
+	 * This method must be provided by the vm vendor, as it is used by
+	 * com.ibm.oti.vm.MsgHelp.setLocale() to get the bootstrap ClassLoader.
+	 * MsgHelp uses the bootstrap ClassLoader to find the resource bundle of
+	 * messages packaged with the bootstrap classes. Returns the ClassLoader of
+	 * the method (including natives) at the specified depth on the stack of the
+	 * calling thread. Frames representing the VM implementation of
+	 * java.lang.reflect are not included in the list. This is not a public
+	 * method as it can return the bootstrap class loader, which should not be
+	 * accessed by non-bootstrap classes. Notes:
+	 * <ul>
+	 * <li>This method operates on the defining classes of methods on stack.
+	 * NOT the classes of receivers.</li>
+	 * <li>The item at depth zero is the caller of this method</li>
+	 * </ul>
+	 * 
+	 * @param depth
+	 *            the stack depth of the requested ClassLoader
+	 * @return the ClassLoader at the specified depth
+	 * @see java.lang.ClassLoader#getStackClassLoader
+	 */
+	static final ClassLoader getStackClassLoader(int depth) {
+		return null;
+	};
+
+	/**
+	 * This method must be provided by the vm vendor, as it is used by other
+	 * provided class implementations. For example,
+	 * java.io.ObjectInputStream.readObject() and
+	 * java.io.ObjectInputStream.resolveProxyClass(). It is also useful for
+	 * other classes, such as java.rmi.server.RMIClassLoader. Walk the stack and
+	 * answer the most recent non-null and non-bootstrap ClassLoader on the
+	 * stack of the calling thread. If no such ClassLoader is found, null is
+	 * returned. Notes: 1) This method operates on the defining classes of
+	 * methods on stack. NOT the classes of receivers.
+	 * 
+	 * @return the first non-bootstrap ClassLoader on the stack
+	 */
+	static public final ClassLoader getNonBootstrapClassLoader() {
+		return null;
+	};
+
+	/**
+	 * Initialize the classloader.
+	 * 
+	 * @param loader
+	 *            ClassLoader the ClassLoader instance
+	 * @param bootLoader
+	 *            boolean true for the bootstrap class loader
+	 */
+	public final static void initializeClassLoader(ClassLoader loader,
+			boolean bootLoader) {
+		return;
+	};
+
+	/**
+	 * Native used to find and load a class using the VM
+	 * 
+	 * @return java.lang.Class the class or null.
+	 * @param className
+	 *            String the name of the class to search for.
+	 * @param classLoader
+	 *            the classloader to do the work
+	 */
+	static Class findClassOrNull(String className, ClassLoader classLoader) {
+		return null;
+	};
+
+	/**
+	 * This method must be included, as it is used by
+	 * ResourceBundle.getBundle(), and other places as well. The reference
+	 * implementation of this method uses the getStackClassLoader() method.
+	 * Returns the ClassLoader of the method that called the caller. i.e. A.x()
+	 * calls B.y() calls callerClassLoader(), A's ClassLoader will be returned.
+	 * Returns null for the bootstrap ClassLoader.
+	 * 
+	 * @return a ClassLoader or null for the bootstrap ClassLoader
+	 * @throws SecurityException
+	 *             when called from a non-bootstrap Class
+	 */
+	public static ClassLoader callerClassLoader() {
+		return null;
+	}
+
+	/**
+	 * Native used to dump a string to the system console for debugging.
+	 * 
+	 * @param str
+	 *            String the String to display
+	 */
+	public static void dumpString(String str) {
+		return;
+	};
+
+	/**
+	 * Get the classpath entry that was used to load the class that is the arg.
+	 * <p>
+	 * This method is for internal use only.
+	 * 
+	 * @param targetClass
+	 *            Class the class to set the classpath of.
+	 * @see java.lang.Class
+	 */
+	static int getCPIndexImpl(Class targetClass) {
+		return 0;
+	};
+
+	/**
+	 * Does internal initializaion required by VM.
+	 * 
+	 */
+	static void initializeVM() {
+	}
+
+	/**
+	 * Registers a new virtual-machine shutdown hook. This is equivalent to the
+	 * 1.3 API of the same name.
+	 * 
+	 * @param hook
+	 *            the hook (a Thread) to register
+	 */
+	public static void addShutdownHook(Thread hook) {
+		return;
+	}
+
+	/**
+	 * De-registers a previously-registered virtual-machine shutdown hook. This
+	 * is equivalent to the 1.3 API of the same name.
+	 * 
+	 * @param hook
+	 *            the hook (a Thread) to de-register
+	 * @return true if the hook could be de-registered
+	 */
+	public static boolean removeShutdownHook(Thread hook) {
+		return false;
+	}
+
+	/**
+	 * This method must be provided by the vm vendor. Called to signal that the
+	 * com.ibm.oti.net.www.protocol.jar.JarURLConnection class has been loaded
+	 * and JarURLConnection.closeCachedFiles() should be called on VM shutdown.
+	 * 
+	 * @see #shutdown()
+	 */
+	public static void closeJars() {
+		return;
+	}
+
+	/**
+	 * This method must be provided by the vm vendor. Called to signal that the
+	 * com.ibm.oti.util.DeleteOnExit class has been loaded and
+	 * DeleteOnExit.deleteOnExit() should be called on VM shutdown.
+	 * 
+	 * @see #shutdown()
+	 */
+	public static void deleteOnExit() {
+		return;
+	}
+
+	static final int CPE_TYPE_UNKNOWN = 0;
+
+	static final int CPE_TYPE_DIRECTORY = 1;
+
+	static final int CPE_TYPE_JAR = 2;
+
+	static final int CPE_TYPE_TCP = 3;
+
+	static final int CPE_TYPE_UNUSABLE = 5;
+
+	/**
+	 * Return the type of the specified entry on the class path for a ClassLoader.
+	 * Valid tyes are:
+	 * 		CPE_TYPE_UNKNOWN
+	 *		CPE_TYPE_DIRECTORY
+	 * 		CPE_TYPE_JAR
+	 *		CPE_TYPE_TCP - this is obsolete
+	 *		CPE_TYPE_UNUSABLE
+	 * 
+	 * @param classLoader the ClassLoader
+	 * @param cpIndex the index on the class path
+	 * 
+	 * @return a int which specifies the class path entry type
+	 */
+	static final int getClassPathEntryType(Object classLoader, int cpIndex) {
+		return 0;
+	};
+
+	/**
+	 * Returns command line arguments passed to the VM. Internally these are
+	 * broken into optionString and extraInfo. This only returns the
+	 * optionString part.
+	 * <p>
+	 * 
+	 * @return a String array containing the optionString part of command line
+	 *         arguments
+	 */
+	public static String[] getVMArgs() {
+		return null;
+	};
+
+	/**
+	 * Return the number of entries on the bootclasspath.
+	 * 
+	 * @return an int which is the number of entries on the bootclasspath
+	 */
+	static int getClassPathCount() {
+		return 0;
+	};
+
+	/**
+	 * Return the specified bootclasspath entry.
+	 * 
+	 * @param index the index of the bootclasspath entry 
+	 * 
+	 * @return a byte array containing the bootclasspath entry
+	 * 			specified in the vm options
+	 */
+	static byte[] getPathFromClassPath(int index) {
+		return null;
+	};
+
+}



Mime
View raw message