Package org.apache.mina.core.buffer

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


                in.limit(oldLimit);
                in.position(pos);

                if (ctx.getOverflowPosition() == 0) {
                    IoBuffer buf = ctx.getBuffer();
                    buf.flip();
                    buf.limit(buf.limit() - matchCount);
                   
                    try {
                        writeText(session, buf.getString(ctx.getDecoder()), out);
                    } finally {
View Full Code Here


                    in.limit(oldLimit);
                    in.position(pos);
                   
                    if (ctx.getOverflowPosition() == 0) {
                        IoBuffer buf = ctx.getBuffer();
                        buf.flip();
                        buf.limit(buf.limit() - matchCount);
                       
                        try {
                            writeText(session, buf.getString(ctx.getDecoder()), out);
                        } finally {
View Full Code Here

            if (i == -1) {
                break;
            }
            ioBuf.put(buf, 0, i);
        }
        ioBuf.flip();
        reader.parse(ioBuf, CharsetUtil.UTF8_DECODER);
    }

}
View Full Code Here

        if (stanzaWriteInfo.isWriteProlog()) byteBuffer.putString(StanzaWriter.XML_PROLOG, getSessionEncoder());
        if (stanzaWriteInfo.isWriteOpeningElement()) byteBuffer.putString(renderer.getOpeningElement(), getSessionEncoder());
        if (stanzaWriteInfo.isWriteContent()) byteBuffer.putString(renderer.getElementContent(), getSessionEncoder());
        if (stanzaWriteInfo.isWriteClosingElement()) byteBuffer.putString(renderer.getClosingElement(), getSessionEncoder());

        byteBuffer.flip();
        protocolEncoderOutput.write(byteBuffer);
    }

    public void dispose(IoSession ioSession) throws Exception {
        logger.warn("unhandled StanzaWriterProtocolEncoder.dispose()");
View Full Code Here

        sess.getFilterChain().addLast("buffer", bFilter);

        IoBuffer data = IoBuffer.allocate(1);
        for (byte i = 0; i < 20; i++) {
            data.put((byte) (0x30 + i));
            data.flip();
            sess.write(data);
            data.clear();
        }

        // Add one more byte to overflow the final buffer
View Full Code Here

            data.clear();
        }

        // Add one more byte to overflow the final buffer
        data.put((byte) 0);
        data.flip();
        sess.write(data);
       
        // Flush the final byte
        bFilter.flush(sess);
       
View Full Code Here

        Charset charset = Charset.forName("UTF-8");
        buf.clear();
        buf.putString("hello", charset.newEncoder());
        buf.put((byte) 0);
        buf.flip();
        assertEquals("hello", buf.getString(charset.newDecoder()));

        buf.clear();
        buf.putString("hello", charset.newEncoder());
        buf.flip();
View Full Code Here

        buf.flip();
        assertEquals("hello", buf.getString(charset.newDecoder()));

        buf.clear();
        buf.putString("hello", charset.newEncoder());
        buf.flip();
        assertEquals("hello", buf.getString(charset.newDecoder()));

        decoder = Charset.forName("ISO-8859-1").newDecoder();
        buf.clear();
        buf.put((byte) 'A');
View Full Code Here

        buf.putShort((short) type);
        buf.putInt(message.getSequence());

        // Encode a body
        encodeBody(session, message, buf);
        buf.flip();
        out.write(buf);
    }

    protected abstract void encodeBody(IoSession session, T message, IoBuffer out);
}
View Full Code Here

    @Override
    public void write(int b) throws IOException {
        IoBuffer buf = IoBuffer.allocate(1);
        buf.put((byte) b);
        buf.flip();
        write(buf);
    }

    @Override
    public synchronized void flush() throws IOException {
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.