Package org.apache.mina.common

Examples of org.apache.mina.common.ByteBuffer.position()


                    // SSL encrypt
                    if (SessionLog.isDebugEnabled(session)) {
                        SessionLog.debug(session, " encrypt: " + buf);
                    }

                    int pos = buf.position();
                    handler.encrypt(buf.buf());
                    buf.position(pos);
                    ByteBuffer encryptedBuffer = new EncryptedBuffer(SSLHandler
                            .copy(handler.getOutNetBuffer()), buf);
View Full Code Here


                        SessionLog.debug(session, " encrypt: " + buf);
                    }

                    int pos = buf.position();
                    handler.encrypt(buf.buf());
                    buf.position(pos);
                    ByteBuffer encryptedBuffer = new EncryptedBuffer(SSLHandler
                            .copy(handler.getOutNetBuffer()), buf);

                    if (SessionLog.isDebugEnabled(session)) {
                        SessionLog.debug(session, " encrypted buf: "
View Full Code Here

    {
        ByteBuffer buf = ByteBuffer.allocate( 64, false );
        buf.setAutoExpand( true );
        buf.putObject( obj );
       
        int objectSize = buf.position() - 4;
        if( objectSize > maxObjectSize )
        {
            buf.release();
            throw new IllegalArgumentException( "The encoded object is too big: " + objectSize + " (> " + maxObjectSize + ')' );
        }
View Full Code Here

        {
            buf.release();
            throw new IllegalArgumentException( "The encoded object is too big: " + objectSize + " (> " + maxObjectSize + ')' );
        }
       
        out.write( buf.array(), 0, buf.position() );
        buf.release();
    }

    public void writeBoolean( boolean v ) throws IOException
    {
View Full Code Here

            buf = in;
        }
       
        for( ;; )
        {
            int oldPos = buf.position();
            boolean decoded = doDecode( session, buf, out );
            if( decoded )
            {
                if( buf.position() == oldPos )
                {
View Full Code Here

        {
            int oldPos = buf.position();
            boolean decoded = doDecode( session, buf, out );
            if( decoded )
            {
                if( buf.position() == oldPos )
                {
                    throw new IllegalStateException(
                            "doDecode() can't return true when buffer is not consumed." );
                }
               
View Full Code Here

        ByteBuffer buf = ByteBuffer.allocate( 64 );
        buf.setAutoExpand( true );
        buf.putObject( message );
       
        int objectSize = buf.position() - 4;
        if( objectSize > maxObjectSize )
        {
            buf.release();
            throw new IllegalArgumentException( "The encoded object is too big: " + objectSize + " (> " + maxObjectSize + ')' );
        }
View Full Code Here

        }
       
        String value = message.toString();
        ByteBuffer buf = ByteBuffer.allocate( value.length() ).setAutoExpand( true );
        buf.putString( value, encoder );
        if( buf.position() > maxLineLength )
        {
            throw new IllegalArgumentException( "Line length: " + buf.position() );
        }
        buf.putString( delimiter.getValue(), encoder );
        buf.flip();
View Full Code Here

        String value = message.toString();
        ByteBuffer buf = ByteBuffer.allocate( value.length() ).setAutoExpand( true );
        buf.putString( value, encoder );
        if( buf.position() > maxLineLength )
        {
            throw new IllegalArgumentException( "Line length: " + buf.position() );
        }
        buf.putString( delimiter.getValue(), encoder );
        buf.flip();
        out.write( buf );
    }
View Full Code Here

        ByteBuffer expectedBuf = ByteBuffer.allocate( DATA_SIZE * COUNT );
        for( int i = 0; i < COUNT; i ++ ) {
            expectedBuf.limit( ( i + 1 ) * DATA_SIZE );
            fillWriteBuffer( expectedBuf, i );
        }
        expectedBuf.position( 0 );
       
        assertEquals(expectedBuf, readBuf);
    }

    private void waitForResponse( EchoConnectorHandler handler, int bytes ) throws InterruptedException
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.