You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2007/09/22 23:25:00 UTC
svn commit: r578502 [8/10] - in /harmony/enhanced/classlib/branches/java6:
depends/files/ depends/jars/ depends/manifests/xerces_2.9.0/
depends/manifests/xerces_2.9.1/ depends/manifests/xerces_2.9.1/META-INF/
make/ modules/archive/src/main/native/archi...
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/LongToByteBufferAdapter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/LongToByteBufferAdapter.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/LongToByteBufferAdapter.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/LongToByteBufferAdapter.java Sat Sep 22 14:24:54 2007
@@ -19,7 +19,6 @@
import org.apache.harmony.nio.internal.DirectBuffer;
import org.apache.harmony.luni.platform.PlatformAddress;
-
/**
* This class wraps a byte buffer to be a long buffer.
* <p>
@@ -35,162 +34,172 @@
*/
final class LongToByteBufferAdapter extends LongBuffer implements DirectBuffer {
- static LongBuffer wrap(ByteBuffer byteBuffer) {
- return new LongToByteBufferAdapter(byteBuffer.slice());
- }
-
- private final ByteBuffer byteBuffer;
-
- LongToByteBufferAdapter(ByteBuffer byteBuffer) {
- super((byteBuffer.capacity() >> 3));
- this.byteBuffer = byteBuffer;
- this.byteBuffer.clear();
- }
-
- public int getByteCapacity() {
- if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getByteCapacity();
- } else {
- assert false : byteBuffer;
- return -1;
- }
- }
-
- public PlatformAddress getEffectiveAddress() {
- if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getEffectiveAddress();
- } else {
- assert false : byteBuffer;
- return null;
- }
- }
-
- public PlatformAddress getBaseAddress() {
- if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getBaseAddress();
- } else {
- assert false : byteBuffer;
- return null;
- }
- }
-
- public boolean isAddressValid() {
- if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).isAddressValid();
- } else {
- assert false : byteBuffer;
- return false;
- }
- }
-
- public void addressValidityCheck() {
- if (byteBuffer instanceof DirectBuffer) {
- ((DirectBuffer)byteBuffer).addressValidityCheck();
- } else {
- assert false : byteBuffer;
- }
- }
-
- public void free() {
- if (byteBuffer instanceof DirectBuffer) {
- ((DirectBuffer)byteBuffer).free();
- } else {
- assert false : byteBuffer;
- }
- }
-
- public LongBuffer asReadOnlyBuffer() {
- LongToByteBufferAdapter buf = new LongToByteBufferAdapter(byteBuffer
- .asReadOnlyBuffer());
- buf.limit = limit;
- buf.position = position;
- buf.mark = mark;
- return buf;
- }
-
- public LongBuffer compact() {
- if (byteBuffer.isReadOnly()) {
- throw new ReadOnlyBufferException();
- }
- byteBuffer.limit(limit << 3);
- byteBuffer.position(position << 3);
- byteBuffer.compact();
- byteBuffer.clear();
- position = limit - position;
- limit = capacity;
- mark = UNSET_MARK;
- return this;
- }
-
- public LongBuffer duplicate() {
- LongToByteBufferAdapter buf = new LongToByteBufferAdapter(byteBuffer
- .duplicate());
- buf.limit = limit;
- buf.position = position;
- buf.mark = mark;
- return buf;
- }
-
- public long get() {
- if (position == limit) {
- throw new BufferUnderflowException();
- }
- return byteBuffer.getLong(position++ << 3);
- }
-
- public long get(int index) {
- if (index < 0 || index >= limit) {
- throw new IndexOutOfBoundsException();
- }
- return byteBuffer.getLong(index << 3);
- }
-
- public boolean isDirect() {
- return byteBuffer.isDirect();
- }
-
- public boolean isReadOnly() {
- return byteBuffer.isReadOnly();
- }
-
- public ByteOrder order() {
- return byteBuffer.order();
- }
-
- protected long[] protectedArray() {
- throw new UnsupportedOperationException();
- }
-
- protected int protectedArrayOffset() {
- throw new UnsupportedOperationException();
- }
-
- protected boolean protectedHasArray() {
- return false;
- }
-
- public LongBuffer put(long c) {
- if (position == limit) {
- throw new BufferOverflowException();
- }
- byteBuffer.putLong(position++ << 3, c);
- return this;
- }
-
- public LongBuffer put(int index, long c) {
- if (index < 0 || index >= limit) {
- throw new IndexOutOfBoundsException();
- }
- byteBuffer.putLong(index << 3, c);
- return this;
- }
-
- public LongBuffer slice() {
- byteBuffer.limit(limit << 3);
- byteBuffer.position(position << 3);
- LongBuffer result = new LongToByteBufferAdapter(byteBuffer.slice());
- byteBuffer.clear();
- return result;
- }
+ static LongBuffer wrap(ByteBuffer byteBuffer) {
+ return new LongToByteBufferAdapter(byteBuffer.slice());
+ }
+
+ private final ByteBuffer byteBuffer;
+
+ LongToByteBufferAdapter(ByteBuffer byteBuffer) {
+ super((byteBuffer.capacity() >> 3));
+ this.byteBuffer = byteBuffer;
+ this.byteBuffer.clear();
+ }
+
+ public int getByteCapacity() {
+ if (byteBuffer instanceof DirectBuffer) {
+ return ((DirectBuffer) byteBuffer).getByteCapacity();
+ }
+ assert false : byteBuffer;
+ return -1;
+ }
+
+ public PlatformAddress getEffectiveAddress() {
+ if (byteBuffer instanceof DirectBuffer) {
+ return ((DirectBuffer) byteBuffer).getEffectiveAddress();
+ }
+ assert false : byteBuffer;
+ return null;
+ }
+
+ public PlatformAddress getBaseAddress() {
+ if (byteBuffer instanceof DirectBuffer) {
+ return ((DirectBuffer) byteBuffer).getBaseAddress();
+ }
+ assert false : byteBuffer;
+ return null;
+ }
+
+ public boolean isAddressValid() {
+ if (byteBuffer instanceof DirectBuffer) {
+ return ((DirectBuffer) byteBuffer).isAddressValid();
+ }
+ assert false : byteBuffer;
+ return false;
+ }
+
+ public void addressValidityCheck() {
+ if (byteBuffer instanceof DirectBuffer) {
+ ((DirectBuffer) byteBuffer).addressValidityCheck();
+ } else {
+ assert false : byteBuffer;
+ }
+ }
+
+ public void free() {
+ if (byteBuffer instanceof DirectBuffer) {
+ ((DirectBuffer) byteBuffer).free();
+ } else {
+ assert false : byteBuffer;
+ }
+ }
+
+ @Override
+ public LongBuffer asReadOnlyBuffer() {
+ LongToByteBufferAdapter buf = new LongToByteBufferAdapter(byteBuffer
+ .asReadOnlyBuffer());
+ buf.limit = limit;
+ buf.position = position;
+ buf.mark = mark;
+ return buf;
+ }
+
+ @Override
+ public LongBuffer compact() {
+ if (byteBuffer.isReadOnly()) {
+ throw new ReadOnlyBufferException();
+ }
+ byteBuffer.limit(limit << 3);
+ byteBuffer.position(position << 3);
+ byteBuffer.compact();
+ byteBuffer.clear();
+ position = limit - position;
+ limit = capacity;
+ mark = UNSET_MARK;
+ return this;
+ }
+
+ @Override
+ public LongBuffer duplicate() {
+ LongToByteBufferAdapter buf = new LongToByteBufferAdapter(byteBuffer
+ .duplicate());
+ buf.limit = limit;
+ buf.position = position;
+ buf.mark = mark;
+ return buf;
+ }
+
+ @Override
+ public long get() {
+ if (position == limit) {
+ throw new BufferUnderflowException();
+ }
+ return byteBuffer.getLong(position++ << 3);
+ }
+
+ @Override
+ public long get(int index) {
+ if (index < 0 || index >= limit) {
+ throw new IndexOutOfBoundsException();
+ }
+ return byteBuffer.getLong(index << 3);
+ }
+
+ @Override
+ public boolean isDirect() {
+ return byteBuffer.isDirect();
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return byteBuffer.isReadOnly();
+ }
+
+ @Override
+ public ByteOrder order() {
+ return byteBuffer.order();
+ }
+
+ @Override
+ protected long[] protectedArray() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected int protectedArrayOffset() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected boolean protectedHasArray() {
+ return false;
+ }
+
+ @Override
+ public LongBuffer put(long c) {
+ if (position == limit) {
+ throw new BufferOverflowException();
+ }
+ byteBuffer.putLong(position++ << 3, c);
+ return this;
+ }
+
+ @Override
+ public LongBuffer put(int index, long c) {
+ if (index < 0 || index >= limit) {
+ throw new IndexOutOfBoundsException();
+ }
+ byteBuffer.putLong(index << 3, c);
+ return this;
+ }
+
+ @Override
+ public LongBuffer slice() {
+ byteBuffer.limit(limit << 3);
+ byteBuffer.position(position << 3);
+ LongBuffer result = new LongToByteBufferAdapter(byteBuffer.slice());
+ byteBuffer.clear();
+ return result;
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/MappedByteBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/MappedByteBuffer.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/MappedByteBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/MappedByteBuffer.java Sat Sep 22 14:24:54 2007
@@ -21,7 +21,6 @@
import org.apache.harmony.luni.platform.PlatformAddress;
import org.apache.harmony.nio.internal.DirectBuffer;
-
/**
* <code>MappedByteBuffer</code> is a special kind of direct byte buffer,
* which maps a region of file to memory.
@@ -58,37 +57,39 @@
super(capa);
mapMode = mode;
switch (mapMode) {
- case IMemorySystem.MMAP_READ_ONLY:
- wrapped = new ReadOnlyDirectByteBuffer(addr, capa, offset);
- break;
- case IMemorySystem.MMAP_READ_WRITE:
- case IMemorySystem.MMAP_WRITE_COPY:
- wrapped = new ReadWriteDirectByteBuffer(addr, capa, offset);
- break;
- default:
- throw new IllegalArgumentException();
+ case IMemorySystem.MMAP_READ_ONLY:
+ wrapped = new ReadOnlyDirectByteBuffer(addr, capa, offset);
+ break;
+ case IMemorySystem.MMAP_READ_WRITE:
+ case IMemorySystem.MMAP_WRITE_COPY:
+ wrapped = new ReadWriteDirectByteBuffer(addr, capa, offset);
+ break;
+ default:
+ throw new IllegalArgumentException();
}
addr.autoFree();
}
- /**
- * Returns true if this buffer's content is loaded.
- *
- * @return True if this buffer's content is loaded.
- */
- public final boolean isLoaded() {
- return ((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapIsLoaded();
- }
-
- /**
- * Loads this buffer's content into memory.
- *
- * @return This buffer
- */
- public final MappedByteBuffer load() {
- ((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapLoad();
- return this;
- }
+ /**
+ * Returns true if this buffer's content is loaded.
+ *
+ * @return True if this buffer's content is loaded.
+ */
+ public final boolean isLoaded() {
+ return ((MappedPlatformAddress) ((DirectBuffer) wrapped)
+ .getBaseAddress()).mmapIsLoaded();
+ }
+
+ /**
+ * Loads this buffer's content into memory.
+ *
+ * @return This buffer
+ */
+ public final MappedByteBuffer load() {
+ ((MappedPlatformAddress) ((DirectBuffer) wrapped).getBaseAddress())
+ .mmapLoad();
+ return this;
+ }
/**
* Writes all changes of the buffer to the mapped file.
@@ -100,7 +101,8 @@
*/
public final MappedByteBuffer force() {
if (mapMode == IMemorySystem.MMAP_READ_WRITE) {
- ((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapFlush();
+ ((MappedPlatformAddress) ((DirectBuffer) wrapped).getBaseAddress())
+ .mmapFlush();
}
return this;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java Sat Sep 22 14:24:54 2007
@@ -20,8 +20,8 @@
import org.apache.harmony.luni.platform.PlatformAddress;
import org.apache.harmony.nio.internal.DirectBuffer;
-
-final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
+final class MappedByteBufferAdapter extends MappedByteBuffer implements
+ DirectBuffer {
private static final int CHAR_SIZE = 2;
@@ -34,280 +34,325 @@
private static final int FLOAT_SIZE = 4;
private static final int DOUBLE_SIZE = 8;
-
+
public MappedByteBufferAdapter(ByteBuffer buffer) {
- super(buffer);
- }
+ super(buffer);
+ }
+
+ public MappedByteBufferAdapter(PlatformAddress addr, int capa, int offset,
+ int mode) {
+ super(addr, capa, offset, mode);
+ }
+
+ @Override
+ public CharBuffer asCharBuffer() {
+ return this.wrapped.asCharBuffer();
+ }
+
+ @Override
+ public DoubleBuffer asDoubleBuffer() {
+ return this.wrapped.asDoubleBuffer();
+ }
+
+ @Override
+ public FloatBuffer asFloatBuffer() {
+ return this.wrapped.asFloatBuffer();
+ }
+
+ @Override
+ public IntBuffer asIntBuffer() {
+ return this.wrapped.asIntBuffer();
+ }
+
+ @Override
+ public LongBuffer asLongBuffer() {
+ return this.wrapped.asLongBuffer();
+ }
+
+ @Override
+ public ByteBuffer asReadOnlyBuffer() {
+ MappedByteBufferAdapter buf = new MappedByteBufferAdapter(this.wrapped
+ .asReadOnlyBuffer());
+ buf.limit = this.limit;
+ buf.position = this.position;
+ buf.mark = this.mark;
+ return buf;
+ }
+
+ @Override
+ public ShortBuffer asShortBuffer() {
+ return this.wrapped.asShortBuffer();
+ }
+
+ @Override
+ public ByteBuffer compact() {
+ if (this.wrapped.isReadOnly()) {
+ throw new ReadOnlyBufferException();
+ }
+ this.wrapped.limit(this.limit);
+ this.wrapped.position(this.position);
+ this.wrapped.compact();
+ this.wrapped.clear();
+ this.position = this.limit - this.position;
+ this.limit = this.capacity;
+ this.mark = UNSET_MARK;
+ return this;
+ }
+
+ @Override
+ public ByteBuffer duplicate() {
+ MappedByteBufferAdapter buf = new MappedByteBufferAdapter(this.wrapped
+ .duplicate());
+ buf.limit = this.limit;
+ buf.position = this.position;
+ buf.mark = this.mark;
+ return buf;
+ }
+
+ @Override
+ public byte get() {
+ byte result = this.wrapped.get();
+ this.position++;
+ return result;
+ }
+
+ @Override
+ public byte get(int index) {
+ return this.wrapped.get(index);
+ }
+
+ @Override
+ public char getChar() {
+ char result = this.wrapped.getChar();
+ this.position += CHAR_SIZE;
+ return result;
+ }
+
+ @Override
+ public char getChar(int index) {
+ return this.wrapped.getChar(index);
+ }
+
+ @Override
+ public double getDouble() {
+ double result = this.wrapped.getDouble();
+ this.position += DOUBLE_SIZE;
+ return result;
+ }
+
+ @Override
+ public double getDouble(int index) {
+ return this.wrapped.getDouble(index);
+ }
+
+ public PlatformAddress getEffectiveAddress() {
+ return ((DirectBuffer) this.wrapped).getEffectiveAddress();
+ }
+
+ @Override
+ public float getFloat() {
+ float result = this.wrapped.getFloat();
+ this.position += FLOAT_SIZE;
+ return result;
+ }
+
+ @Override
+ public float getFloat(int index) {
+ return this.wrapped.getFloat(index);
+ }
+
+ @Override
+ public int getInt() {
+ int result = this.wrapped.getInt();
+ this.position += INTEGER_SIZE;
+ return result;
+ }
+
+ @Override
+ public int getInt(int index) {
+ return this.wrapped.getInt(index);
+ }
+
+ @Override
+ public long getLong() {
+ long result = this.wrapped.getLong();
+ this.position += LONG_SIZE;
+ return result;
+ }
+
+ @Override
+ public long getLong(int index) {
+ return this.wrapped.getLong(index);
+ }
+
+ @Override
+ public short getShort() {
+ short result = this.wrapped.getShort();
+ this.position += SHORT_SIZE;
+ return result;
+ }
+
+ @Override
+ public short getShort(int index) {
+ return this.wrapped.getShort(index);
+ }
+
+ @Override
+ public boolean isDirect() {
+ return true;
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return this.wrapped.isReadOnly();
+ }
+
+ @Override
+ ByteBuffer orderImpl(ByteOrder byteOrder) {
+ super.orderImpl(byteOrder);
+ return this.wrapped.order(byteOrder);
+ }
+
+ @Override
+ public ByteBuffer put(byte b) {
+ this.wrapped.put(b);
+ this.position++;
+ return this;
+ }
+
+ @Override
+ public ByteBuffer put(byte[] src, int off, int len) {
+ this.wrapped.position(this.position);
+ this.wrapped.put(src, off, len);
+ this.position += len;
+ return this;
+ }
+
+ @Override
+ public ByteBuffer put(int index, byte b) {
+ this.wrapped.put(index, b);
+ return this;
+ }
+
+ @Override
+ public ByteBuffer putChar(char value) {
+ this.wrapped.putChar(value);
+ this.position += CHAR_SIZE;
+ return this;
+ }
+
+ @Override
+ public ByteBuffer putChar(int index, char value) {
+ this.wrapped.putChar(index, value);
+ return this;
+ }
+
+ @Override
+ public ByteBuffer putDouble(double value) {
+ this.wrapped.putDouble(value);
+ this.position += DOUBLE_SIZE;
+ return this;
+ }
+
+ @Override
+ public ByteBuffer putDouble(int index, double value) {
+ this.wrapped.putDouble(index, value);
+ return this;
+ }
+
+ @Override
+ public ByteBuffer putFloat(float value) {
+ this.wrapped.putFloat(value);
+ this.position += FLOAT_SIZE;
+ return this;
+ }
+
+ @Override
+ public ByteBuffer putFloat(int index, float value) {
+ this.wrapped.putFloat(index, value);
+ return this;
+ }
+
+ @Override
+ public ByteBuffer putInt(int index, int value) {
+ this.wrapped.putInt(index, value);
+ return this;
+ }
+
+ @Override
+ public ByteBuffer putInt(int value) {
+ this.wrapped.putInt(value);
+ this.position += INTEGER_SIZE;
+ return this;
+ }
+
+ @Override
+ public ByteBuffer putLong(int index, long value) {
+ this.wrapped.putLong(index, value);
+ return this;
+ }
+
+ @Override
+ public ByteBuffer putLong(long value) {
+ this.wrapped.putLong(value);
+ this.position += LONG_SIZE;
+ return this;
+ }
+
+ @Override
+ public ByteBuffer putShort(int index, short value) {
+ this.wrapped.putShort(index, value);
+ return this;
+ }
+
+ @Override
+ public ByteBuffer putShort(short value) {
+ this.wrapped.putShort(value);
+ this.position += SHORT_SIZE;
+ return this;
+ }
+
+ @Override
+ public ByteBuffer slice() {
+ this.wrapped.limit(this.limit);
+ this.wrapped.position(this.position);
+ MappedByteBufferAdapter result = new MappedByteBufferAdapter(
+ this.wrapped.slice());
+ this.wrapped.clear();
+ return result;
+ }
+
+ @Override
+ byte[] protectedArray() {
+ return this.wrapped.protectedArray();
+ }
+
+ @Override
+ int protectedArrayOffset() {
+ return this.wrapped.protectedArrayOffset();
+ }
+
+ @Override
+ boolean protectedHasArray() {
+ return this.wrapped.protectedHasArray();
+ }
+
+ public PlatformAddress getBaseAddress() {
+ return this.wrapped.getBaseAddress();
+ }
+
+ public boolean isAddressValid() {
+ return this.wrapped.isAddressValid();
+ }
+
+ public void addressValidityCheck() {
+ this.wrapped.addressValidityCheck();
+ }
+
+ public void free() {
+ this.wrapped.free();
+ }
- public MappedByteBufferAdapter(PlatformAddress addr, int capa, int offset,
- int mode) {
- super(addr, capa, offset, mode);
- }
-
- public CharBuffer asCharBuffer() {
- return this.wrapped.asCharBuffer();
- }
-
- public DoubleBuffer asDoubleBuffer() {
- return this.wrapped.asDoubleBuffer();
- }
-
- public FloatBuffer asFloatBuffer() {
- return this.wrapped.asFloatBuffer();
- }
-
- public IntBuffer asIntBuffer() {
- return this.wrapped.asIntBuffer();
- }
-
- public LongBuffer asLongBuffer() {
- return this.wrapped.asLongBuffer();
- }
-
- public ByteBuffer asReadOnlyBuffer() {
- MappedByteBufferAdapter buf = new MappedByteBufferAdapter(this.wrapped
- .asReadOnlyBuffer());
- buf.limit = this.limit;
- buf.position = this.position;
- buf.mark = this.mark;
- return buf;
- }
-
- public ShortBuffer asShortBuffer() {
- return this.wrapped.asShortBuffer();
- }
-
- public ByteBuffer compact() {
- if (this.wrapped.isReadOnly()) {
- throw new ReadOnlyBufferException();
- }
- this.wrapped.limit(this.limit);
- this.wrapped.position(this.position);
- this.wrapped.compact();
- this.wrapped.clear();
- this.position = this.limit - this.position;
- this.limit = this.capacity;
- this.mark = UNSET_MARK;
- return this;
- }
-
- public ByteBuffer duplicate() {
- MappedByteBufferAdapter buf = new MappedByteBufferAdapter(this.wrapped
- .duplicate());
- buf.limit = this.limit;
- buf.position = this.position;
- buf.mark = this.mark;
- return buf;
- }
-
- public byte get() {
- byte result = this.wrapped.get();
- this.position++;
- return result;
- }
-
- public byte get(int index) {
- return this.wrapped.get(index);
- }
-
- public char getChar() {
- char result = this.wrapped.getChar();
- this.position += CHAR_SIZE;
- return result;
- }
-
- public char getChar(int index) {
- return this.wrapped.getChar(index);
- }
-
- public double getDouble() {
- double result = this.wrapped.getDouble();
- this.position += DOUBLE_SIZE;
- return result;
- }
-
- public double getDouble(int index) {
- return this.wrapped.getDouble(index);
- }
-
- public PlatformAddress getEffectiveAddress() {
- return ((DirectBuffer) this.wrapped).getEffectiveAddress();
- }
-
- public float getFloat() {
- float result = this.wrapped.getFloat();
- this.position += FLOAT_SIZE;
- return result;
- }
-
- public float getFloat(int index) {
- return this.wrapped.getFloat(index);
- }
-
- public int getInt() {
- int result = this.wrapped.getInt();
- this.position += INTEGER_SIZE;
- return result;
- }
-
- public int getInt(int index) {
- return this.wrapped.getInt(index);
- }
-
- public long getLong() {
- long result = this.wrapped.getLong();
- this.position += LONG_SIZE;
- return result;
- }
-
- public long getLong(int index) {
- return this.wrapped.getLong(index);
- }
-
- public short getShort() {
- short result = this.wrapped.getShort();
- this.position += SHORT_SIZE;
- return result;
- }
-
- public short getShort(int index) {
- return this.wrapped.getShort(index);
- }
-
- public boolean isDirect() {
- return true;
- }
-
- public boolean isReadOnly() {
- return this.wrapped.isReadOnly();
- }
-
- ByteBuffer orderImpl(ByteOrder byteOrder) {
- super.orderImpl(byteOrder);
- return this.wrapped.order(byteOrder);
- }
-
- public ByteBuffer put(byte b) {
- this.wrapped.put(b);
- this.position++;
- return this;
- }
-
- public ByteBuffer put(byte[] src, int off, int len) {
- this.wrapped.position(this.position);
- this.wrapped.put(src, off, len);
- this.position += len;
- return this;
- }
-
- public ByteBuffer put(int index, byte b) {
- this.wrapped.put(index, b);
- return this;
- }
-
- public ByteBuffer putChar(char value) {
- this.wrapped.putChar(value);
- this.position += CHAR_SIZE;
- return this;
- }
-
- public ByteBuffer putChar(int index, char value) {
- this.wrapped.putChar(index, value);
- return this;
- }
-
- public ByteBuffer putDouble(double value) {
- this.wrapped.putDouble(value);
- this.position += DOUBLE_SIZE;
- return this;
- }
-
- public ByteBuffer putDouble(int index, double value) {
- this.wrapped.putDouble(index, value);
- return this;
- }
-
- public ByteBuffer putFloat(float value) {
- this.wrapped.putFloat(value);
- this.position += FLOAT_SIZE;
- return this;
- }
-
- public ByteBuffer putFloat(int index, float value) {
- this.wrapped.putFloat(index, value);
- return this;
- }
-
- public ByteBuffer putInt(int index, int value) {
- this.wrapped.putInt(index, value);
- return this;
- }
-
- public ByteBuffer putInt(int value) {
- this.wrapped.putInt(value);
- this.position += INTEGER_SIZE;
- return this;
- }
-
- public ByteBuffer putLong(int index, long value) {
- this.wrapped.putLong(index, value);
- return this;
- }
-
- public ByteBuffer putLong(long value) {
- this.wrapped.putLong(value);
- this.position += LONG_SIZE;
- return this;
- }
-
- public ByteBuffer putShort(int index, short value) {
- this.wrapped.putShort(index, value);
- return this;
- }
-
- public ByteBuffer putShort(short value) {
- this.wrapped.putShort(value);
- this.position += SHORT_SIZE;
- return this;
- }
-
- public ByteBuffer slice() {
- this.wrapped.limit(this.limit);
- this.wrapped.position(this.position);
- MappedByteBufferAdapter result = new MappedByteBufferAdapter(
- this.wrapped.slice());
- this.wrapped.clear();
- return result;
- }
-
- byte[] protectedArray() {
- return this.wrapped.protectedArray();
- }
-
- int protectedArrayOffset() {
- return this.wrapped.protectedArrayOffset();
- }
-
- boolean protectedHasArray() {
- return this.wrapped.protectedHasArray();
- }
-
- public PlatformAddress getBaseAddress() {
- return this.wrapped.getBaseAddress();
- }
-
- public boolean isAddressValid() {
- return this.wrapped.isAddressValid();
- }
-
- public void addressValidityCheck() {
- this.wrapped.addressValidityCheck();
- }
-
- public void free() {
- this.wrapped.free();
- }
-
public int getByteCapacity() {
return wrapped.getByteCapacity();
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyBufferException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyBufferException.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyBufferException.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyBufferException.java Sat Sep 22 14:24:54 2007
@@ -16,7 +16,6 @@
package java.nio;
-
/**
* A <code>ReadOnlyBufferException</code> is thrown when some write operation
* is called on a readonly buffer.
@@ -24,12 +23,12 @@
*/
public class ReadOnlyBufferException extends UnsupportedOperationException {
- private static final long serialVersionUID = -1210063976496234090L;
+ private static final long serialVersionUID = -1210063976496234090L;
- /**
- * Constructs a <code>ReadOnlyBufferException</code>.
- */
- public ReadOnlyBufferException() {
- super();
- }
+ /**
+ * Constructs a <code>ReadOnlyBufferException</code>.
+ */
+ public ReadOnlyBufferException() {
+ super();
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyCharArrayBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyCharArrayBuffer.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyCharArrayBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyCharArrayBuffer.java Sat Sep 22 14:24:54 2007
@@ -31,72 +31,86 @@
*/
final class ReadOnlyCharArrayBuffer extends CharArrayBuffer {
- static ReadOnlyCharArrayBuffer copy(CharArrayBuffer other, int markOfOther) {
- ReadOnlyCharArrayBuffer buf = new ReadOnlyCharArrayBuffer(other
- .capacity(), other.backingArray, other.offset);
- buf.limit = other.limit();
- buf.position = other.position();
- buf.mark = markOfOther;
- return buf;
- }
-
- ReadOnlyCharArrayBuffer(int capacity, char[] backingArray, int arrayOffset) {
- super(capacity, backingArray, arrayOffset);
- }
-
- public CharBuffer asReadOnlyBuffer() {
- return duplicate();
- }
-
- public CharBuffer compact() {
- throw new ReadOnlyBufferException();
- }
-
- public CharBuffer duplicate() {
- return copy(this, mark);
- }
-
- public boolean isReadOnly() {
- return true;
- }
-
- protected char[] protectedArray() {
- throw new ReadOnlyBufferException();
- }
-
- protected int protectedArrayOffset() {
- throw new ReadOnlyBufferException();
- }
-
- protected boolean protectedHasArray() {
- return false;
- }
-
- public CharBuffer put(char c) {
- throw new ReadOnlyBufferException();
- }
-
- public CharBuffer put(int index, char c) {
- throw new ReadOnlyBufferException();
- }
+ static ReadOnlyCharArrayBuffer copy(CharArrayBuffer other, int markOfOther) {
+ ReadOnlyCharArrayBuffer buf = new ReadOnlyCharArrayBuffer(other
+ .capacity(), other.backingArray, other.offset);
+ buf.limit = other.limit();
+ buf.position = other.position();
+ buf.mark = markOfOther;
+ return buf;
+ }
+
+ ReadOnlyCharArrayBuffer(int capacity, char[] backingArray, int arrayOffset) {
+ super(capacity, backingArray, arrayOffset);
+ }
+
+ @Override
+ public CharBuffer asReadOnlyBuffer() {
+ return duplicate();
+ }
+
+ @Override
+ public CharBuffer compact() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public CharBuffer duplicate() {
+ return copy(this, mark);
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ @Override
+ protected char[] protectedArray() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ protected int protectedArrayOffset() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ protected boolean protectedHasArray() {
+ return false;
+ }
+
+ @Override
+ public CharBuffer put(char c) {
+ throw new ReadOnlyBufferException();
+ }
+ @Override
+ public CharBuffer put(int index, char c) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
public final CharBuffer put(char[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public final CharBuffer put(CharBuffer src) {
throw new ReadOnlyBufferException();
}
+ @Override
public CharBuffer put(String src, int start, int end) {
- if ((start < 0 ) || (end < 0) || (long)start + (long)end > src.length()) {
+ if ((start < 0) || (end < 0)
+ || (long) start + (long) end > src.length()) {
throw new IndexOutOfBoundsException();
}
throw new ReadOnlyBufferException();
}
- public CharBuffer slice() {
- return new ReadOnlyCharArrayBuffer(remaining(), backingArray, offset
- + position);
- }
+ @Override
+ public CharBuffer slice() {
+ return new ReadOnlyCharArrayBuffer(remaining(), backingArray, offset
+ + position);
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyDirectByteBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyDirectByteBuffer.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyDirectByteBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyDirectByteBuffer.java Sat Sep 22 14:24:54 2007
@@ -33,103 +33,122 @@
*/
final class ReadOnlyDirectByteBuffer extends DirectByteBuffer {
- static ReadOnlyDirectByteBuffer copy(DirectByteBuffer other, int markOfOther) {
- ReadOnlyDirectByteBuffer buf = new ReadOnlyDirectByteBuffer(
- other.safeAddress, other.capacity(), other.offset);
- buf.limit = other.limit();
- buf.position = other.position();
- buf.mark = markOfOther;
- buf.order(other.order());
- return buf;
- }
-
- protected ReadOnlyDirectByteBuffer(SafeAddress address, int capacity,
- int offset) {
- super(address, capacity, offset);
- }
+ static ReadOnlyDirectByteBuffer copy(DirectByteBuffer other, int markOfOther) {
+ ReadOnlyDirectByteBuffer buf = new ReadOnlyDirectByteBuffer(
+ other.safeAddress, other.capacity(), other.offset);
+ buf.limit = other.limit();
+ buf.position = other.position();
+ buf.mark = markOfOther;
+ buf.order(other.order());
+ return buf;
+ }
+
+ protected ReadOnlyDirectByteBuffer(SafeAddress address, int capacity,
+ int offset) {
+ super(address, capacity, offset);
+ }
protected ReadOnlyDirectByteBuffer(PlatformAddress address, int capacity,
int offset) {
super(new SafeAddress(address), capacity, offset);
}
-
- public ByteBuffer asReadOnlyBuffer() {
- return copy(this, mark);
- }
-
- public ByteBuffer compact() {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer duplicate() {
- return copy(this, mark);
- }
-
- public boolean isReadOnly() {
- return true;
- }
-
- public ByteBuffer put(byte value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer put(int index, byte value) {
- throw new ReadOnlyBufferException();
- }
+ @Override
+ public ByteBuffer asReadOnlyBuffer() {
+ return copy(this, mark);
+ }
+
+ @Override
+ public ByteBuffer compact() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer duplicate() {
+ return copy(this, mark);
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ @Override
+ public ByteBuffer put(byte value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer put(int index, byte value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
public ByteBuffer put(byte[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
- public ByteBuffer putDouble(double value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putDouble(int index, double value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putFloat(float value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putFloat(int index, float value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putInt(int value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putInt(int index, int value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putLong(int index, long value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putLong(long value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putShort(int index, short value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putShort(short value) {
- throw new ReadOnlyBufferException();
- }
-
+
+ @Override
+ public ByteBuffer putDouble(double value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putDouble(int index, double value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putFloat(float value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putFloat(int index, float value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putInt(int value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putInt(int index, int value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putLong(int index, long value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putLong(long value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putShort(int index, short value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putShort(short value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
public ByteBuffer put(ByteBuffer buf) {
throw new ReadOnlyBufferException();
}
- public ByteBuffer slice() {
- ReadOnlyDirectByteBuffer buf = new ReadOnlyDirectByteBuffer(
- safeAddress, remaining(), offset + position);
- buf.order = order;
- return buf;
- }
+ @Override
+ public ByteBuffer slice() {
+ ReadOnlyDirectByteBuffer buf = new ReadOnlyDirectByteBuffer(
+ safeAddress, remaining(), offset + position);
+ buf.order = order;
+ return buf;
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyDoubleArrayBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyDoubleArrayBuffer.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyDoubleArrayBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyDoubleArrayBuffer.java Sat Sep 22 14:24:54 2007
@@ -31,68 +31,80 @@
*/
final class ReadOnlyDoubleArrayBuffer extends DoubleArrayBuffer {
- static ReadOnlyDoubleArrayBuffer copy(DoubleArrayBuffer other,
- int markOfOther) {
- ReadOnlyDoubleArrayBuffer buf = new ReadOnlyDoubleArrayBuffer(other
- .capacity(), other.backingArray, other.offset);
- buf.limit = other.limit();
- buf.position = other.position();
- buf.mark = markOfOther;
- return buf;
- }
-
- ReadOnlyDoubleArrayBuffer(int capacity, double[] backingArray,
- int arrayOffset) {
- super(capacity, backingArray, arrayOffset);
- }
-
- public DoubleBuffer asReadOnlyBuffer() {
- return duplicate();
- }
-
- public DoubleBuffer compact() {
- throw new ReadOnlyBufferException();
- }
-
- public DoubleBuffer duplicate() {
- return copy(this, mark);
- }
-
- public boolean isReadOnly() {
- return true;
- }
-
- protected double[] protectedArray() {
- throw new ReadOnlyBufferException();
- }
-
- protected int protectedArrayOffset() {
- throw new ReadOnlyBufferException();
- }
-
- protected boolean protectedHasArray() {
- return false;
- }
-
- public DoubleBuffer put(double c) {
- throw new ReadOnlyBufferException();
- }
-
- public DoubleBuffer put(int index, double c) {
- throw new ReadOnlyBufferException();
- }
+ static ReadOnlyDoubleArrayBuffer copy(DoubleArrayBuffer other,
+ int markOfOther) {
+ ReadOnlyDoubleArrayBuffer buf = new ReadOnlyDoubleArrayBuffer(other
+ .capacity(), other.backingArray, other.offset);
+ buf.limit = other.limit();
+ buf.position = other.position();
+ buf.mark = markOfOther;
+ return buf;
+ }
+
+ ReadOnlyDoubleArrayBuffer(int capacity, double[] backingArray,
+ int arrayOffset) {
+ super(capacity, backingArray, arrayOffset);
+ }
+
+ @Override
+ public DoubleBuffer asReadOnlyBuffer() {
+ return duplicate();
+ }
+
+ @Override
+ public DoubleBuffer compact() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public DoubleBuffer duplicate() {
+ return copy(this, mark);
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ @Override
+ protected double[] protectedArray() {
+ throw new ReadOnlyBufferException();
+ }
+ @Override
+ protected int protectedArrayOffset() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ protected boolean protectedHasArray() {
+ return false;
+ }
+
+ @Override
+ public DoubleBuffer put(double c) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public DoubleBuffer put(int index, double c) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
public final DoubleBuffer put(double[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public final DoubleBuffer put(DoubleBuffer buf) {
throw new ReadOnlyBufferException();
}
-
- public DoubleBuffer slice() {
- return new ReadOnlyDoubleArrayBuffer(remaining(), backingArray, offset
- + position);
- }
+
+ @Override
+ public DoubleBuffer slice() {
+ return new ReadOnlyDoubleArrayBuffer(remaining(), backingArray, offset
+ + position);
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java Sat Sep 22 14:24:54 2007
@@ -31,66 +31,78 @@
*/
final class ReadOnlyFloatArrayBuffer extends FloatArrayBuffer {
- static ReadOnlyFloatArrayBuffer copy(FloatArrayBuffer other, int markOfOther) {
- ReadOnlyFloatArrayBuffer buf = new ReadOnlyFloatArrayBuffer(other
- .capacity(), other.backingArray, other.offset);
- buf.limit = other.limit();
- buf.position = other.position();
- buf.mark = markOfOther;
- return buf;
- }
-
- ReadOnlyFloatArrayBuffer(int capacity, float[] backingArray, int arrayOffset) {
- super(capacity, backingArray, arrayOffset);
- }
-
- public FloatBuffer asReadOnlyBuffer() {
- return duplicate();
- }
-
- public FloatBuffer compact() {
- throw new ReadOnlyBufferException();
- }
-
- public FloatBuffer duplicate() {
- return copy(this, mark);
- }
-
- public boolean isReadOnly() {
- return true;
- }
-
- protected float[] protectedArray() {
- throw new ReadOnlyBufferException();
- }
-
- protected int protectedArrayOffset() {
- throw new ReadOnlyBufferException();
- }
-
- protected boolean protectedHasArray() {
- return false;
- }
-
- public FloatBuffer put(float c) {
- throw new ReadOnlyBufferException();
- }
-
- public FloatBuffer put(int index, float c) {
- throw new ReadOnlyBufferException();
- }
-
+ static ReadOnlyFloatArrayBuffer copy(FloatArrayBuffer other, int markOfOther) {
+ ReadOnlyFloatArrayBuffer buf = new ReadOnlyFloatArrayBuffer(other
+ .capacity(), other.backingArray, other.offset);
+ buf.limit = other.limit();
+ buf.position = other.position();
+ buf.mark = markOfOther;
+ return buf;
+ }
+
+ ReadOnlyFloatArrayBuffer(int capacity, float[] backingArray, int arrayOffset) {
+ super(capacity, backingArray, arrayOffset);
+ }
+
+ @Override
+ public FloatBuffer asReadOnlyBuffer() {
+ return duplicate();
+ }
+
+ @Override
+ public FloatBuffer compact() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public FloatBuffer duplicate() {
+ return copy(this, mark);
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ @Override
+ protected float[] protectedArray() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ protected int protectedArrayOffset() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ protected boolean protectedHasArray() {
+ return false;
+ }
+
+ @Override
+ public FloatBuffer put(float c) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public FloatBuffer put(int index, float c) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
public FloatBuffer put(FloatBuffer buf) {
throw new ReadOnlyBufferException();
}
+ @Override
public final FloatBuffer put(float[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
- public FloatBuffer slice() {
- return new ReadOnlyFloatArrayBuffer(remaining(), backingArray, offset
- + position);
- }
+
+ @Override
+ public FloatBuffer slice() {
+ return new ReadOnlyFloatArrayBuffer(remaining(), backingArray, offset
+ + position);
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyHeapByteBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyHeapByteBuffer.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyHeapByteBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyHeapByteBuffer.java Sat Sep 22 14:24:54 2007
@@ -31,108 +31,130 @@
*/
final class ReadOnlyHeapByteBuffer extends HeapByteBuffer {
- static ReadOnlyHeapByteBuffer copy(HeapByteBuffer other, int markOfOther) {
- ReadOnlyHeapByteBuffer buf = new ReadOnlyHeapByteBuffer(
- other.backingArray, other.capacity(), other.offset);
- buf.limit = other.limit();
- buf.position = other.position();
- buf.mark = markOfOther;
- buf.order(other.order());
- return buf;
- }
-
- ReadOnlyHeapByteBuffer(byte[] backingArray, int capacity, int arrayOffset) {
- super(backingArray, capacity, arrayOffset);
- }
-
- public ByteBuffer asReadOnlyBuffer() {
- return copy(this, mark);
- }
-
- public ByteBuffer compact() {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer duplicate() {
- return copy(this, mark);
- }
-
- public boolean isReadOnly() {
- return true;
- }
-
- protected byte[] protectedArray() {
- throw new ReadOnlyBufferException();
- }
-
- protected int protectedArrayOffset() {
- throw new ReadOnlyBufferException();
- }
-
- protected boolean protectedHasArray() {
- return false;
- }
-
- public ByteBuffer put(byte b) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer put(int index, byte b) {
- throw new ReadOnlyBufferException();
- }
+ static ReadOnlyHeapByteBuffer copy(HeapByteBuffer other, int markOfOther) {
+ ReadOnlyHeapByteBuffer buf = new ReadOnlyHeapByteBuffer(
+ other.backingArray, other.capacity(), other.offset);
+ buf.limit = other.limit();
+ buf.position = other.position();
+ buf.mark = markOfOther;
+ buf.order(other.order());
+ return buf;
+ }
+
+ ReadOnlyHeapByteBuffer(byte[] backingArray, int capacity, int arrayOffset) {
+ super(backingArray, capacity, arrayOffset);
+ }
+
+ @Override
+ public ByteBuffer asReadOnlyBuffer() {
+ return copy(this, mark);
+ }
+
+ @Override
+ public ByteBuffer compact() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer duplicate() {
+ return copy(this, mark);
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ @Override
+ protected byte[] protectedArray() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ protected int protectedArrayOffset() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ protected boolean protectedHasArray() {
+ return false;
+ }
+
+ @Override
+ public ByteBuffer put(byte b) {
+ throw new ReadOnlyBufferException();
+ }
+ @Override
+ public ByteBuffer put(int index, byte b) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
public ByteBuffer put(byte[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
- public ByteBuffer putDouble(double value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putDouble(int index, double value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putFloat(float value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putFloat(int index, float value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putInt(int value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putInt(int index, int value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putLong(int index, long value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putLong(long value) {
- throw new ReadOnlyBufferException();
- }
-
- public ByteBuffer putShort(int index, short value) {
- throw new ReadOnlyBufferException();
- }
+ @Override
+ public ByteBuffer putDouble(double value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putDouble(int index, double value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putFloat(float value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putFloat(int index, float value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putInt(int value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putInt(int index, int value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putLong(int index, long value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putLong(long value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ByteBuffer putShort(int index, short value) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
public ByteBuffer putShort(short value) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public ByteBuffer put(ByteBuffer buf) {
throw new ReadOnlyBufferException();
}
- public ByteBuffer slice() {
- ReadOnlyHeapByteBuffer slice = new ReadOnlyHeapByteBuffer(backingArray,
- remaining(), offset + position);
- slice.order = order;
- return slice;
- }
+ @Override
+ public ByteBuffer slice() {
+ ReadOnlyHeapByteBuffer slice = new ReadOnlyHeapByteBuffer(backingArray,
+ remaining(), offset + position);
+ slice.order = order;
+ return slice;
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java Sat Sep 22 14:24:54 2007
@@ -31,66 +31,78 @@
*/
final class ReadOnlyIntArrayBuffer extends IntArrayBuffer {
- static ReadOnlyIntArrayBuffer copy(IntArrayBuffer other, int markOfOther) {
- ReadOnlyIntArrayBuffer buf = new ReadOnlyIntArrayBuffer(other
- .capacity(), other.backingArray, other.offset);
- buf.limit = other.limit();
- buf.position = other.position();
- buf.mark = markOfOther;
- return buf;
- }
-
- ReadOnlyIntArrayBuffer(int capacity, int[] backingArray, int arrayOffset) {
- super(capacity, backingArray, arrayOffset);
- }
-
- public IntBuffer asReadOnlyBuffer() {
- return duplicate();
- }
-
- public IntBuffer compact() {
- throw new ReadOnlyBufferException();
- }
-
- public IntBuffer duplicate() {
- return copy(this, mark);
- }
-
- public boolean isReadOnly() {
- return true;
- }
-
- protected int[] protectedArray() {
- throw new ReadOnlyBufferException();
- }
-
- protected int protectedArrayOffset() {
- throw new ReadOnlyBufferException();
- }
-
- protected boolean protectedHasArray() {
- return false;
- }
-
- public IntBuffer put(int c) {
- throw new ReadOnlyBufferException();
- }
-
- public IntBuffer put(int index, int c) {
- throw new ReadOnlyBufferException();
- }
-
+ static ReadOnlyIntArrayBuffer copy(IntArrayBuffer other, int markOfOther) {
+ ReadOnlyIntArrayBuffer buf = new ReadOnlyIntArrayBuffer(other
+ .capacity(), other.backingArray, other.offset);
+ buf.limit = other.limit();
+ buf.position = other.position();
+ buf.mark = markOfOther;
+ return buf;
+ }
+
+ ReadOnlyIntArrayBuffer(int capacity, int[] backingArray, int arrayOffset) {
+ super(capacity, backingArray, arrayOffset);
+ }
+
+ @Override
+ public IntBuffer asReadOnlyBuffer() {
+ return duplicate();
+ }
+
+ @Override
+ public IntBuffer compact() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public IntBuffer duplicate() {
+ return copy(this, mark);
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ @Override
+ protected int[] protectedArray() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ protected int protectedArrayOffset() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ protected boolean protectedHasArray() {
+ return false;
+ }
+
+ @Override
+ public IntBuffer put(int c) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public IntBuffer put(int index, int c) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
public IntBuffer put(IntBuffer buf) {
throw new ReadOnlyBufferException();
}
+ @Override
public final IntBuffer put(int[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
- public IntBuffer slice() {
- return new ReadOnlyIntArrayBuffer(remaining(), backingArray, offset
- + position);
- }
+
+ @Override
+ public IntBuffer slice() {
+ return new ReadOnlyIntArrayBuffer(remaining(), backingArray, offset
+ + position);
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyLongArrayBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyLongArrayBuffer.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyLongArrayBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyLongArrayBuffer.java Sat Sep 22 14:24:54 2007
@@ -31,66 +31,78 @@
*/
final class ReadOnlyLongArrayBuffer extends LongArrayBuffer {
- static ReadOnlyLongArrayBuffer copy(LongArrayBuffer other, int markOfOther) {
- ReadOnlyLongArrayBuffer buf = new ReadOnlyLongArrayBuffer(other
- .capacity(), other.backingArray, other.offset);
- buf.limit = other.limit();
- buf.position = other.position();
- buf.mark = markOfOther;
- return buf;
- }
-
- ReadOnlyLongArrayBuffer(int capacity, long[] backingArray, int arrayOffset) {
- super(capacity, backingArray, arrayOffset);
- }
-
- public LongBuffer asReadOnlyBuffer() {
- return duplicate();
- }
-
- public LongBuffer compact() {
- throw new ReadOnlyBufferException();
- }
-
- public LongBuffer duplicate() {
- return copy(this, mark);
- }
-
- public boolean isReadOnly() {
- return true;
- }
-
- protected long[] protectedArray() {
- throw new ReadOnlyBufferException();
- }
-
- protected int protectedArrayOffset() {
- throw new ReadOnlyBufferException();
- }
-
- protected boolean protectedHasArray() {
- return false;
- }
-
- public LongBuffer put(long c) {
- throw new ReadOnlyBufferException();
- }
-
- public LongBuffer put(int index, long c) {
- throw new ReadOnlyBufferException();
- }
-
+ static ReadOnlyLongArrayBuffer copy(LongArrayBuffer other, int markOfOther) {
+ ReadOnlyLongArrayBuffer buf = new ReadOnlyLongArrayBuffer(other
+ .capacity(), other.backingArray, other.offset);
+ buf.limit = other.limit();
+ buf.position = other.position();
+ buf.mark = markOfOther;
+ return buf;
+ }
+
+ ReadOnlyLongArrayBuffer(int capacity, long[] backingArray, int arrayOffset) {
+ super(capacity, backingArray, arrayOffset);
+ }
+
+ @Override
+ public LongBuffer asReadOnlyBuffer() {
+ return duplicate();
+ }
+
+ @Override
+ public LongBuffer compact() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public LongBuffer duplicate() {
+ return copy(this, mark);
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ @Override
+ protected long[] protectedArray() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ protected int protectedArrayOffset() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ protected boolean protectedHasArray() {
+ return false;
+ }
+
+ @Override
+ public LongBuffer put(long c) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public LongBuffer put(int index, long c) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
public LongBuffer put(LongBuffer buf) {
throw new ReadOnlyBufferException();
}
+ @Override
public final LongBuffer put(long[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
- public LongBuffer slice() {
- return new ReadOnlyLongArrayBuffer(remaining(), backingArray, offset
- + position);
- }
+
+ @Override
+ public LongBuffer slice() {
+ return new ReadOnlyLongArrayBuffer(remaining(), backingArray, offset
+ + position);
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyShortArrayBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyShortArrayBuffer.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyShortArrayBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadOnlyShortArrayBuffer.java Sat Sep 22 14:24:54 2007
@@ -31,66 +31,78 @@
*/
final class ReadOnlyShortArrayBuffer extends ShortArrayBuffer {
- static ReadOnlyShortArrayBuffer copy(ShortArrayBuffer other, int markOfOther) {
- ReadOnlyShortArrayBuffer buf = new ReadOnlyShortArrayBuffer(other
- .capacity(), other.backingArray, other.offset);
- buf.limit = other.limit();
- buf.position = other.position();
- buf.mark = markOfOther;
- return buf;
- }
-
- ReadOnlyShortArrayBuffer(int capacity, short[] backingArray, int arrayOffset) {
- super(capacity, backingArray, arrayOffset);
- }
-
- public ShortBuffer asReadOnlyBuffer() {
- return duplicate();
- }
-
- public ShortBuffer compact() {
- throw new ReadOnlyBufferException();
- }
-
- public ShortBuffer duplicate() {
- return copy(this, mark);
- }
-
- public boolean isReadOnly() {
- return true;
- }
-
- protected short[] protectedArray() {
- throw new ReadOnlyBufferException();
- }
-
- protected int protectedArrayOffset() {
- throw new ReadOnlyBufferException();
- }
-
- protected boolean protectedHasArray() {
- return false;
- }
-
+ static ReadOnlyShortArrayBuffer copy(ShortArrayBuffer other, int markOfOther) {
+ ReadOnlyShortArrayBuffer buf = new ReadOnlyShortArrayBuffer(other
+ .capacity(), other.backingArray, other.offset);
+ buf.limit = other.limit();
+ buf.position = other.position();
+ buf.mark = markOfOther;
+ return buf;
+ }
+
+ ReadOnlyShortArrayBuffer(int capacity, short[] backingArray, int arrayOffset) {
+ super(capacity, backingArray, arrayOffset);
+ }
+
+ @Override
+ public ShortBuffer asReadOnlyBuffer() {
+ return duplicate();
+ }
+
+ @Override
+ public ShortBuffer compact() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ public ShortBuffer duplicate() {
+ return copy(this, mark);
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ @Override
+ protected short[] protectedArray() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ protected int protectedArrayOffset() {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
+ protected boolean protectedHasArray() {
+ return false;
+ }
+
+ @Override
public ShortBuffer put(ShortBuffer buf) {
throw new ReadOnlyBufferException();
}
- public ShortBuffer put(short c) {
- throw new ReadOnlyBufferException();
- }
-
- public ShortBuffer put(int index, short c) {
- throw new ReadOnlyBufferException();
- }
+ @Override
+ public ShortBuffer put(short c) {
+ throw new ReadOnlyBufferException();
+ }
+ @Override
+ public ShortBuffer put(int index, short c) {
+ throw new ReadOnlyBufferException();
+ }
+
+ @Override
public final ShortBuffer put(short[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
- public ShortBuffer slice() {
- return new ReadOnlyShortArrayBuffer(remaining(), backingArray, offset
- + position);
- }
+
+ @Override
+ public ShortBuffer slice() {
+ return new ReadOnlyShortArrayBuffer(remaining(), backingArray, offset
+ + position);
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadWriteCharArrayBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadWriteCharArrayBuffer.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadWriteCharArrayBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadWriteCharArrayBuffer.java Sat Sep 22 14:24:54 2007
@@ -30,92 +30,103 @@
*/
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;
- }
+ 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);
+ }
+
+ @Override
+ public CharBuffer asReadOnlyBuffer() {
+ return ReadOnlyCharArrayBuffer.copy(this, mark);
+ }
+
+ @Override
+ public CharBuffer compact() {
+ System.arraycopy(backingArray, position + offset, backingArray, offset,
+ remaining());
+ position = limit - position;
+ limit = capacity;
+ mark = UNSET_MARK;
+ return this;
+ }
+
+ @Override
+ public CharBuffer duplicate() {
+ return copy(this, mark);
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return false;
+ }
+
+ @Override
+ protected char[] protectedArray() {
+ return backingArray;
+ }
+
+ @Override
+ protected int protectedArrayOffset() {
+ return offset;
+ }
+
+ @Override
+ protected boolean protectedHasArray() {
+ return true;
+ }
+ @Override
+ public CharBuffer put(char c) {
+ if (position == limit) {
+ throw new BufferOverflowException();
+ }
+ backingArray[offset + position++] = c;
+ return this;
+ }
+
+ @Override
+ public CharBuffer put(int index, char c) {
+ if (index < 0 || index >= limit) {
+ throw new IndexOutOfBoundsException();
+ }
+ backingArray[offset + index] = c;
+ return this;
+ }
+
+ @Override
public CharBuffer put(char[] src, int off, int len) {
int length = src.length;
- if (off < 0 || len < 0 || (long)len + (long)off > length) {
+ if (off < 0 || len < 0 || (long) len + (long) off > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
- System.arraycopy(src, off, backingArray, offset+position, len);
+ System.arraycopy(src, off, backingArray, offset + position, len);
position += len;
return this;
}
-
- public CharBuffer slice() {
- return new ReadWriteCharArrayBuffer(remaining(), backingArray, offset
- + position);
- }
+
+ @Override
+ public CharBuffer slice() {
+ return new ReadWriteCharArrayBuffer(remaining(), backingArray, offset
+ + position);
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java Sat Sep 22 14:24:54 2007
@@ -33,67 +33,73 @@
*/
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);
- }
+ 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);
+ }
ReadWriteDirectByteBuffer(PlatformAddress address, int aCapacity,
int anOffset) {
super(new SafeAddress(address), aCapacity, anOffset);
}
-
- 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;
- }
-
- 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;
- }
+
+ @Override
+ public ByteBuffer asReadOnlyBuffer() {
+ return ReadOnlyDirectByteBuffer.copy(this, mark);
+ }
+
+ @Override
+ public ByteBuffer compact() {
+ PlatformAddress effectiveAddress = getEffectiveAddress();
+ effectiveAddress.offsetBytes(position).moveTo(effectiveAddress,
+ remaining());
+ position = limit - position;
+ limit = capacity;
+ mark = UNSET_MARK;
+ return this;
+ }
+
+ @Override
+ public ByteBuffer duplicate() {
+ return copy(this, mark);
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return false;
+ }
+
+ @Override
+ public ByteBuffer put(byte value) {
+ if (position == limit) {
+ throw new BufferOverflowException();
+ }
+ getBaseAddress().setByte(offset + position++, value);
+ return this;
+ }
+
+ @Override
+ public ByteBuffer put(int index, byte value) {
+ if (index < 0 || index >= limit) {
+ throw new IndexOutOfBoundsException();
+ }
+ getBaseAddress().setByte(offset + index, value);
+ return this;
+ }
/*
* Override ByteBuffer.put(byte[], int, int) to improve performance.
@@ -102,9 +108,10 @@
*
* @see java.nio.ByteBuffer#put(byte[], int, int)
*/
+ @Override
public ByteBuffer put(byte[] src, int off, int len) {
int length = src.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
@@ -113,107 +120,117 @@
if (isReadOnly()) {
throw new ReadOnlyBufferException();
}
- getBaseAddress().setByteArray(offset + position, src, off,
- len);
+ getBaseAddress().setByteArray(offset + position, src, off, len);
position += len;
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 || (long)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 || (long)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 || (long)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 || (long)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 || (long)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;
- }
+
+ @Override
+ 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;
+ }
+
+ @Override
+ public ByteBuffer putDouble(int index, double value) {
+ if (index < 0 || (long) index + 8 > limit) {
+ throw new IndexOutOfBoundsException();
+ }
+ getBaseAddress().setDouble(offset + index, value, order);
+ return this;
+ }
+
+ @Override
+ 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;
+ }
+
+ @Override
+ public ByteBuffer putFloat(int index, float value) {
+ if (index < 0 || (long) index + 4 > limit) {
+ throw new IndexOutOfBoundsException();
+ }
+ getBaseAddress().setFloat(offset + index, value, order);
+ return this;
+ }
+
+ @Override
+ 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;
+ }
+
+ @Override
+ public ByteBuffer putInt(int index, int value) {
+ if (index < 0 || (long) index + 4 > limit) {
+ throw new IndexOutOfBoundsException();
+ }
+ getBaseAddress().setInt(offset + index, value, order);
+ return this;
+ }
+
+ @Override
+ 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;
+ }
+
+ @Override
+ public ByteBuffer putLong(int index, long value) {
+ if (index < 0 || (long) index + 8 > limit) {
+ throw new IndexOutOfBoundsException();
+ }
+ getBaseAddress().setLong(offset + index, value, order);
+ return this;
+ }
+
+ @Override
+ 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;
+ }
+
+ @Override
+ public ByteBuffer putShort(int index, short value) {
+ if (index < 0 || (long) index + 2 > limit) {
+ throw new IndexOutOfBoundsException();
+ }
+ getBaseAddress().setShort(offset + index, value, order);
+ return this;
+ }
+
+ @Override
+ public ByteBuffer slice() {
+ ReadWriteDirectByteBuffer buf = new ReadWriteDirectByteBuffer(
+ safeAddress, remaining(), offset + position);
+ buf.order = order;
+ return buf;
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadWriteDoubleArrayBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadWriteDoubleArrayBuffer.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadWriteDoubleArrayBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/ReadWriteDoubleArrayBuffer.java Sat Sep 22 14:24:54 2007
@@ -31,95 +31,105 @@
*/
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;
- }
+ 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);
+ }
+
+ @Override
+ public DoubleBuffer asReadOnlyBuffer() {
+ return ReadOnlyDoubleArrayBuffer.copy(this, mark);
+ }
+
+ @Override
+ public DoubleBuffer compact() {
+ System.arraycopy(backingArray, position + offset, backingArray, offset,
+ remaining());
+ position = limit - position;
+ limit = capacity;
+ mark = UNSET_MARK;
+ return this;
+ }
+
+ @Override
+ public DoubleBuffer duplicate() {
+ return copy(this, mark);
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return false;
+ }
+
+ @Override
+ protected double[] protectedArray() {
+ return backingArray;
+ }
+
+ @Override
+ protected int protectedArrayOffset() {
+ return offset;
+ }
+
+ @Override
+ protected boolean protectedHasArray() {
+ return true;
+ }
+ @Override
+ public DoubleBuffer put(double c) {
+ if (position == limit) {
+ throw new BufferOverflowException();
+ }
+ backingArray[offset + position++] = c;
+ return this;
+ }
+
+ @Override
+ public DoubleBuffer put(int index, double c) {
+ if (index < 0 || index >= limit) {
+ throw new IndexOutOfBoundsException();
+ }
+ backingArray[offset + index] = c;
+ return this;
+ }
+
+ @Override
public DoubleBuffer put(double[] src, int off, int len) {
int length = src.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
- throw new IndexOutOfBoundsException();
- }
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
+ throw new IndexOutOfBoundsException();
+ }
if (len > remaining()) {
throw new BufferOverflowException();
}
- System.arraycopy(src, off, backingArray, offset
- + position, len);
+ System.arraycopy(src, off, backingArray, offset + position, len);
position += len;
return this;
}
-
- public DoubleBuffer slice() {
- return new ReadWriteDoubleArrayBuffer(remaining(), backingArray, offset
- + position);
- }
+
+ @Override
+ public DoubleBuffer slice() {
+ return new ReadWriteDoubleArrayBuffer(remaining(), backingArray, offset
+ + position);
+ }
}