FileDocCategorySizeDatePackage
ShortBufferImpl.javaAPI DocphoneME MR2 API (J2ME)3455Wed May 02 18:00:48 BST 2007java.nio

ShortBufferImpl

public class ShortBufferImpl extends ShortBuffer
A Buffer storing short data.

Fields Summary
Constructors Summary
ShortBufferImpl(ByteBufferImpl parent, int capacity, short[] array, int arrayOffset, boolean isDirect)

        this.parent = parent;
	this.isDirect = isDirect;
	this.array = array;
	this.arrayOffset = arrayOffset;
	this.capacity = this.limit = capacity;
	this.position = 0;
    
Methods Summary
public voiddispose()

        // Need revisit
        this.disposed = true;
    
public shortget()

        if (position >= limit) {
            throw new BufferUnderflowException();
        }
	return get(position++);
    
public shortget(int index)

        if (index < 0 || index >= limit) {
            throw new IndexOutOfBoundsException();
        }

        int bytePtr = arrayOffset + (index << 1);
	if (isDirect) {
	    return ByteBufferImpl._getShort(bytePtr);
	} else if (array != null) {
	   return array[arrayOffset + index];
	} else {
            return parent.getShort(bytePtr);
	}
    
public booleanisDirect()

	return isDirect;
    
public intnativeAddress()

	return arrayOffset;
    
public java.nio.ShortBufferput(short s)

        if (position >= limit) {
            throw new BufferOverflowException();
        }
	return put(position++, s);
    
public java.nio.ShortBufferput(int index, short s)

        if (index < 0 || index >= limit) {
            throw new IndexOutOfBoundsException();
        }

        int bytePtr = arrayOffset + (index << 1);
	if (isDirect) {
	    ByteBufferImpl._putShort(bytePtr, s);
	} else if (array != null) {
	    array[arrayOffset + index] = s;
	} else {
            parent.putShort(bytePtr, s);
	}
	return this;
    
public java.nio.ShortBufferslice()

        int pos = position;
        if (isDirect) {
            pos <<= 1;
        }
        return new ShortBufferImpl(parent, limit - position, array,
                                   arrayOffset + pos,
                                   isDirect);