Package org.apache.mina.core.buffer

Examples of org.apache.mina.core.buffer.IoBuffer.position()


        // Loop until we don't have anymore byte in the buffer,
        // or until the decoder throws an unrecoverable exception or
        // can't decoder a message, because there are not enough
        // data in the buffer
        while (in.hasRemaining()) {
            int oldPos = in.position();
            try {
                synchronized (decoderOut) {
                    // Call the decoder with the read bytes
                    decoder.decode(session, in, decoderOut);
                }
View Full Code Here


                    pde = new ProtocolDecoderException(t);
                }
               
                if (pde.getHexdump() == null) {
                    // Generate a message hex dump
                    int curPos = in.position();
                    in.position(oldPos);
                    pde.setHexdump(in.getHexDump());
                    in.position(curPos);
                }
View Full Code Here

                }
               
                if (pde.getHexdump() == null) {
                    // Generate a message hex dump
                    int curPos = in.position();
                    in.position(oldPos);
                    pde.setHexdump(in.getHexDump());
                    in.position(curPos);
                }

                // Fire the exceptionCaught event.
View Full Code Here

                if (pde.getHexdump() == null) {
                    // Generate a message hex dump
                    int curPos = in.position();
                    in.position(oldPos);
                    pde.setHexdump(in.getHexDump());
                    in.position(curPos);
                }

                // Fire the exceptionCaught event.
                decoderOut.flush(nextFilter, session);
                nextFilter.exceptionCaught(session, pde);
View Full Code Here

                // Retry only if the type of the caught exception is
                // recoverable and the buffer position has changed.
                // We check buffer position additionally to prevent an
                // infinite loop.
                if (!(t instanceof RecoverableProtocolDecoderException) ||
                        (in.position() == oldPos)) {
                    break;
                }
            }
        }
    }
View Full Code Here

            buf.put((byte) 0x4);
            buf.put((byte) 0x1);
            buf.put((byte) 0x2);
            buf.put((byte) 0x3);
            buf.put((byte) 0x4);
            buf.position(2);
            buf.limit(5);

            assertEquals(4, buf.indexOf((byte) 0x1));
            assertEquals(-1, buf.indexOf((byte) 0x2));
            assertEquals(2, buf.indexOf((byte) 0x3));
View Full Code Here

                errorEncoder.encode( ( ErrorMessage ) message, buf.buf() );
            }
        }

        // mark position
        int pos = buf.position();

        // length is the data minus 4 bytes for the pre-pended length
        int recordLength = buf.position() - 4;

        // write the length
View Full Code Here

        // mark position
        int pos = buf.position();

        // length is the data minus 4 bytes for the pre-pended length
        int recordLength = buf.position() - 4;

        // write the length
        buf.rewind();
        buf.putInt( recordLength );
View Full Code Here

        // write the length
        buf.rewind();
        buf.putInt( recordLength );

        // set the position back before flipping the buffer
        buf.position( pos );
        buf.flip();

        out.write( buf );
    }
}
View Full Code Here

        Iterator<KeytabEntry> iterator = entries.iterator();

        while ( iterator.hasNext() )
        {
            IoBuffer entryBuffer = putKeytabEntry( iterator.next() );
            int size = entryBuffer.position();

            entryBuffer.flip();

            buffer.putInt( size );
            buffer.put( entryBuffer );
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.