Commit b772d2f5 by Michael Koch Committed by Michael Koch

2003-03-11 Michael Koch <konqueror@gmx.de>

	* gnu/java/nio/ByteBufferImpl.java
	(putInt): Use limit() instead of limit.
	* gnu/java/nio/CharBufferImpl.java
	(slice): Fixed implementation.
	(subSequence): Better bounds checking.
	* gnu/java/nio/MappedByteFileBuffer.java:
	Import all needed classes directly.
	* java/nio/ByteBuffer.java
	(hashCode): New dummy method.
	* java/nio/CharBuffer.java
	(array_offset): New member variable.
	(hasArray): Fixed documentation.
	(arrayOffset): Return array_offset.

From-SVN: r64165
parent 37bd08f8
2003-03-11 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/ByteBufferImpl.java
(putInt): Use limit() instead of limit.
* gnu/java/nio/CharBufferImpl.java
(slice): Fixed implementation.
(subSequence): Better bounds checking.
* gnu/java/nio/MappedByteFileBuffer.java:
Import all needed classes directly.
* java/nio/ByteBuffer.java
(hashCode): New dummy method.
* java/nio/CharBuffer.java
(array_offset): New member variable.
(hasArray): Fixed documentation.
(arrayOffset): Return array_offset.
2003-03-10 2003-02-27 Mohan Embar <gnustuff@thisiscool.com> 2003-03-10 2003-02-27 Mohan Embar <gnustuff@thisiscool.com>
* include/jvm.h: removed declaration of _Jv_ThisExecutable() * include/jvm.h: removed declaration of _Jv_ThisExecutable()
......
...@@ -320,7 +320,7 @@ public final class ByteBufferImpl extends ByteBuffer ...@@ -320,7 +320,7 @@ public final class ByteBufferImpl extends ByteBuffer
if (readOnly) if (readOnly)
throw new ReadOnlyBufferException (); throw new ReadOnlyBufferException ();
nio_put_Short (this, position (), limit(), value); nio_put_Short (this, position (), limit (), value);
inc_pos (2); inc_pos (2);
return this; return this;
} }
...@@ -352,7 +352,7 @@ public final class ByteBufferImpl extends ByteBuffer ...@@ -352,7 +352,7 @@ public final class ByteBufferImpl extends ByteBuffer
if (readOnly) if (readOnly)
throw new ReadOnlyBufferException (); throw new ReadOnlyBufferException ();
nio_put_Int (this, position (), limit , value); nio_put_Int (this, position (), limit (), value);
inc_pos (4); inc_pos (4);
return this; return this;
} }
......
...@@ -98,7 +98,8 @@ public final class CharBufferImpl extends CharBuffer ...@@ -98,7 +98,8 @@ public final class CharBufferImpl extends CharBuffer
public CharBuffer slice() public CharBuffer slice()
{ {
return new CharBufferImpl (this); return new CharBufferImpl (backing_buffer, arrayOffset () + position (),
remaining ());
} }
public CharBuffer duplicate() public CharBuffer duplicate()
...@@ -125,9 +126,10 @@ public final class CharBufferImpl extends CharBuffer ...@@ -125,9 +126,10 @@ public final class CharBufferImpl extends CharBuffer
final public CharSequence subSequence (int start, int end) final public CharSequence subSequence (int start, int end)
{ {
if (start < 0 || if (start < 0
end > length () || || start > length ()
start > end) || end < start
|| end > length ())
throw new IndexOutOfBoundsException (); throw new IndexOutOfBoundsException ();
// No support for direct buffers yet. // No support for direct buffers yet.
......
...@@ -36,7 +36,15 @@ obligated to do so. If you do not wish to do so, delete this ...@@ -36,7 +36,15 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package gnu.java.nio; package gnu.java.nio;
import java.nio.*;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.nio.ShortBuffer;
import java.nio.MappedByteBuffer;
import java.io.IOException; import java.io.IOException;
final public class MappedByteFileBuffer final public class MappedByteFileBuffer
......
...@@ -247,6 +247,15 @@ public abstract class ByteBuffer extends Buffer implements Comparable ...@@ -247,6 +247,15 @@ public abstract class ByteBuffer extends Buffer implements Comparable
} }
/** /**
* Returns the current hash code of this buffer.
*/
public int hashCode()
{
// FIXME: Check what SUN calcs here
return super.hashCode();
}
/**
* Tells whether or not this buffer is equal to another object. * Tells whether or not this buffer is equal to another object.
*/ */
public boolean equals (Object obj) public boolean equals (Object obj)
......
...@@ -45,6 +45,7 @@ import gnu.java.nio.CharBufferImpl; ...@@ -45,6 +45,7 @@ import gnu.java.nio.CharBufferImpl;
public abstract class CharBuffer extends Buffer public abstract class CharBuffer extends Buffer
implements Comparable, CharSequence implements Comparable, CharSequence
{ {
protected int array_offset = 0;
protected char [] backing_buffer; protected char [] backing_buffer;
/** /**
...@@ -201,7 +202,7 @@ public abstract class CharBuffer extends Buffer ...@@ -201,7 +202,7 @@ public abstract class CharBuffer extends Buffer
} }
/** /**
* Tells wether this is buffer is backed by an array or not. * Tells wether this is buffer is backed by an accessible array or not.
*/ */
public final boolean hasArray () public final boolean hasArray ()
{ {
...@@ -242,7 +243,7 @@ public abstract class CharBuffer extends Buffer ...@@ -242,7 +243,7 @@ public abstract class CharBuffer extends Buffer
if (isReadOnly ()) if (isReadOnly ())
throw new ReadOnlyBufferException (); throw new ReadOnlyBufferException ();
return 0; return array_offset;
} }
/** /**
......
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