Package org.glassfish.grizzly

Examples of org.glassfish.grizzly.Buffer.shrink()


                encoder.transform(connection, input);

        if (!input.hasRemaining()) {
            input.tryDispose();
        } else {
            input.shrink();
        }

        try {
            switch (result.getStatus()) {
                case COMPLETE:
View Full Code Here


        // Shift the position buffer
        final Buffer posBuffer = buffers[posBufferIndex];       
        final int diff = posBufferPosition - posBuffer.position();
        if (diff > 0) {
            posBuffer.position(posBufferPosition);
            posBuffer.shrink();
            shift += diff;
        }      
       
        setPosLim(position - shift, limit - shift);
        if (mark > position) mark = -1;
View Full Code Here

        // Shift the position buffer
        final Buffer posBuffer = buffers[posBufferIndex];       
        final int diff = posBufferPosition - posBuffer.position();
        if (diff > 0) {
            posBuffer.position(posBufferPosition);
            posBuffer.shrink();
            shift += diff;
        }      
       
        setPosLim(position - shift, limit - shift);
        if (mark > position) mark = -1;
View Full Code Here

    public char readChar()  throws IOException {
        if (input.isBuffered()) {
            final Buffer buffer = input.getBuffer();
            if (buffer != null && buffer.remaining() >= 2) {
                final char result = buffer.getChar();
                buffer.shrink();
                return result;
            }
        }

        return (char) ((readByte() & 0xff) << 8 | readByte() & 0xff);
View Full Code Here

    public short readShort() throws IOException {
        if (input.isBuffered()) {
            final Buffer buffer = input.getBuffer();
            if (buffer != null && buffer.remaining() >= 2) {
                final short result = buffer.getShort();
                buffer.shrink();
                return result;
            }
        }
       
        return (short) ((readByte() & 0xff) << 8 | readByte() & 0xff);
View Full Code Here

    public int readInt() throws IOException {
        if (input.isBuffered()) {
            final Buffer buffer = input.getBuffer();
            if (buffer != null && buffer.remaining() >= 4) {
                final int result = buffer.getInt();
                buffer.shrink();
                return result;
            }
        }
       
        return (readShort() & 0xffff) << 16 | readShort() & 0xffff;
View Full Code Here

    public long readLong() throws IOException {
        if (input.isBuffered()) {
            final Buffer buffer = input.getBuffer();
            if (buffer != null && buffer.remaining() >= 8) {
                final long result = buffer.getLong();
                buffer.shrink();
                return result;
            }
        }
       
        return (readInt() & 0xffffffffL) << 32 | readInt() & 0xffffffffL;
View Full Code Here

    final public float readFloat() throws IOException {
        if (input.isBuffered()) {
            final Buffer buffer = input.getBuffer();
            if (buffer != null && buffer.remaining() >= 4) {
                final float result = buffer.getFloat();
                buffer.shrink();
                return result;
            }
        }

        return Float.intBitsToFloat(readInt());
View Full Code Here

    final public double readDouble() throws IOException {
        if (input.isBuffered()) {
            final Buffer buffer = input.getBuffer();
            if (buffer != null && buffer.remaining() >= 8) {
                final double result = buffer.getDouble();
                buffer.shrink();
                return result;
            }
        }
       
        return Double.longBitsToDouble(readLong());
View Full Code Here

    public void readByteArray(byte[] data, int offset, int length) throws IOException {
        arraySizeCheck(length);
        if (input.isBuffered()) {
            final Buffer buffer = input.getBuffer();
            buffer.get(data, offset, length);
            buffer.shrink();
        } else {
            for(int i = offset; i < length; i++) {
                data[i] = input.read();
            }
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.