Package org.glassfish.grizzly

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


           
            GrizzlyChannel.removeChannelIfDisconnectd(connection);
            byte[] bytes = output.toByteArray();
            Buffer buffer = connection.getTransport().getMemoryManager().allocate(bytes.length);
            buffer.put(bytes);
            buffer.flip();
            buffer.allowBufferDispose(true);
            context.setMessage(buffer);
        } finally {
            GrizzlyChannel.removeChannelIfDisconnectd(connection);
        }
View Full Code Here


        final SSLConnectionContext.SslResult result =
                sslCtx.wrap(Buffers.EMPTY_BUFFER, buffer, HS_WRAP_ALLOCATOR);
       
        Buffer output = result.getOutput();
       
        output.flip();
        if (buffer != output) {
            if (buffer == netBuffer) {
                netBuffer.flip();
            }
        }
View Full Code Here

    static Buffer copy(final MemoryManager memoryManager,
            final Buffer buffer) {
        final Buffer tmpBuf = memoryManager.allocate(buffer.remaining());
        tmpBuf.put(buffer);

        return tmpBuf.flip();

    }
   
    static Buffer move(final MemoryManager memoryManager,
            final Buffer buffer) {
View Full Code Here

        } else {
            // if we can't write the chunk - buffer it.
            finishCurrentBuffer();
            final Buffer cloneBuffer = memoryManager.allocate(len);
            cloneBuffer.put(b, off, len);
            cloneBuffer.flip();
            checkCompositeBuffer();
           
            compositeBuffer.append(cloneBuffer);
        }
    }
View Full Code Here

        if (decState == Decoder.State.NEED_MORE_DATA
                || decodedBuffer == null) {
            return TransformationResult.createIncompletedResult(hasRemainder ? input : null);
        }

        return TransformationResult.createCompletedResult(decodedBuffer.flip(),
                hasRemainder ? input : null);
    }

    @Override
    protected LastResultAwareState<Buffer, Buffer> createStateObject() {
View Full Code Here

            output.putInt(byteRepresentation.length);
        }

        output.put(byteRepresentation);

        output.flip();
        output.allowBufferDispose(true);

        return TransformationResult.createCompletedResult(output, null);
    }
View Full Code Here

        final int length = remaining();
       
        if (!hasClonedArray) {
            buffer = memoryManager.allocate(length);
            buffer.put(heap, offset + pos, length);
            buffer.flip();
        } else {
            buffer = Buffers.wrap(memoryManager, heap, offset + pos, length);
        }

        buffer.allowBufferDispose(true);
View Full Code Here

            return ((WrapperAware) memoryManager).wrap(array, offset, length);
        }

        final Buffer buffer = memoryManager.allocate(length);
        buffer.put(array, offset, length);
        buffer.flip();
        return buffer;
    }

    /**
     * Returns {@link Buffer}, which wraps the {@link ByteBuffer}.
View Full Code Here

        }
       
        final Buffer clone = getDefaultMemoryManager().allocate(srcLength);
        clone.put(srcBuffer, position, srcLength);

        return clone.flip();
    }

    /**
     * Reads data from the {@link FileChannel} into the {@link Buffer}.
     *
 
View Full Code Here

                // Put GZIP member trailer
                final Buffer trailer = memoryManager.allocate(TRAILER_SIZE);
                final CRC32 crc32 = state.crc32;
                putUInt(trailer, (int) crc32.getValue());
                putUInt(trailer, deflater.getTotalIn());
                trailer.flip();

                resultBuffer = Buffers.appendBuffers(memoryManager,
                        resultBuffer, trailer);
            }
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.