Package java.nio

Examples of java.nio.ByteBuffer.flip()


            if ( dataBuf.hasRemaining() )
            {
                DataChannel.nonBlockingRead( this._senderInfo.getChannel(), dataBuf );
            }

            dataBuf.flip();

            if ( log.isLoggable( Level.FINE ) )
            {
                byte[] tmp = new byte[dataBuf.remaining()];
                dataBuf.get( tmp );
View Full Code Here


                    else
                    {
                        // copy the bytebuffer
                        ByteBuffer tmp = ByteBufferAllocator.allocate( dataBuf.remaining() );
                        tmp.put( dataBuf );
                        tmp.flip();
                        result = dataChannel.decode( tmp );
                    }
                }
                catch ( Throwable t )
                {
View Full Code Here

                    dataBuf = (ByteBuffer) obj;
                }

                if ( dataBuf.position() > 0 )
                {
                    dataBuf.flip();
                }

                if ( log.isLoggable( Level.FINE ) )
                {
                    byte[] tmp = new byte[dataBuf.remaining()];
View Full Code Here

            if ( dataBuf.hasRemaining() )
            {
                DataChannel.nonBlockingRead( _channel, dataBuf );
            }

            dataBuf.flip();

            log
                    .log( Level.FINE,
                          "Response read. Now calling (de)serialize adapter to convert response back to object." );
View Full Code Here

                    else
                    {
                        // copy the bytebuffer
                        ByteBuffer tmp = ByteBufferAllocator.allocate( dataBuf.remaining() );
                        tmp.put( dataBuf );
                        tmp.flip();
                        result = tmp;
                    }

                    log.log( Level.FINE, "Server response successfully converted to object." );
                }
View Full Code Here

        else
        {
            ByteBuffer tmp = (ByteBuffer) obj;
            if ( tmp.position() > 0 )
            {
                tmp.flip();
            }
            IOUtil.writeDirect( Channels.newOutputStream( _channel ), tmp );
            result = IOUtil.readDirect( new ChannelInputStream( Channels.newInputStream( _channel ) ) );
        }
View Full Code Here

            lOut = new ByteBufferOutputStream();
            lOut.write( IOUtil.encodeToBytes( toHeaderString(), CHARSET ) );
            ByteBuffer buffer = this._out.getBackingBuffer();
            int pos = buffer.position();
            int limit = buffer.limit();
            buffer.flip();
            lOut.write( buffer );
            result = lOut.getBackingBuffer();
            result.flip();
            buffer.limit( limit );
            buffer.position( pos );
View Full Code Here

                else
                {
                    ByteBuffer tmp = (ByteBuffer) this._receiverInfo.getAttachment();
                    if ( tmp.position() > 0 )
                    {
                        tmp.flip();
                    }
                    dataBuf = tmp.duplicate();
                    ByteBufferAllocator.collect( tmp );
                }
View Full Code Here

        else
        {
            ByteBuffer tmp = (ByteBuffer) this._receiverInfo.getAttachment();
            if ( tmp.position() > 0 )
            {
                tmp.flip();
            }
            IOUtil.writeDirect( Channels.newOutputStream( this._receiverInfo.getChannel() ), tmp );
        }

        log.log( Level.FINE, "Server response sent." );
View Full Code Here

        buf.putInt( length );
        if ( adapterArr != null )
        {
            buf.put( adapterArr );
        }
        buf.flip();

        return buf;
    }

    /**
 
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.