Commit 7318eb21 by Michael Koch Committed by Michael Koch

2003-08-02 Michael Koch <konqueror@gmx.de>

	* java/nio/ByteBufferImpl.java
	(getChar): Check remaining bytes, fixed comment about endianess.
	(putChar): Likewise.
	(getShort): Likewise.
	(putShort): Likewise.
	(getInt): Check remaining bytes, fixed conversion, fixed comment about
	endianess.
	(putInt): Likewise.
	(getLong): Likewise.
	(putLong): Likewise.
	(getFloat): Likewise.
	(putFloat): Likewise.
	(getDouble): Likewise.
	(putDouble): Likewise.
	* java/nio/DirectByteBufferImpl.java
	(getChar): Wrapped code, fixed comment about endianess.
	(putchar): Likewise.
	(getShort): Likewise.
	(putShort): Likewise.
	(getInt): Fixed conversion, fixed comment about endianess.
	(putInt): Likewise.
	(getLong): Likewise.
	(putLong): Likewise.
	(getFloat): Likewise.
	(putFloat): Likewise.
	(getDouble): Likewise.
	(putDouble): Likewise.
	* java/nio/MappedByteBufferImpl.java
	(compact): Implemented.
	(getChar): Implemented.
	(putChar): Implemented.
	(getDouble): Implemented.
	(putdouble): Implemented.
	(getFloat): Implemented.
	(putFloat): Implemented.
	(getInt): Implemented.
	(putInt): Implemented.
	(getLong): Implemented.
	(putLong): Implemented.
	(getShort): Implemented.
	(putShort): Implemented.
	* java/nio/channels/FileChannelImpl.java
	(read): Set position where to access file.
	(write): Likewise.
	(transferTo): Flip buffer after read and before write.
	(transferFrom): Likewise.

