FileDocCategorySizeDatePackage
ReadWriteHeapByteBuffer.javaAPI DocAndroid 1.5 API5909Wed May 06 22:41:04 BST 2009java.nio

ReadWriteHeapByteBuffer

public final class ReadWriteHeapByteBuffer extends HeapByteBuffer
HeapByteBuffer, ReadWriteHeapByteBuffer and ReadOnlyHeapByteBuffer compose the implementation of array based byte buffers.

ReadWriteHeapByteBuffer extends HeapByteBuffer with all the write methods.

This class is marked final for runtime performance.

Fields Summary
Constructors Summary
ReadWriteHeapByteBuffer(byte[] backingArray)

        super(backingArray);
    
ReadWriteHeapByteBuffer(int capacity)

        super(capacity);
    
ReadWriteHeapByteBuffer(byte[] backingArray, int capacity, int arrayOffset)

        super(backingArray, capacity, arrayOffset);
    
Methods Summary
public java.nio.ByteBufferasReadOnlyBuffer()

        return ReadOnlyHeapByteBuffer.copy(this, mark);
    
public java.nio.ByteBuffercompact()

        System.arraycopy(backingArray, position + offset, backingArray, offset,
                remaining());
        position = limit - position;
        limit = capacity;
        mark = UNSET_MARK;
        return this;
    
static java.nio.ReadWriteHeapByteBuffercopy(java.nio.HeapByteBuffer other, int markOfOther)

        ReadWriteHeapByteBuffer buf = new ReadWriteHeapByteBuffer(
                other.backingArray, other.capacity(), other.offset);
        buf.limit = other.limit();
        buf.position = other.position();
        buf.mark = markOfOther;
        buf.order(other.order());
        return buf;
    
public java.nio.ByteBufferduplicate()

        return copy(this, mark);
    
public booleanisReadOnly()

        return false;
    
protected byte[]protectedArray()

        return backingArray;
    
protected intprotectedArrayOffset()

        return offset;
    
protected booleanprotectedHasArray()

        return true;
    
public java.nio.ByteBufferput(byte b)

        if (position == limit) {
            throw new BufferOverflowException();
        }
        backingArray[offset + position++] = b;
        return this;
    
public java.nio.ByteBufferput(int index, byte b)

        if (index < 0 || index >= limit) {
            throw new IndexOutOfBoundsException();
        }
        backingArray[offset + index] = b;
        return this;
    
public java.nio.ByteBufferput(byte[] src, int off, int len)

        if (off < 0 || len < 0 || (long)off + (long)len > src.length) {
            throw new IndexOutOfBoundsException();
        }
        if (len > remaining()) {
            throw new BufferOverflowException();
        }
        if (isReadOnly()) {
            throw new ReadOnlyBufferException();
        }
        System.arraycopy(src, off, backingArray, offset
                + position, len);
        position += len;
        return this;
    
public java.nio.ByteBufferputDouble(double value)

        return putLong(Double.doubleToRawLongBits(value));
    
public java.nio.ByteBufferputDouble(int index, double value)

        return putLong(index, Double.doubleToRawLongBits(value));
    
public java.nio.ByteBufferputFloat(float value)

        return putInt(Float.floatToIntBits(value));
    
public java.nio.ByteBufferputFloat(int index, float value)

        return putInt(index, Float.floatToIntBits(value));
    
public java.nio.ByteBufferputInt(int value)

        int newPosition = position + 4;
        if (newPosition > limit) {
            throw new BufferOverflowException();
        }
        store(position, value);
        position = newPosition;
        return this;
    
public java.nio.ByteBufferputInt(int index, int value)

        if (index < 0 || (long)index + 4 > limit) {
            throw new IndexOutOfBoundsException();
        }
        store(index, value);
        return this;
    
public java.nio.ByteBufferputLong(int index, long value)

        if (index < 0 || (long)index + 8 > limit) {
            throw new IndexOutOfBoundsException();
        }
        store(index, value);
        return this;
    
public java.nio.ByteBufferputLong(long value)

        int newPosition = position + 8;
        if (newPosition > limit) {
            throw new BufferOverflowException();
        }
        store(position, value);
        position = newPosition;
        return this;
    
public java.nio.ByteBufferputShort(int index, short value)

        if (index < 0 || (long)index + 2 > limit) {
            throw new IndexOutOfBoundsException();
        }
        store(index, value);
        return this;
    
public java.nio.ByteBufferputShort(short value)

        int newPosition = position + 2;
        if (newPosition > limit) {
            throw new BufferOverflowException();
        }
        store(position, value);
        position = newPosition;
        return this;
    
public java.nio.ByteBufferslice()

        ReadWriteHeapByteBuffer slice = new ReadWriteHeapByteBuffer(
                backingArray, remaining(), offset + position);
        slice.order = order;
        return slice;