harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r350181 [125/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....
Date Thu, 01 Dec 2005 06:04:00 GMT
Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteCharArrayBuffer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteCharArrayBuffer.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteCharArrayBuffer.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteCharArrayBuffer.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,110 @@
+/* Copyright 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 com.ibm.io.nio;
+
+
+import java.nio.BufferOverflowException;
+import java.nio.CharBuffer;
+
+/**
+ * CharArrayBuffer, ReadWriteCharArrayBuffer and ReadOnlyCharArrayBuffer compose
+ * the implementation of array based char buffers.
+ * <p>
+ * ReadWriteCharArrayBuffer extends CharArrayBuffer with all the write methods.
+ * </p>
+ * <p>
+ * This class is marked final for runtime performance.
+ * </p>
+ * 
+ */
+final class ReadWriteCharArrayBuffer extends CharArrayBuffer {
+
+	static ReadWriteCharArrayBuffer copy(CharArrayBuffer other, int markOfOther) {
+		ReadWriteCharArrayBuffer buf = new ReadWriteCharArrayBuffer(other
+				.capacity(), other.backingArray, other.offset);
+		buf.limit = other.limit();
+		buf.position = other.position();
+		buf.mark = markOfOther;
+		return buf;
+	}
+
+	ReadWriteCharArrayBuffer(char[] array) {
+		super(array);
+	}
+
+	ReadWriteCharArrayBuffer(int capacity) {
+		super(capacity);
+	}
+
+	ReadWriteCharArrayBuffer(int capacity, char[] backingArray, int arrayOffset) {
+		super(capacity, backingArray, arrayOffset);
+	}
+
+	public CharBuffer asReadOnlyBuffer() {
+		return ReadOnlyCharArrayBuffer.copy(this, mark);
+	}
+
+	public CharBuffer compact() {
+		System.arraycopy(backingArray, position + offset, backingArray, offset,
+				remaining());
+		position = limit - position;
+		limit = capacity;
+		mark = UNSET_MARK;
+		return this;
+	}
+
+	public CharBuffer duplicate() {
+		return copy(this, mark);
+	}
+
+	public boolean isReadOnly() {
+		return false;
+	}
+
+	protected char[] protectedArray() {
+		return backingArray;
+	}
+
+	protected int protectedArrayOffset() {
+		return offset;
+	}
+
+	protected boolean protectedHasArray() {
+		return true;
+	}
+
+	public CharBuffer put(char c) {
+		if (position == limit) {
+			throw new BufferOverflowException();
+		}
+		backingArray[offset + position++] = c;
+		return this;
+	}
+
+	public CharBuffer put(int index, char c) {
+		if (index < 0 || index >= limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		backingArray[offset + index] = c;
+		return this;
+	}
+
+	public CharBuffer slice() {
+		return new ReadWriteCharArrayBuffer(remaining(), backingArray, offset
+				+ position);
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteDirectByteBuffer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteDirectByteBuffer.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteDirectByteBuffer.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteDirectByteBuffer.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,205 @@
+/* Copyright 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 com.ibm.io.nio;
+
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import com.ibm.platform.struct.PlatformAddress;
+
+/**
+ * DirectByteBuffer, ReadWriteDirectByteBuffer and ReadOnlyDirectByteBuffer
+ * compose the implementation of platform memory based byte buffers.
+ * <p>
+ * ReadWriteDirectByteBuffer extends DirectByteBuffer with all the write
+ * methods.
+ * </p>
+ * <p>
+ * This class is marked final for runtime performance.
+ * </p>
+ * 
+ */
+final class ReadWriteDirectByteBuffer extends DirectByteBuffer {
+
+	static ReadWriteDirectByteBuffer copy(DirectByteBuffer other,
+			int markOfOther) {
+		ReadWriteDirectByteBuffer buf = new ReadWriteDirectByteBuffer(
+				other.safeAddress, other.capacity(), other.offset);
+		buf.limit = other.limit();
+		buf.position = other.position();
+		buf.mark = markOfOther;
+		buf.order(other.order());
+		return buf;
+	}
+
+	ReadWriteDirectByteBuffer(int capacity) {
+		super(capacity);
+	}
+
+	ReadWriteDirectByteBuffer(SafeAddress address, int capacity, int offset) {
+		super(address, capacity, offset);
+	}
+
+	public ByteBuffer asReadOnlyBuffer() {
+		return ReadOnlyDirectByteBuffer.copy(this, mark);
+	}
+
+	public ByteBuffer compact() {
+		PlatformAddress effectiveAddress = getEffectiveAddress();
+		effectiveAddress.offsetBytes(position).moveTo(effectiveAddress,
+				remaining());
+		position = limit - position;
+		limit = capacity;
+		mark = UNSET_MARK;
+		return this;
+	}
+
+	public ByteBuffer duplicate() {
+		return copy(this, mark);
+	}
+
+	public boolean isReadOnly() {
+		return false;
+	}
+
+	protected byte[] protectedArray() {
+		throw new UnsupportedOperationException();
+	}
+
+	protected int protectedArrayOffset() {
+		throw new UnsupportedOperationException();
+	}
+
+	protected boolean protectedHasArray() {
+		return false;
+	}
+
+	public ByteBuffer put(byte value) {
+		if (position == limit) {
+			throw new BufferOverflowException();
+		}
+		getBaseAddress().setByte(offset + position++, value);
+		return this;
+	}
+
+	public ByteBuffer put(int index, byte value) {
+		if (index < 0 || index >= limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		getBaseAddress().setByte(offset + index, value);
+		return this;
+
+	}
+
+	public ByteBuffer putDouble(double value) {
+		int newPosition = position + 8;
+		if (newPosition > limit) {
+			throw new BufferOverflowException();
+		}
+		getBaseAddress().setDouble(offset + position, value, order);
+		position = newPosition;
+		return this;
+	}
+
+	public ByteBuffer putDouble(int index, double value) {
+		if (index < 0 || index + 8 > limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		getBaseAddress().setDouble(offset + index, value, order);
+		return this;
+	}
+
+	public ByteBuffer putFloat(float value) {
+		int newPosition = position + 4;
+		if (newPosition > limit) {
+			throw new BufferOverflowException();
+		}
+		getBaseAddress().setFloat(offset + position, value, order);
+		position = newPosition;
+		return this;
+	}
+
+	public ByteBuffer putFloat(int index, float value) {
+		if (index < 0 || index + 4 > limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		getBaseAddress().setFloat(offset + index, value, order);
+		return this;
+	}
+
+	public ByteBuffer putInt(int value) {
+		int newPosition = position + 4;
+		if (newPosition > limit) {
+			throw new BufferOverflowException();
+		}
+		getBaseAddress().setInt(offset + position, value, order);
+		position = newPosition;
+		return this;
+	}
+
+	public ByteBuffer putInt(int index, int value) {
+		if (index < 0 || index + 4 > limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		getBaseAddress().setInt(offset + index, value, order);
+		return this;
+	}
+
+	public ByteBuffer putLong(long value) {
+		int newPosition = position + 8;
+		if (newPosition > limit) {
+			throw new BufferOverflowException();
+		}
+		getBaseAddress().setLong(offset + position, value, order);
+		position = newPosition;
+		return this;
+	}
+
+	public ByteBuffer putLong(int index, long value) {
+		if (index < 0 || index + 8 > limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		getBaseAddress().setLong(offset + index, value, order);
+		return this;
+	}
+
+	public ByteBuffer putShort(short value) {
+		int newPosition = position + 2;
+		if (newPosition > limit) {
+			throw new BufferOverflowException();
+		}
+		getBaseAddress().setShort(offset + position, value, order);
+		position = newPosition;
+		return this;
+	}
+
+	public ByteBuffer putShort(int index, short value) {
+		if (index < 0 || index + 2 > limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		getBaseAddress().setShort(offset + index, value, order);
+		return this;
+	}
+
+	public ByteBuffer slice() {
+		ReadWriteDirectByteBuffer buf = new ReadWriteDirectByteBuffer(
+				safeAddress, remaining(), offset + position);
+		buf.order = order;
+		return buf;
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteDoubleArrayBuffer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteDoubleArrayBuffer.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteDoubleArrayBuffer.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteDoubleArrayBuffer.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,113 @@
+/* Copyright 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 com.ibm.io.nio;
+
+
+import java.nio.BufferOverflowException;
+import java.nio.DoubleBuffer;
+
+/**
+ * DoubleArrayBuffer, ReadWriteDoubleArrayBuffer and ReadOnlyDoubleArrayBuffer
+ * compose the implementation of array based double buffers.
+ * <p>
+ * ReadWriteDoubleArrayBuffer extends DoubleArrayBuffer with all the write
+ * methods.
+ * </p>
+ * <p>
+ * This class is marked final for runtime performance.
+ * </p>
+ * 
+ */
+final class ReadWriteDoubleArrayBuffer extends DoubleArrayBuffer {
+
+	static ReadWriteDoubleArrayBuffer copy(DoubleArrayBuffer other,
+			int markOfOther) {
+		ReadWriteDoubleArrayBuffer buf = new ReadWriteDoubleArrayBuffer(other
+				.capacity(), other.backingArray, other.offset);
+		buf.limit = other.limit();
+		buf.position = other.position();
+		buf.mark = markOfOther;
+		return buf;
+	}
+
+	ReadWriteDoubleArrayBuffer(double[] array) {
+		super(array);
+	}
+
+	ReadWriteDoubleArrayBuffer(int capacity) {
+		super(capacity);
+	}
+
+	ReadWriteDoubleArrayBuffer(int capacity, double[] backingArray,
+			int arrayOffset) {
+		super(capacity, backingArray, arrayOffset);
+	}
+
+	public DoubleBuffer asReadOnlyBuffer() {
+		return ReadOnlyDoubleArrayBuffer.copy(this, mark);
+	}
+
+	public DoubleBuffer compact() {
+		System.arraycopy(backingArray, position + offset, backingArray, offset,
+				remaining());
+		position = limit - position;
+		limit = capacity;
+		mark = UNSET_MARK;
+		return this;
+	}
+
+	public DoubleBuffer duplicate() {
+		return copy(this, mark);
+	}
+
+	public boolean isReadOnly() {
+		return false;
+	}
+
+	protected double[] protectedArray() {
+		return backingArray;
+	}
+
+	protected int protectedArrayOffset() {
+		return offset;
+	}
+
+	protected boolean protectedHasArray() {
+		return true;
+	}
+
+	public DoubleBuffer put(double c) {
+		if (position == limit) {
+			throw new BufferOverflowException();
+		}
+		backingArray[offset + position++] = c;
+		return this;
+	}
+
+	public DoubleBuffer put(int index, double c) {
+		if (index < 0 || index >= limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		backingArray[offset + index] = c;
+		return this;
+	}
+
+	public DoubleBuffer slice() {
+		return new ReadWriteDoubleArrayBuffer(remaining(), backingArray, offset
+				+ position);
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteFloatArrayBuffer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteFloatArrayBuffer.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteFloatArrayBuffer.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteFloatArrayBuffer.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,113 @@
+/* Copyright 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 com.ibm.io.nio;
+
+
+import java.nio.BufferOverflowException;
+import java.nio.FloatBuffer;
+
+/**
+ * FloatArrayBuffer, ReadWriteFloatArrayBuffer and ReadOnlyFloatArrayBuffer
+ * compose the implementation of array based float buffers.
+ * <p>
+ * ReadWriteFloatArrayBuffer extends FloatArrayBuffer with all the write
+ * methods.
+ * </p>
+ * <p>
+ * This class is marked final for runtime performance.
+ * </p>
+ * 
+ */
+final class ReadWriteFloatArrayBuffer extends FloatArrayBuffer {
+
+	static ReadWriteFloatArrayBuffer copy(FloatArrayBuffer other,
+			int markOfOther) {
+		ReadWriteFloatArrayBuffer buf = new ReadWriteFloatArrayBuffer(other
+				.capacity(), other.backingArray, other.offset);
+		buf.limit = other.limit();
+		buf.position = other.position();
+		buf.mark = markOfOther;
+		return buf;
+	}
+
+	ReadWriteFloatArrayBuffer(float[] array) {
+		super(array);
+	}
+
+	ReadWriteFloatArrayBuffer(int capacity) {
+		super(capacity);
+	}
+
+	ReadWriteFloatArrayBuffer(int capacity, float[] backingArray,
+			int arrayOffset) {
+		super(capacity, backingArray, arrayOffset);
+	}
+
+	public FloatBuffer asReadOnlyBuffer() {
+		return ReadOnlyFloatArrayBuffer.copy(this, mark);
+	}
+
+	public FloatBuffer compact() {
+		System.arraycopy(backingArray, position + offset, backingArray, offset,
+				remaining());
+		position = limit - position;
+		limit = capacity;
+		mark = UNSET_MARK;
+		return this;
+	}
+
+	public FloatBuffer duplicate() {
+		return copy(this, mark);
+	}
+
+	public boolean isReadOnly() {
+		return false;
+	}
+
+	protected float[] protectedArray() {
+		return backingArray;
+	}
+
+	protected int protectedArrayOffset() {
+		return offset;
+	}
+
+	protected boolean protectedHasArray() {
+		return true;
+	}
+
+	public FloatBuffer put(float c) {
+		if (position == limit) {
+			throw new BufferOverflowException();
+		}
+		backingArray[offset + position++] = c;
+		return this;
+	}
+
+	public FloatBuffer put(int index, float c) {
+		if (index < 0 || index >= limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		backingArray[offset + index] = c;
+		return this;
+	}
+
+	public FloatBuffer slice() {
+		return new ReadWriteFloatArrayBuffer(remaining(), backingArray, offset
+				+ position);
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteHeapByteBuffer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteHeapByteBuffer.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteHeapByteBuffer.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteHeapByteBuffer.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,182 @@
+/* Copyright 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 com.ibm.io.nio;
+
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+/**
+ * HeapByteBuffer, ReadWriteHeapByteBuffer and ReadOnlyHeapByteBuffer compose
+ * the implementation of array based byte buffers.
+ * <p>
+ * ReadWriteHeapByteBuffer extends HeapByteBuffer with all the write methods.
+ * </p>
+ * <p>
+ * This class is marked final for runtime performance.
+ * </p>
+ * 
+ */
+final class ReadWriteHeapByteBuffer extends HeapByteBuffer {
+
+	static ReadWriteHeapByteBuffer copy(HeapByteBuffer other, int markOfOther) {
+		ReadWriteHeapByteBuffer buf = new ReadWriteHeapByteBuffer(
+				other.backingArray, other.capacity(), other.offset);
+		buf.limit = other.limit();
+		buf.position = other.position();
+		buf.mark = markOfOther;
+		buf.order(other.order());
+		return buf;
+	}
+
+	ReadWriteHeapByteBuffer(byte[] backingArray) {
+		super(backingArray);
+	}
+
+	ReadWriteHeapByteBuffer(int capacity) {
+		super(capacity);
+	}
+
+	ReadWriteHeapByteBuffer(byte[] backingArray, int capacity, int arrayOffset) {
+		super(backingArray, capacity, arrayOffset);
+	}
+
+	public ByteBuffer asReadOnlyBuffer() {
+		return ReadOnlyHeapByteBuffer.copy(this, mark);
+	}
+
+	public ByteBuffer compact() {
+		System.arraycopy(backingArray, position + offset, backingArray, offset,
+				remaining());
+		position = limit - position;
+		limit = capacity;
+		mark = UNSET_MARK;
+		return this;
+	}
+
+	public ByteBuffer duplicate() {
+		return copy(this, mark);
+	}
+
+	public boolean isReadOnly() {
+		return false;
+	}
+
+	protected byte[] protectedArray() {
+		return backingArray;
+	}
+
+	protected int protectedArrayOffset() {
+		return offset;
+	}
+
+	protected boolean protectedHasArray() {
+		return true;
+	}
+
+	public ByteBuffer put(byte b) {
+		if (position == limit) {
+			throw new BufferOverflowException();
+		}
+		backingArray[offset + position++] = b;
+		return this;
+	}
+
+	public ByteBuffer put(int index, byte b) {
+		if (index < 0 || index >= limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		backingArray[offset + index] = b;
+		return this;
+	}
+
+	public ByteBuffer putDouble(double value) {
+		return putLong(Double.doubleToRawLongBits(value));
+	}
+
+	public ByteBuffer putDouble(int index, double value) {
+		return putLong(index, Double.doubleToRawLongBits(value));
+	}
+
+	public ByteBuffer putFloat(float value) {
+		return putInt(Float.floatToIntBits(value));
+	}
+
+	public ByteBuffer putFloat(int index, float value) {
+		return putInt(index, Float.floatToIntBits(value));
+	}
+
+	public ByteBuffer putInt(int value) {
+		int newPosition = position + 4;
+		if (newPosition > limit) {
+			throw new BufferOverflowException();
+		}
+		store(position, value);
+		position = newPosition;
+		return this;
+	}
+
+	public ByteBuffer putInt(int index, int value) {
+		if (index < 0 || index + 4 > limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		store(index, value);
+		return this;
+	}
+
+	public ByteBuffer putLong(int index, long value) {
+		if (index < 0 || index + 8 > limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		store(index, value);
+		return this;
+	}
+
+	public ByteBuffer putLong(long value) {
+		int newPosition = position + 8;
+		if (newPosition > limit) {
+			throw new BufferOverflowException();
+		}
+		store(position, value);
+		position = newPosition;
+		return this;
+	}
+
+	public ByteBuffer putShort(int index, short value) {
+		if (index < 0 || index + 2 > limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		store(index, value);
+		return this;
+	}
+
+	public ByteBuffer putShort(short value) {
+		int newPosition = position + 2;
+		if (newPosition > limit) {
+			throw new BufferOverflowException();
+		}
+		store(position, value);
+		position = newPosition;
+		return this;
+	}
+
+	public ByteBuffer slice() {
+		ReadWriteHeapByteBuffer slice = new ReadWriteHeapByteBuffer(
+				backingArray, remaining(), offset + position);
+		slice.order = order;
+		return slice;
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteIntArrayBuffer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteIntArrayBuffer.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteIntArrayBuffer.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteIntArrayBuffer.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,110 @@
+/* Copyright 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 com.ibm.io.nio;
+
+
+import java.nio.BufferOverflowException;
+import java.nio.IntBuffer;
+
+/**
+ * IntArrayBuffer, ReadWriteIntArrayBuffer and ReadOnlyIntArrayBuffer compose
+ * the implementation of array based int buffers.
+ * <p>
+ * ReadWriteIntArrayBuffer extends IntArrayBuffer with all the write methods.
+ * </p>
+ * <p>
+ * This class is marked final for runtime performance.
+ * </p>
+ * 
+ */
+final class ReadWriteIntArrayBuffer extends IntArrayBuffer {
+
+	static ReadWriteIntArrayBuffer copy(IntArrayBuffer other, int markOfOther) {
+		ReadWriteIntArrayBuffer buf = new ReadWriteIntArrayBuffer(other
+				.capacity(), other.backingArray, other.offset);
+		buf.limit = other.limit();
+		buf.position = other.position();
+		buf.mark = markOfOther;
+		return buf;
+	}
+
+	ReadWriteIntArrayBuffer(int[] array) {
+		super(array);
+	}
+
+	ReadWriteIntArrayBuffer(int capacity) {
+		super(capacity);
+	}
+
+	ReadWriteIntArrayBuffer(int capacity, int[] backingArray, int arrayOffset) {
+		super(capacity, backingArray, arrayOffset);
+	}
+
+	public IntBuffer asReadOnlyBuffer() {
+		return ReadOnlyIntArrayBuffer.copy(this, mark);
+	}
+
+	public IntBuffer compact() {
+		System.arraycopy(backingArray, position + offset, backingArray, offset,
+				remaining());
+		position = limit - position;
+		limit = capacity;
+		mark = UNSET_MARK;
+		return this;
+	}
+
+	public IntBuffer duplicate() {
+		return copy(this, mark);
+	}
+
+	public boolean isReadOnly() {
+		return false;
+	}
+
+	protected int[] protectedArray() {
+		return backingArray;
+	}
+
+	protected int protectedArrayOffset() {
+		return offset;
+	}
+
+	protected boolean protectedHasArray() {
+		return true;
+	}
+
+	public IntBuffer put(int c) {
+		if (position == limit) {
+			throw new BufferOverflowException();
+		}
+		backingArray[offset + position++] = c;
+		return this;
+	}
+
+	public IntBuffer put(int index, int c) {
+		if (index < 0 || index >= limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		backingArray[offset + index] = c;
+		return this;
+	}
+
+	public IntBuffer slice() {
+		return new ReadWriteIntArrayBuffer(remaining(), backingArray, offset
+				+ position);
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteLongArrayBuffer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteLongArrayBuffer.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteLongArrayBuffer.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteLongArrayBuffer.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,110 @@
+/* Copyright 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 com.ibm.io.nio;
+
+
+import java.nio.BufferOverflowException;
+import java.nio.LongBuffer;
+
+/**
+ * LongArrayBuffer, ReadWriteLongArrayBuffer and ReadOnlyLongArrayBuffer compose
+ * the implementation of array based long buffers.
+ * <p>
+ * ReadWriteLongArrayBuffer extends LongArrayBuffer with all the write methods.
+ * </p>
+ * <p>
+ * This class is marked final for runtime performance.
+ * </p>
+ * 
+ */
+final class ReadWriteLongArrayBuffer extends LongArrayBuffer {
+
+	static ReadWriteLongArrayBuffer copy(LongArrayBuffer other, int markOfOther) {
+		ReadWriteLongArrayBuffer buf = new ReadWriteLongArrayBuffer(other
+				.capacity(), other.backingArray, other.offset);
+		buf.limit = other.limit();
+		buf.position = other.position();
+		buf.mark = markOfOther;
+		return buf;
+	}
+
+	ReadWriteLongArrayBuffer(long[] array) {
+		super(array);
+	}
+
+	ReadWriteLongArrayBuffer(int capacity) {
+		super(capacity);
+	}
+
+	ReadWriteLongArrayBuffer(int capacity, long[] backingArray, int arrayOffset) {
+		super(capacity, backingArray, arrayOffset);
+	}
+
+	public LongBuffer asReadOnlyBuffer() {
+		return ReadOnlyLongArrayBuffer.copy(this, mark);
+	}
+
+	public LongBuffer compact() {
+		System.arraycopy(backingArray, position + offset, backingArray, offset,
+				remaining());
+		position = limit - position;
+		limit = capacity;
+		mark = UNSET_MARK;
+		return this;
+	}
+
+	public LongBuffer duplicate() {
+		return copy(this, mark);
+	}
+
+	public boolean isReadOnly() {
+		return false;
+	}
+
+	protected long[] protectedArray() {
+		return backingArray;
+	}
+
+	protected int protectedArrayOffset() {
+		return offset;
+	}
+
+	protected boolean protectedHasArray() {
+		return true;
+	}
+
+	public LongBuffer put(long c) {
+		if (position == limit) {
+			throw new BufferOverflowException();
+		}
+		backingArray[offset + position++] = c;
+		return this;
+	}
+
+	public LongBuffer put(int index, long c) {
+		if (index < 0 || index >= limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		backingArray[offset + index] = c;
+		return this;
+	}
+
+	public LongBuffer slice() {
+		return new ReadWriteLongArrayBuffer(remaining(), backingArray, offset
+				+ position);
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteShortArrayBuffer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteShortArrayBuffer.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteShortArrayBuffer.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ReadWriteShortArrayBuffer.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,113 @@
+/* Copyright 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 com.ibm.io.nio;
+
+
+import java.nio.BufferOverflowException;
+import java.nio.ShortBuffer;
+
+/**
+ * ShortArrayBuffer, ReadWriteShortArrayBuffer and ReadOnlyShortArrayBuffer
+ * compose the implementation of array based short buffers.
+ * <p>
+ * ReadWriteShortArrayBuffer extends ShortArrayBuffer with all the write
+ * methods.
+ * </p>
+ * <p>
+ * This class is marked final for runtime performance.
+ * </p>
+ * 
+ */
+final class ReadWriteShortArrayBuffer extends ShortArrayBuffer {
+
+	static ReadWriteShortArrayBuffer copy(ShortArrayBuffer other,
+			int markOfOther) {
+		ReadWriteShortArrayBuffer buf = new ReadWriteShortArrayBuffer(other
+				.capacity(), other.backingArray, other.offset);
+		buf.limit = other.limit();
+		buf.position = other.position();
+		buf.mark = markOfOther;
+		return buf;
+	}
+
+	ReadWriteShortArrayBuffer(short[] array) {
+		super(array);
+	}
+
+	ReadWriteShortArrayBuffer(int capacity) {
+		super(capacity);
+	}
+
+	ReadWriteShortArrayBuffer(int capacity, short[] backingArray,
+			int arrayOffset) {
+		super(capacity, backingArray, arrayOffset);
+	}
+
+	public ShortBuffer asReadOnlyBuffer() {
+		return ReadOnlyShortArrayBuffer.copy(this, mark);
+	}
+
+	public ShortBuffer compact() {
+		System.arraycopy(backingArray, position + offset, backingArray, offset,
+				remaining());
+		position = limit - position;
+		limit = capacity;
+		mark = UNSET_MARK;
+		return this;
+	}
+
+	public ShortBuffer duplicate() {
+		return copy(this, mark);
+	}
+
+	public boolean isReadOnly() {
+		return false;
+	}
+
+	protected short[] protectedArray() {
+		return backingArray;
+	}
+
+	protected int protectedArrayOffset() {
+		return offset;
+	}
+
+	protected boolean protectedHasArray() {
+		return true;
+	}
+
+	public ShortBuffer put(short c) {
+		if (position == limit) {
+			throw new BufferOverflowException();
+		}
+		backingArray[offset + position++] = c;
+		return this;
+	}
+
+	public ShortBuffer put(int index, short c) {
+		if (index < 0 || index >= limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		backingArray[offset + index] = c;
+		return this;
+	}
+
+	public ShortBuffer slice() {
+		return new ReadWriteShortArrayBuffer(remaining(), backingArray, offset
+				+ position);
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ShortArrayBuffer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ShortArrayBuffer.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ShortArrayBuffer.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ShortArrayBuffer.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,77 @@
+/* Copyright 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 com.ibm.io.nio;
+
+
+import java.nio.BufferUnderflowException;
+import java.nio.ByteOrder;
+import java.nio.ShortBuffer;
+
+/**
+ * ShortArrayBuffer, ReadWriteShortArrayBuffer and ReadOnlyShortArrayBuffer
+ * compose the implementation of array based short buffers.
+ * <p>
+ * ShortArrayBuffer implements all the shared readonly methods and is extended
+ * by the other two classes.
+ * </p>
+ * <p>
+ * All methods are marked final for runtime performance.
+ * </p>
+ * 
+ */
+abstract class ShortArrayBuffer extends ShortBuffer {
+
+	protected final short[] backingArray;
+
+	protected final int offset;
+
+	ShortArrayBuffer(short[] array) {
+		this(array.length, array, 0);
+	}
+
+	ShortArrayBuffer(int capacity) {
+		this(capacity, new short[capacity], 0);
+	}
+
+	ShortArrayBuffer(int capacity, short[] backingArray, int offset) {
+		super(capacity);
+		this.backingArray = backingArray;
+		this.offset = offset;
+	}
+
+	public final short get() {
+		if (position == limit) {
+			throw new BufferUnderflowException();
+		}
+		return backingArray[offset + position++];
+	}
+
+	public final short get(int index) {
+		if (index < 0 || index >= limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		return backingArray[offset + index];
+	}
+
+	public final boolean isDirect() {
+		return false;
+	}
+
+	public final ByteOrder order() {
+		return ByteOrder.nativeOrder();
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ShortToByteBufferAdapter.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ShortToByteBufferAdapter.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ShortToByteBufferAdapter.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/io/nio/ShortToByteBufferAdapter.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,147 @@
+/* Copyright 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 com.ibm.io.nio;
+
+
+import java.nio.BufferOverflowException;
+import java.nio.BufferUnderflowException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.ReadOnlyBufferException;
+import java.nio.ShortBuffer;
+
+/**
+ * This class wraps a byte buffer to be a short buffer.
+ * <p>
+ * Implementation notice:
+ * <ul>
+ * <li>After a byte buffer instance is wrapped, it becomes privately owned by
+ * the adapter. It must NOT be accessed outside the adapter any more.</li>
+ * <li>The byte buffer's position and limit are NOT linked with the adapter.
+ * The adapter extends Buffer, thus has its own position and limit.</li>
+ * </ul>
+ * </p>
+ * 
+ */
+final class ShortToByteBufferAdapter extends ShortBuffer {
+
+	static ShortBuffer wrap(ByteBuffer byteBuffer) {
+		return new ShortToByteBufferAdapter(byteBuffer.slice());
+	}
+
+	private final ByteBuffer byteBuffer;
+
+	ShortToByteBufferAdapter(ByteBuffer byteBuffer) {
+		super((byteBuffer.capacity() >> 1));
+		this.byteBuffer = byteBuffer;
+		this.byteBuffer.clear();
+	}
+
+	public ShortBuffer asReadOnlyBuffer() {
+		ShortToByteBufferAdapter buf = new ShortToByteBufferAdapter(byteBuffer
+				.asReadOnlyBuffer());
+		buf.limit = limit;
+		buf.position = position;
+		buf.mark = mark;
+		return buf;
+	}
+
+	public ShortBuffer compact() {
+		if (byteBuffer.isReadOnly()) {
+			throw new ReadOnlyBufferException();
+		}
+		byteBuffer.limit(limit << 1);
+		byteBuffer.position(position << 1);
+		byteBuffer.compact();
+		byteBuffer.clear();
+		position = limit - position;
+		limit = capacity;
+		mark = UNSET_MARK;
+		return this;
+	}
+
+	public ShortBuffer duplicate() {
+		ShortToByteBufferAdapter buf = new ShortToByteBufferAdapter(byteBuffer
+				.duplicate());
+		buf.limit = limit;
+		buf.position = position;
+		buf.mark = mark;
+		return buf;
+	}
+
+	public short get() {
+		if (position == limit) {
+			throw new BufferUnderflowException();
+		}
+		return byteBuffer.getShort(position++ << 1);
+	}
+
+	public short get(int index) {
+		if (index < 0 || index >= limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		return byteBuffer.getShort(index << 1);
+	}
+
+	public boolean isDirect() {
+		return byteBuffer.isDirect();
+	}
+
+	public boolean isReadOnly() {
+		return byteBuffer.isReadOnly();
+	}
+
+	public ByteOrder order() {
+		return byteBuffer.order();
+	}
+
+	protected short[] protectedArray() {
+		throw new UnsupportedOperationException();
+	}
+
+	protected int protectedArrayOffset() {
+		throw new UnsupportedOperationException();
+	}
+
+	protected boolean protectedHasArray() {
+		return false;
+	}
+
+	public ShortBuffer put(short c) {
+		if (position == limit) {
+			throw new BufferOverflowException();
+		}
+		byteBuffer.putShort(position++ << 1, c);
+		return this;
+	}
+
+	public ShortBuffer put(int index, short c) {
+		if (index < 0 || index >= limit) {
+			throw new IndexOutOfBoundsException();
+		}
+		byteBuffer.putShort(index << 1, c);
+		return this;
+	}
+
+	public ShortBuffer slice() {
+		byteBuffer.limit(limit << 1);
+		byteBuffer.position(position << 1);
+		ShortBuffer result = new ShortToByteBufferAdapter(byteBuffer.slice());
+		byteBuffer.clear();
+		return result;
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/AdapterManager.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/AdapterManager.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/AdapterManager.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/AdapterManager.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,78 @@
+/* Copyright 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 com.ibm.platform;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Adapter Manager
+ *  
+ */
+public final class AdapterManager implements IAdapterManager {
+
+	/*
+	 * key is adaptable type, and value is list of adapter factories for that
+	 * type.
+	 */
+	private final HashMap factories = new HashMap();
+
+	public Object getAdapter(IAdaptable adaptable, Class adapterType) {
+		List factoryList = (List) factories.get(adaptable);
+		if (factoryList != null) {
+			for (Iterator factoryItr = factoryList.iterator(); factoryItr
+					.hasNext();) {
+				IAdapterFactory factory = (IAdapterFactory) factoryItr.next();
+				Object adapter = factory.getAdapter(adaptable, adapterType);
+				if (adapter != null) {
+					return adapter;
+				}
+			}
+		}
+		return null;
+	}
+
+	public boolean hasAdapter(IAdaptable adaptable, Class adapterType) {
+		return null == getAdapter(adaptable, adapterType);
+	}
+
+	public void registerAdapters(IAdapterFactory factory, Class adaptable) {
+		List factoryList = (List) factories.get(adaptable);
+		if (factoryList == null) {
+			factoryList = new ArrayList();
+			factories.put(adaptable, factoryList);
+		}
+		factoryList.add(factory);
+	}
+
+	public void unregisterAdapters(IAdapterFactory factory, Class adaptable) {
+		List factoryList = (List) factories.get(adaptable);
+		if (factoryList != null) {
+			factoryList.remove(factory);
+		}
+	}
+
+	public void unregisterAdapters(IAdapterFactory factory) {
+		for (Iterator knownAdaptablesItr = factories.keySet().iterator(); knownAdaptablesItr
+				.hasNext();) {
+			Class adaptable = (Class) knownAdaptablesItr.next();
+			unregisterAdapters(factory, adaptable);
+		}
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/Endianness.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/Endianness.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/Endianness.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/Endianness.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,54 @@
+/* Copyright 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 com.ibm.platform;
+
+
+/**
+ * Endianness
+ * 
+ */
+public final class Endianness {
+	/**
+	 * Private mapping mode (equivalent to copy on write).
+	 */
+	public static final Endianness BIG_ENDIAN = new Endianness("BIG_ENDIAN"); //$NON-NLS-1$
+
+	/**
+	 * Read-only mapping mode.
+	 */
+	public static final Endianness LITTLE_ENDIAN = new Endianness(
+			"LITTLE_ENDIAN"); //$NON-NLS-1$
+
+	// The string used to display the mapping mode.
+	private final String displayName;
+
+	/*
+	 * Private constructor prevents others creating new Endians.
+	 */
+	private Endianness(String displayName) {
+		super();
+		this.displayName = displayName;
+	}
+
+	/**
+	 * Answers a string version of the endianness
+	 * 
+	 * @return the mode string.
+	 */
+	public String toString() {
+		return displayName;
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IAdaptable.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IAdaptable.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IAdaptable.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IAdaptable.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,53 @@
+/* Copyright 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 com.ibm.platform;
+
+
+/**
+ * The interface to extensible objects.
+ * <p>
+ * Classes can implement this interface (a single method) to provide interfaces
+ * that are not API -- each interface type has to be handled in the
+ * implementation of <code>getAdapter(Class)</code>. This is a good way to
+ * extend the class without breaking existing API.
+ * </p>
+ * <p>
+ * In addition, classes can be augmented by interfaces that are defined by other
+ * classes (which requires the <code>getAdapter(Class)</code> to be
+ * implemented by a factory.
+ * 
+ */
+public interface IAdaptable {
+
+	/**
+	 * Answers the adapter corresponding to the given class.
+	 * <p>
+	 * The adapter is typically obtained using the class literal, like this:
+	 * 
+	 * <pre>
+	 *    ...
+	 *    IAdaptable = (IAdaptable) foo;
+	 *    IMyInterface bar = (IMyInterface)foo.getAdapter(IMyInterface.class);
+	 *    bar.doMyThing();
+	 *    ...
+	 * </pre>
+	 * 
+	 * @param adapter
+	 *            the type of adapter requested
+	 * @return the adapter
+	 */
+	public Object getAdapter(Class adapter);
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IAdapterFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IAdapterFactory.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IAdapterFactory.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IAdapterFactory.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,42 @@
+/* Copyright 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 com.ibm.platform;
+
+
+/**
+ * IAdapterFactory
+ * 
+ */
+public interface IAdapterFactory {
+
+	/**
+	 * Answer the adapter of the given type for the given object.
+	 * 
+	 * @param adaptableObject
+	 *            the object that implements IAdaptable.
+	 * @param adapterType
+	 *            the type of adapter to return.
+	 * @return the adapter of the requested type.
+	 */
+	public Object getAdapter(IAdaptable adaptableObject, Class adapterType);
+
+	/**
+	 * Answers the adapters that this factory provides.
+	 * 
+	 * @return the list of adapters as an array of classes.
+	 */
+	public Class[] getAdapterList();
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IAdapterManager.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IAdapterManager.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IAdapterManager.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IAdapterManager.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,33 @@
+/* Copyright 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 com.ibm.platform;
+
+
+/**
+ * IAdapterManager
+ * 
+ */
+public interface IAdapterManager {
+	public Object getAdapter(IAdaptable adaptable, Class adapterType);
+
+	public boolean hasAdapter(IAdaptable adaptable, Class adapterType);
+
+	public void registerAdapters(IAdapterFactory factory, Class adaptable);
+
+	public void unregisterAdapters(IAdapterFactory factory);
+
+	public void unregisterAdapters(IAdapterFactory factory, Class adaptable);
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IFileSystem.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IFileSystem.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IFileSystem.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IFileSystem.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,98 @@
+/* Copyright 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 com.ibm.platform;
+
+
+import java.io.IOException;
+
+import com.ibm.platform.struct.PlatformAddress;
+
+/**
+ * TODO Type description
+ * 
+ */
+public interface IFileSystem extends ISystemComponent {
+
+	public final int SHARED_LOCK_TYPE = 1;
+
+	public final int EXCLUSIVE_LOCK_TYPE = 2;
+
+	public final int SEEK_SET = 1;
+
+	public final int SEEK_CUR = 2;
+
+	public final int SEEK_END = 4;
+
+	public final int MMAP_READ_ONLY = 1;
+
+	public final int MMAP_READ_WRITE = 2;
+
+	public final int MMAP_WRITE_COPY = 4;
+
+	public final int O_RDONLY = 0x00000000;
+
+	public final int O_WRONLY = 0x00000001;
+
+	public final int O_RDWR = 0x00000010;
+
+	public final int O_APPEND = 0x00000100;
+
+	public final int O_CREAT = 0x00001000;
+
+	public final int O_EXCL = 0x00010000;
+
+	public final int O_NOCTTY = 0x00100000;
+
+	public final int O_NONBLOCK = 0x01000000;
+
+	public final int O_TRUNC = 0x10000000;
+
+	public long read(long fileDescriptor, byte[] bytes, int offset, int length)
+			throws IOException;
+
+	public long write(long fileDescriptor, byte[] bytes, int offset, int length)
+			throws IOException;
+
+	public long readv(long fileDescriptor, byte[] bytes, int[] offsets,
+			int[] lengths) throws IOException;
+
+	public long writev(long fileDescriptor, byte[] bytes, int[] offsets,
+			int[] lengths) throws IOException;
+
+	// Required to support direct byte buffers
+	public long readDirect(long fileDescriptor, long address, int length)
+			throws IOException;
+
+	public long writeDirect(long fileDescriptor, long address, int length)
+			throws IOException;
+
+	public boolean lock(long fileDescriptor, long start, long length, int type,
+			boolean waitFlag) throws IOException;
+
+	public void unlock(long fileDescriptor, long start, long length)
+			throws IOException;
+
+	public long seek(long fileDescriptor, long offset, int whence)
+			throws IOException;
+
+	public void fflush(long fileDescriptor, boolean metadata)
+			throws IOException;
+
+	public PlatformAddress mmap(long fileDescriptor, long offset, long size,
+			int mapMode) throws IOException;
+
+	public void close(long fileDescriptor) throws IOException;
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IMemorySystem.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IMemorySystem.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IMemorySystem.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/IMemorySystem.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,395 @@
+/* Copyright 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 com.ibm.platform; 
+
+
+/**
+ * IMemorySystem
+ * 
+ */
+public interface IMemorySystem {
+
+	/**
+	 * Answers true if the platform is little endian, otherwise it may be
+	 * assumed to be big endian..
+	 * 
+	 * @return true if the platform is little endian.
+	 */
+	public boolean isLittleEndian();
+
+	/**
+	 * Answers the platform pointer size.
+	 * 
+	 * @return the native platform pointer size, in bytes.
+	 */
+	public int getPointerSize();
+
+	/**
+	 * Allocates and returns a pointer to space for a memory block of
+	 * <code>length</code> bytes. The space is uninitialized and may be larger
+	 * than the number of bytes requested; however, the guaranteed usable memory
+	 * block is exactly <code>length</code> bytes long.
+	 * 
+	 * @param length
+	 *            number of bytes requested.
+	 * @return the address of the start of the memory block.
+	 * @throws OutOfMemoryError
+	 *             if the request cannot be satisfied.
+	 */
+	public long malloc(long length) throws OutOfMemoryError;
+
+	/**
+	 * Deallocates space for a memory block that was previously allocated by a
+	 * call to {@link #malloc(long) malloc(long)}. The number of bytes freed is
+	 * identical to the number of bytes acquired when the memory block was
+	 * allocated. If <code>address</code> is zero the method does nothing.
+	 * <p>
+	 * Freeing a pointer to a memory block that was not allocated by
+	 * <code>malloc()</code> has unspecified effect.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the address of the memory block to deallocate.
+	 */
+	public void free(long address);
+
+	/**
+	 * Places <code>value</code> into first <code>length</code> bytes of the
+	 * memory block starting at <code>address</code>.
+	 * <p>
+	 * The behavior is unspecified if
+	 * <code>(address ... address + length)</code> is not wholly within the
+	 * range that was previously allocated using <code>malloc()</code>.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the address of the first memory location.
+	 * @param value
+	 *            the byte value to set at each location.
+	 * @param length
+	 *            the number of byte-length locations to set.
+	 */
+	public void memset(long address, byte value, long length);
+
+	/**
+	 * Copies <code>length</code> bytes from <code>srcAddress</code> to
+	 * <code>destAddress</code>. Where any part of the source memory block
+	 * and the destination memory block overlap <code>memmove()</code> ensures
+	 * that the original source bytes in the overlapping region are copied
+	 * before being overwritten.
+	 * <p>
+	 * The behavior is unspecified if
+	 * <code>(srcAddress ... srcAddress + length)</code> and
+	 * <code>(destAddress ... destAddress + length)</code> are not both wholly
+	 * within the range that was previously allocated using
+	 * <code>malloc()</code>.
+	 * </p>
+	 * 
+	 * @param destAddress
+	 *            the address of the destination memory block.
+	 * @param srcAddress
+	 *            the address of the source memory block.
+	 * @param length
+	 *            the number of bytes to move.
+	 */
+	public void memmove(long destAddress, long srcAddress, long length);
+
+	/**
+	 * Copies <code>length</code> bytes from the memory block at
+	 * <code>address</code> into the byte array <code>bytes</code> starting
+	 * at element <code>offset</code> within the byte array.
+	 * <p>
+	 * The behavior of this method is undefined if the range
+	 * <code>(address ... address + length)</code> is not within a memory
+	 * block that was allocated using {@link #malloc(long) malloc(long)}.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the address of the OS memory block from which to copy bytes.
+	 * @param bytes
+	 *            the byte array into which to copy the bytes.
+	 * @param offset
+	 *            the index of the first element in <code>bytes</code> that
+	 *            will be overwritten.
+	 * @param length
+	 *            the total number of bytes to copy into the byte array.
+	 * @throws NullPointerException
+	 *             if <code>bytes</code> is <code>null</code>.
+	 * @throws IndexOutOfBoundsException
+	 *             if <code>offset + length > bytes.length</code>.
+	 */
+	public void getByteArray(long address, byte[] bytes, int offset, int length)
+			throws NullPointerException, IndexOutOfBoundsException;
+
+	/**
+	 * Copies <code>length</code> bytes from the byte array <code>bytes</code>
+	 * into the memory block at <code>address</code>, starting at element
+	 * <code>offset</code> within the byte array.
+	 * <p>
+	 * The behavior of this method is undefined if the range
+	 * <code>(address ... address + length)</code> is not within a memory
+	 * block that was allocated using {@link #malloc(long) malloc(long)}.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the address of the OS memory block into which to copy the
+	 *            bytes.
+	 * @param bytes
+	 *            the byte array from which to copy the bytes.
+	 * @param offset
+	 *            the index of the first element in <code>bytes</code> that
+	 *            will be read.
+	 * @param length
+	 *            the total number of bytes to copy from <code>bytes</code>
+	 *            into the memory block.
+	 * @throws NullPointerException
+	 *             if <code>bytes</code> is <code>null</code>.
+	 * @throws IndexOutOfBoundsException
+	 *             if <code>offset + length > bytes.length</code>.
+	 */
+	public void setByteArray(long address, byte[] bytes, int offset, int length)
+			throws NullPointerException, IndexOutOfBoundsException;
+
+	// Primitive get & set methods
+	public byte getByte(long address);
+
+	/**
+	 * Sets the given single byte value at the given address.
+	 * <p>
+	 * The behavior is unspecified if <code>address</code> is not in the range
+	 * that was previously allocated using <code>malloc()</code>.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the address at which to set the byte value.
+	 * @param value
+	 *            the value to set.
+	 */
+	public void setByte(long address, byte value);
+
+	/**
+	 * Gets the value of the signed two-byte integer stored in platform byte
+	 * order at the given address.
+	 * <p>
+	 * The behavior is unspecified if <code>(address ... address + 2)</code>
+	 * is not wholly within the range that was previously allocated using
+	 * <code>malloc()</code>.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the platform address of the start of the two-byte value.
+	 * @return the value of the two-byte integer as a Java <code>short</code>.
+	 */
+	public short getShort(long address);
+
+	public short getShort(long address, Endianness endianness);
+
+	/**
+	 * Sets the value of the signed two-byte integer at the given address in
+	 * platform byte order.
+	 * <p>
+	 * The behavior is unspecified if <code>(address ... address + 2)</code>
+	 * is not wholly within the range that was previously allocated using
+	 * <code>malloc()</code>.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the platform address of the start of the two-byte value.
+	 * @param value
+	 *            the value of the two-byte integer as a Java <code>short</code>.
+	 */
+	public void setShort(long address, short value);
+
+	public void setShort(long address, short value, Endianness endianness);
+
+	/**
+	 * Gets the value of the signed four-byte integer stored in platform
+	 * byte-order at the given address.
+	 * <p>
+	 * The behavior is unspecified if <code>(address ... address + 4)</code>
+	 * is not wholly within the range that was previously allocated using
+	 * <code>malloc()</code>.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the platform address of the start of the four-byte value.
+	 * @return the value of the four-byte integer as a Java <code>int</code>.
+	 */
+	public int getInt(long address);
+
+	public int getInt(long address, Endianness endianness);
+
+	/**
+	 * Sets the value of the signed four-byte integer at the given address in
+	 * platform byte order.
+	 * <p>
+	 * The behavior is unspecified if <code>(address ... address + 4)</code>
+	 * is not wholly within the range that was previously allocated using
+	 * <code>malloc()</code>.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the platform address of the start of the four-byte value.
+	 * @param value
+	 *            the value of the four-byte integer as a Java <code>int</code>.
+	 */
+	public void setInt(long address, int value);
+
+	public void setInt(long address, int value, Endianness endianness);
+
+	/**
+	 * Gets the value of the signed eight-byte integer stored in platform byte
+	 * order at the given address.
+	 * <p>
+	 * The behavior is unspecified if <code>(address ... address + 8)</code>
+	 * is not wholly within the range that was previously allocated using
+	 * <code>malloc()</code>.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the platform address of the start of the eight-byte value.
+	 * @return the value of the eight-byte integer as a Java <code>long</code>.
+	 */
+	public long getLong(long address);
+
+	public long getLong(long address, Endianness endianness);
+
+	/**
+	 * Sets the value of the signed eight-byte integer at the given address in
+	 * the platform byte order.
+	 * <p>
+	 * The behavior is unspecified if <code>(address ... address + 8)</code>
+	 * is not wholly within the range that was previously allocated using
+	 * <code>malloc()</code>.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the platform address of the start of the eight-byte value.
+	 * @param value
+	 *            the value of the eight-byte integer as a Java
+	 *            <code>long</code>.
+	 */
+	public void setLong(long address, long value);
+
+	public void setLong(long address, long value, Endianness endianness);
+
+	/**
+	 * Gets the value of the IEEE754-format four-byte float stored in platform
+	 * byte order at the given address.
+	 * <p>
+	 * The behavior is unspecified if <code>(address ... address + 4)</code>
+	 * is not wholly within the range that was previously allocated using
+	 * <code>malloc()</code>.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the platform address of the start of the eight-byte value.
+	 * @return the value of the four-byte float as a Java <code>float</code>.
+	 */
+	public float getFloat(long address);
+
+	public float getFloat(long address, Endianness endianness);
+
+	/**
+	 * Sets the value of the IEEE754-format four-byte float stored in platform
+	 * byte order at the given address.
+	 * <p>
+	 * The behavior is unspecified if <code>(address ... address + 4)</code>
+	 * is not wholly within the range that was previously allocated using
+	 * <code>malloc()</code>.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the platform address of the start of the eight-byte value.
+	 * @param value
+	 *            the value of the four-byte float as a Java <code>float</code>.
+	 */
+	public void setFloat(long address, float value);
+
+	public void setFloat(long address, float value, Endianness endianness);
+
+	/**
+	 * Gets the value of the IEEE754-format eight-byte float stored in platform
+	 * byte order at the given address.
+	 * <p>
+	 * The behavior is unspecified if <code>(address ... address + 8)</code>
+	 * is not wholly within the range that was previously allocated using
+	 * <code>malloc()</code>.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the platform address of the start of the eight-byte value.
+	 * @return the value of the eight-byte float as a Java <code>double</code>.
+	 */
+	public double getDouble(long address);
+
+	public double getDouble(long address, Endianness endianness);
+
+	/**
+	 * Sets the value of the IEEE754-format eight-byte float store in platform
+	 * byte order at the given address.
+	 * <p>
+	 * The behavior is unspecified if <code>(address ... address + 8)</code>
+	 * is not wholly within the range that was previously allocated using
+	 * <code>malloc()</code>.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the platform address of the start of the eight-byte value.
+	 * @param value
+	 *            the value of the eight-byte float as a Java
+	 *            <code>double</code>.
+	 */
+	public void setDouble(long address, double value);
+
+	public void setDouble(long address, double value, Endianness endianness);
+
+	/**
+	 * Gets the value of the platform pointer at the given address.
+	 * <p>
+	 * The length of the platform pointer is defined by
+	 * <code>POINTER_SIZE</code>.
+	 * </p>
+	 * The behavior is unspecified if
+	 * <code>(address ... address + POINTER_SIZE)</code> is not wholly within
+	 * the range that was previously allocated using <code>malloc()</code>.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the platform address of the start of the platform pointer.
+	 * @return the value of the platform pointer as a Java <code>long</code>.
+	 */
+	public long getAddress(long address);
+
+	/**
+	 * Sets the value of the platform pointer at the given address.
+	 * <p>
+	 * The length of the platform pointer is defined by
+	 * <code>POINTER_SIZE</code>. This method only sets
+	 * <code>POINTER_SIZE</code> bytes at the given address.
+	 * </p>
+	 * The behavior is unspecified if
+	 * <code>(address ... address + POINTER_SIZE)</code> is not wholly within
+	 * the range that was previously allocated using <code>malloc()</code>.
+	 * </p>
+	 * 
+	 * @param address
+	 *            the platform address of the start of the platform pointer.
+	 * @param value
+	 *            the value of the platform pointer as a Java <code>long</code>.
+	 */
+	public void setAddress(long address, long value);
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/ISystemComponent.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/ISystemComponent.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/ISystemComponent.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/ISystemComponent.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,25 @@
+/* Copyright 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 com.ibm.platform;
+
+
+/**
+ * ISystemComponent
+ * 
+ */
+public interface ISystemComponent extends IAdaptable {
+	/*empty*/
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/OSComponent.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/OSComponent.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/OSComponent.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/OSComponent.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,46 @@
+/* Copyright 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 com.ibm.platform;
+
+
+import com.ibm.oti.vm.VM;
+
+/**
+ * OSComponent
+ * 
+ */
+public class OSComponent implements IAdaptable {
+
+	/**
+	 * 
+	 */
+	public OSComponent() {
+		super();
+		if (VM.callerClassLoader() != null) {
+			throw new SecurityException();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see com.ibm.core.IAdaptable#getAdapter(java.lang.Class)
+	 */
+	public Object getAdapter(Class adapter) {
+		return Platform.getAdapterManager().getAdapter(this, adapter);
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/OSComponentFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/OSComponentFactory.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/OSComponentFactory.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/OSComponentFactory.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,41 @@
+/* Copyright 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 com.ibm.platform;
+
+
+/**
+ * OSComponentFactory
+ * 
+ */
+public class OSComponentFactory {
+
+	/**
+	 * @return OSFileSystem
+	 */
+	public static IFileSystem getFileSystem() {
+		//  Auto-generated method stub
+		return new OSFileSystem();
+	}
+
+	/**
+	 * @return OSMemory
+	 */
+	public static IMemorySystem getMemorySystem() {
+		// Auto-generated method stub
+		return new OSMemory();
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/OSFileSystem.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/OSFileSystem.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/OSFileSystem.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/nio/src/com/ibm/platform/OSFileSystem.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,197 @@
+/* Copyright 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 com.ibm.platform;
+
+
+import java.io.IOException;
+
+import com.ibm.misc.util.NotYetImplementedException;
+import com.ibm.platform.struct.PlatformAddress;
+
+/**
+ * This is the portable implementation of the file system interface.
+ * 
+ */
+public class OSFileSystem extends OSComponent implements IFileSystem {
+
+	/**
+	 * 
+	 */
+	public OSFileSystem() {
+		super();
+		// Auto-generated constructor stub
+	}
+
+	private final void validateLockArgs(int type, long start, long length) {
+		if ((type != IFileSystem.SHARED_LOCK_TYPE)
+				&& (type != IFileSystem.EXCLUSIVE_LOCK_TYPE)) {
+			throw new IllegalArgumentException("Illegal lock type requested."); //$NON-NLS-1$
+		}
+
+		// Start position
+		if (start < 0) {
+			throw new IllegalArgumentException(
+					"Lock start position must be non-negative"); //$NON-NLS-1$
+		}
+
+		// Length of lock stretch
+		if (length < 0) {
+			throw new IllegalArgumentException(
+					"Lock length must be non-negative"); //$NON-NLS-1$
+		}
+	}
+
+	private native int lockImpl(long fileDescriptor, long start, long length,
+			int type, boolean wait);
+
+	public boolean lock(long fileDescriptor, long start, long length, int type,
+			boolean waitFlag) throws IOException {
+		// Validate arguments
+		validateLockArgs(type, start, length);
+		int result = lockImpl(fileDescriptor, start, length, type, waitFlag);
+		return result != -1;
+	}
+
+	private native int unlockImpl(long fileDescriptor, long start, long length);
+
+	public void unlock(long fileDescriptor, long start, long length)
+			throws IOException {
+		// Validate arguments
+		validateLockArgs(IFileSystem.SHARED_LOCK_TYPE, start, length);
+		int result = unlockImpl(fileDescriptor, start, length);
+		if (result == -1) {
+			throw new IOException();
+		}
+	}
+
+	private native int fflushImpl(long fd, boolean metadata);
+
+	public void fflush(long fileDescriptor, boolean metadata)
+			throws IOException {
+		int result = fflushImpl(fileDescriptor, metadata);
+		if (result == -1) {
+			throw new IOException();
+		}
+	}
+
+	/*
+	 * File position seeking.
+	 */
+
+	private native long seekImpl(long fd, long offset, int whence);
+
+	public long seek(long fileDescriptor, long offset, int whence)
+			throws IOException {
+		long pos = seekImpl(fileDescriptor, offset, whence);
+		if (pos == -1) {
+			throw new IOException();
+		}
+		return pos;
+	}
+
+	/*
+	 * Direct read/write APIs work on addresses.
+	 */
+	private native long readDirectImpl(long fileDescriptor, long address,
+			int length);
+
+	public long readDirect(long fileDescriptor, long address, int length)
+			throws IOException {
+		long bytesRead = readDirectImpl(fileDescriptor, address, length);
+		if (bytesRead < -1) {
+			throw new IOException();
+		}
+		return bytesRead;
+	}
+
+	private native long writeDirectImpl(long fileDescriptor, long address,
+			int length);
+
+	public long writeDirect(long fileDescriptor, long address, int length)
+			throws IOException {
+		long bytesWritten = writeDirectImpl(fileDescriptor, address, length);
+		if (bytesWritten < -1) {
+			throw new IOException();
+		}
+		return bytesWritten;
+	}
+
+	/*
+	 * Indirect read/writes work on byte[]'s
+	 */
+	private native long readImpl(long fileDescriptor, byte[] bytes, int offset,
+			int length);
+
+	public long read(long fileDescriptor, byte[] bytes, int offset, int length)
+			throws IOException {
+		long bytesRead = readImpl(fileDescriptor, bytes, offset, length);
+		if (bytesRead < -1) {
+			throw new IOException();
+		}
+		return bytesRead;
+	}
+
+	public long write(long fileDescriptor, byte[] bytes, int offset, int length)
+			throws IOException {
+		// Auto-generated method stub
+		throw new NotYetImplementedException();
+	}
+
+	/*
+	 * Scatter/gather calls.
+	 */
+	public long readv(long fileDescriptor, byte[] bytes, int[] offsets,
+			int[] lengths) throws IOException {
+		// Auto-generated method stub
+		throw new NotYetImplementedException();
+	}
+
+	public long writev(long fileDescriptor, byte[] bytes, int[] offsets,
+			int[] lengths) throws IOException {
+		//  Auto-generated method stub
+		throw new NotYetImplementedException();
+	}
+
+	/*
+	 * Memory mapped file
+	 */
+	private native long mmapImpl(long fileDescriptor, long offset, long size,
+			int mapMode);
+
+	public PlatformAddress mmap(long fileDescriptor, long offset, long size,
+			int mapMode) throws IOException {
+		long address = mmapImpl(fileDescriptor, offset, size, mapMode);
+		if (address == -1) {
+			throw new IOException();
+		}
+		return PlatformAddress.on(address);
+
+	}
+
+	private native int closeImpl(long fileDescriptor);
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see com.ibm.platform.IFileSystem#close(long)
+	 */
+	public void close(long fileDescriptor) throws IOException {
+		int rc = closeImpl(fileDescriptor);
+		if (rc == -1) {
+			throw new IOException();
+		}
+	}
+}



Mime
View raw message