138 |
public ByteBuffer slice() |
public ByteBuffer slice() |
139 |
{ |
{ |
140 |
int rem = remaining(); |
int rem = remaining(); |
141 |
return new DirectByteBufferImpl |
if (isReadOnly()) |
142 |
|
return new DirectByteBufferImpl.ReadOnly |
143 |
(this, VMDirectByteBuffer.adjustAddress(address, position()), |
(this, VMDirectByteBuffer.adjustAddress(address, position()), |
144 |
rem, rem, 0, isReadOnly()); |
rem, rem, 0); |
145 |
|
else |
146 |
|
return new DirectByteBufferImpl.ReadWrite |
147 |
|
(this, VMDirectByteBuffer.adjustAddress(address, position()), |
148 |
|
rem, rem, 0); |
149 |
} |
} |
150 |
|
|
151 |
private ByteBuffer duplicate(boolean readOnly) |
private ByteBuffer duplicate(boolean readOnly) |
154 |
reset(); |
reset(); |
155 |
int mark = position(); |
int mark = position(); |
156 |
position(pos); |
position(pos); |
157 |
DirectByteBufferImpl result |
DirectByteBufferImpl result; |
158 |
= new DirectByteBufferImpl(this, address, capacity(), limit(), |
if (readOnly) |
159 |
pos, readOnly); |
result = new DirectByteBufferImpl.ReadOnly(this, address, capacity(), |
160 |
|
limit(), pos); |
161 |
|
else |
162 |
|
result = new DirectByteBufferImpl.ReadWrite(this, address, capacity(), |
163 |
|
limit(), pos); |
164 |
|
|
165 |
if (mark != pos) |
if (mark != pos) |
166 |
{ |
{ |
167 |
result.position(mark); |
result.position(mark); |