Package java.nio

Examples of java.nio.BufferUnderflowException


     * @param sliceSize the size of the slice
     * @return the buffer slice
     */
    public static IntBuffer slice(IntBuffer buffer, int sliceSize) {
        if (sliceSize > buffer.remaining() || sliceSize < -buffer.remaining()) {
            throw new BufferUnderflowException();
        }
        final int oldPos = buffer.position();
        final int oldLim = buffer.limit();
        if (sliceSize < 0) {
            // count from end (sliceSize is NEGATIVE)
View Full Code Here


     * @param count the number of ints to fill
     * @return the buffer instance
     */
    public static IntBuffer fill(IntBuffer buffer, int value, int count) {
        if (count > buffer.remaining()) {
            throw new BufferUnderflowException();
        }
        if (buffer.hasArray()) {
            final int offs = buffer.arrayOffset();
            Arrays.fill(buffer.array(), offs + buffer.position(), offs + buffer.limit(), value);
            skip(buffer, count);
View Full Code Here

     * @param sliceSize the size of the slice
     * @return the buffer slice
     */
    public static LongBuffer slice(LongBuffer buffer, int sliceSize) {
        if (sliceSize > buffer.remaining() || sliceSize < -buffer.remaining()) {
            throw new BufferUnderflowException();
        }
        final int oldPos = buffer.position();
        final int oldLim = buffer.limit();
        if (sliceSize < 0) {
            // count from end (sliceSize is NEGATIVE)
View Full Code Here

     * @param count the number of longs to fill
     * @return the buffer instance
     */
    public static LongBuffer fill(LongBuffer buffer, long value, int count) {
        if (count > buffer.remaining()) {
            throw new BufferUnderflowException();
        }
        if (buffer.hasArray()) {
            final int offs = buffer.arrayOffset();
            Arrays.fill(buffer.array(), offs + buffer.position(), offs + buffer.limit(), value);
            skip(buffer, count);
View Full Code Here

     * @param cnt the distantce to skip
     * @return the buffer instance
     */
    public static <T extends Buffer> T skip(T buffer, int cnt) {
        if (cnt > buffer.remaining()) {
            throw new BufferUnderflowException();
        }
        buffer.position(buffer.position() + cnt);
        return buffer;
    }
View Full Code Here

    /**
     * @see ByteBuffer#get()
     */
    public byte get() {
        if (!hasRemaining()) {
            throw new BufferUnderflowException();
        }

        return get(position);
    }
View Full Code Here

    /**
     * @see ByteBuffer#get(byte[], int,int)
     */
    public IoBuffer get(byte[] dst, int offset, int length) {
        if (remaining() < length) {
            throw new BufferUnderflowException();
        }
        int remainsToCopy = length;
        int currentOffset = offset;

        while (remainsToCopy > 0) {
View Full Code Here

        return getInt(getPointerByPosition(index));
    }

    private int getInt(Pointer pos) {
        if (pos.getPosition() > capacity - Integer.SIZE / Byte.SIZE) {
            throw new BufferUnderflowException();
        }

        int out = 0;
        for (int i = 0; i < Integer.SIZE; i += Byte.SIZE) {
            out |= (get(pos) & BYTE_MASK) << (bo == ByteOrder.BIG_ENDIAN ? (Integer.SIZE - Byte.SIZE) - i : i);
View Full Code Here

        return getLong(getPointerByPosition(index));
    }

    private long getLong(Pointer pos) {
        if (pos.getPosition() > capacity - Long.SIZE / Byte.SIZE) {
            throw new BufferUnderflowException();
        }

        long out = 0;
        for (int i = 0; i < Long.SIZE; i += Byte.SIZE) {
            out |= (get(pos) & BYTE_MASK_L) << (bo == ByteOrder.BIG_ENDIAN ? (Long.SIZE - Byte.SIZE) - i : i);
View Full Code Here

        return getShort(getPointerByPosition(index));
    }

    private short getShort(Pointer pos) {
        if (pos.getPosition() > capacity - Short.SIZE / Byte.SIZE) {
            throw new BufferUnderflowException();
        }
        if (bo == ByteOrder.BIG_ENDIAN) {
            return (short) ((get(pos) & BYTE_MASK) << Byte.SIZE | (get(pos) & BYTE_MASK));
        } else {
            return (short) ((get(pos) & BYTE_MASK) | (get(pos) & BYTE_MASK) << Byte.SIZE);
View Full Code Here

TOP

Related Classes of java.nio.BufferUnderflowException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.