From-SVN: r70102
parent 29370796
2003-08-02 Michael Koch <konqueror@gmx.de>
* java/nio/ByteBufferImpl.java
(getChar): Check remaining bytes, fixed comment about endianess.
(putChar): Likewise.
(getShort): Likewise.
(putShort): Likewise.
(getInt): Check remaining bytes, fixed conversion, fixed comment about
endianess.
(putInt): Likewise.
(getLong): Likewise.
(putLong): Likewise.
(getFloat): Likewise.
(putFloat): Likewise.
(getDouble): Likewise.
(putDouble): Likewise.
* java/nio/DirectByteBufferImpl.java
(getChar): Wrapped code, fixed comment about endianess.
(putchar): Likewise.
(getShort): Likewise.
(putShort): Likewise.
(getInt): Fixed conversion, fixed comment about endianess.
(putInt): Likewise.
(getLong): Likewise.
(putLong): Likewise.
(getFloat): Likewise.
(putFloat): Likewise.
(getDouble): Likewise.
(putDouble): Likewise.
* java/nio/MappedByteBufferImpl.java
(compact): Implemented.
(getChar): Implemented.
(putChar): Implemented.
(getDouble): Implemented.
(putdouble): Implemented.
(getFloat): Implemented.
(putFloat): Implemented.
(getInt): Implemented.
(putInt): Implemented.
(getLong): Implemented.
(putLong): Implemented.
(getShort): Implemented.
(putShort): Implemented.
* java/nio/channels/FileChannelImpl.java
(read): Set position where to access file.
(write): Likewise.
(transferTo): Flip buffer after read and before write.
(transferFrom): Likewise.
2003-08-02 Michael Koch <konqueror@gmx.de>
* gnu/java/lang/ArrayHelper.java
(equalsArray): Reformated, added method documentation.
......
......@@ -102,7 +102,16 @@ public class MappedByteBufferImpl extends MappedByteBuffer
public ByteBuffer compact ()
{
throw new Error ("Not implemented");
int copied = 0;
while (remaining () > 0)
{
put (copied, get ());
copied++;
}
position (copied);
return this;
}
public boolean isDirect ()
......@@ -157,7 +166,9 @@ public class MappedByteBufferImpl extends MappedByteBuffer
public char getChar ()
{
throw new Error ("Not implemented");
char value = getChar (position());
position (position() + 2);
return value;
}
public char getChar (int index)
......@@ -167,7 +178,9 @@ public class MappedByteBufferImpl extends MappedByteBuffer
public ByteBuffer putChar (char value)
{
throw new Error ("Not implemented");
putChar (position(), value);
position (position() + 2);
return this;
}
public ByteBuffer putChar (int index, char value)
......@@ -177,7 +190,9 @@ public class MappedByteBufferImpl extends MappedByteBuffer
public double getDouble ()
{
throw new Error ("Not implemented");
double value = getDouble (position());
position (position() + 8);
return value;
}
public double getDouble (int index)
......@@ -187,7 +202,9 @@ public class MappedByteBufferImpl extends MappedByteBuffer
public ByteBuffer putDouble (double value)
{
throw new Error ("Not implemented");
putDouble (position(), value);
position (position() + 8);
return this;
}
public ByteBuffer putDouble (int index, double value)
......@@ -197,7 +214,9 @@ public class MappedByteBufferImpl extends MappedByteBuffer
public float getFloat ()
{
throw new Error ("Not implemented");
float value = getFloat (position ());
position (position() + 4);
return value;
}
public float getFloat (int index)
......@@ -207,7 +226,9 @@ public class MappedByteBufferImpl extends MappedByteBuffer
public ByteBuffer putFloat (float value)
{
throw new Error ("Not implemented");
putFloat (position(), value);
position (position() + 4);
return this;
}
public ByteBuffer putFloat (int index, float value)
......@@ -217,7 +238,9 @@ public class MappedByteBufferImpl extends MappedByteBuffer
public int getInt ()
{
throw new Error ("Not implemented");
int value = getInt (position());
position (position() + 8);
return value;
}
public int getInt (int index)
......@@ -227,7 +250,9 @@ public class MappedByteBufferImpl extends MappedByteBuffer
public ByteBuffer putInt (int value)
{
throw new Error ("Not implemented");
putInt (position(), value);
position (position() + 4);
return this;
}
public ByteBuffer putInt (int index, int value)
......@@ -237,7 +262,9 @@ public class MappedByteBufferImpl extends MappedByteBuffer
public long getLong ()
{
throw new Error ("Not implemented");
long value = getLong (position());
position (position() + 8);
return value;
}
public long getLong (int index)
......@@ -247,7 +274,9 @@ public class MappedByteBufferImpl extends MappedByteBuffer
public ByteBuffer putLong (long value)
{
throw new Error ("Not implemented");
putLong (position(), value);
position (position() + 8);
return this;
}
public ByteBuffer putLong (int index, long value)
......@@ -257,7 +286,9 @@ public class MappedByteBufferImpl extends MappedByteBuffer
public short getShort ()
{
throw new Error ("Not implemented");
short value = getShort (position());
position (position() + 2);
return value;
}
public short getShort (int index)
......@@ -267,7 +298,9 @@ public class MappedByteBufferImpl extends MappedByteBuffer
public ByteBuffer putShort (short value)
{
throw new Error ("Not implemented");
putShort (position(), value);
position (position() + 2);
return this;
}
public ByteBuffer putShort (int index, short value)
......
......@@ -146,6 +146,7 @@ public class FileChannelImpl extends FileChannel
long oldPosition;
oldPosition = implPosition ();
position (position);
result = implRead (dst);
implPosition (oldPosition);
......@@ -208,6 +209,7 @@ public class FileChannelImpl extends FileChannel
long oldPosition;
oldPosition = implPosition ();
position (position);
result = implWrite (src);
implPosition (oldPosition);
......@@ -298,6 +300,7 @@ public class FileChannelImpl extends FileChannel
// XXX: count needs to be casted from long to int. Dataloss ?
ByteBuffer buffer = ByteBuffer.allocate ((int) count);
read (buffer, position);
buffer.flip();
return target.write (buffer);
}
......@@ -317,6 +320,7 @@ public class FileChannelImpl extends FileChannel
// XXX: count needs to be casted from long to int. Dataloss ?
ByteBuffer buffer = ByteBuffer.allocate ((int) count);
src.read (buffer);
buffer.flip();
return write (buffer, position);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment