Package org.glassfish.grizzly

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


        if (bytes != null) {
            return bytes;
        }
        final Buffer b = content.getContent();
        final int origPos = b.position();
        bytes = new byte[b.remaining()];
        b.get(bytes);
        b.position(origPos);
        contentBytes.compareAndSet(null, bytes);
        return bytes;
    }
View Full Code Here


     * {@inheritDoc}
     */
    public String getResponseBodyExcerpt(int maxLength, String charset) throws IOException {
        charset = calculateCharset(charset);
        final Buffer responseBody = getResponseBody0();
        final int len = Math.min(responseBody.remaining(), maxLength);
        final int pos = responseBody.position();
        return responseBody.toStringContent(getCharset(charset), pos, len + pos);
    }

    /**
 
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public byte[] getResponseBodyAsBytes() throws IOException {
        final Buffer responseBody = getResponseBody0();
        final byte[] responseBodyBytes = new byte[responseBody.remaining()];
        final int origPos = responseBody.position();
        responseBody.get(responseBodyBytes);
        responseBody.position(origPos);
        return responseBodyBytes;
    }
View Full Code Here

     */
    @Override
    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;
            }
        }
View Full Code Here

     */
    @Override
    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;
            }
        }
View Full Code Here

     */
    @Override
    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;
            }
        }
View Full Code Here

     */
    @Override
    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;
            }
        }
View Full Code Here

     */
    @Override
    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;
            }
        }
View Full Code Here

     */
    @Override
    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;
            }
        }
View Full Code Here

        }
       
        arraySizeCheck(buffer.remaining());
        if (input.isBuffered()) {
            final Buffer inputBuffer = input.getBuffer();
            final int diff = buffer.remaining() - inputBuffer.remaining();
            if (diff >= 0) {
                buffer.put(inputBuffer);
            } else {
                final int save = inputBuffer.limit();
                inputBuffer.limit(save + diff);
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.