2004-11-24 Jeroen Frijters <address@bogus.example.com>
* java/nio/DirectByteBufferImpl.java (ReadOnly): New inner subclass. (ReadWrite): New inner subclass. (owner): Made final and private. (address): Made final. (DirectByteBufferImpl(int)): New constructor. (DirectByteBufferImpl(Object,RawData,int,int,int)): New constructor. (DirectByteBufferImpl(Object,RawData,int,int,int,boolean)): Removed. (allocate): Modified to instantiate ReadWrite subclass. (finalize): Fixed to only free the buffer, if we own it. (put): Removed read-only check. (slice, duplicate): Modified to instantiate appropriate subclass. (isReadOnly): Removed. * java/nio/MappedByteBufferImpl.java (slice, duplicate): Modified to instantiate appropriate DirectByteBufferImpl subclass. From-SVN: r91147
This commit is contained in:
parent
11dde1bb18
commit
b4345a57d8
3 changed files with 121 additions and 34 deletions
|
@ -138,9 +138,14 @@ final class MappedByteBufferImpl extends MappedByteBuffer
|
|||
public ByteBuffer slice()
|
||||
{
|
||||
int rem = remaining();
|
||||
return new DirectByteBufferImpl
|
||||
if (isReadOnly())
|
||||
return new DirectByteBufferImpl.ReadOnly
|
||||
(this, VMDirectByteBuffer.adjustAddress(address, position()),
|
||||
rem, rem, 0, isReadOnly());
|
||||
rem, rem, 0);
|
||||
else
|
||||
return new DirectByteBufferImpl.ReadWrite
|
||||
(this, VMDirectByteBuffer.adjustAddress(address, position()),
|
||||
rem, rem, 0);
|
||||
}
|
||||
|
||||
private ByteBuffer duplicate(boolean readOnly)
|
||||
|
@ -149,9 +154,14 @@ final class MappedByteBufferImpl extends MappedByteBuffer
|
|||
reset();
|
||||
int mark = position();
|
||||
position(pos);
|
||||
DirectByteBufferImpl result
|
||||
= new DirectByteBufferImpl(this, address, capacity(), limit(),
|
||||
pos, readOnly);
|
||||
DirectByteBufferImpl result;
|
||||
if (readOnly)
|
||||
result = new DirectByteBufferImpl.ReadOnly(this, address, capacity(),
|
||||
limit(), pos);
|
||||
else
|
||||
result = new DirectByteBufferImpl.ReadWrite(this, address, capacity(),
|
||||
limit(), pos);
|
||||
|
||||
if (mark != pos)
|
||||
{
|
||||
result.position(mark);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue