Package org.apache.mina.common

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


            buf = in;
            usingSessionBuffer = false;
        }

        for (;;) {
            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


        for (;;) {
            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.");
                }

                if (!buf.hasRemaining()) {
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

        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 buf = ByteBuffer.allocate(objectSize + 4, false);
        buf.putInt(objectSize);
        in.readFully(buf.array(), 4, objectSize);
        buf.position(0);
        buf.limit(objectSize + 4);

        Object answer = buf.getObject(classLoader);
        buf.release();
        return answer;
View Full Code Here

    public void writeObject(Object obj) throws IOException {
        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

            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 {
        out.writeBoolean(v);
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

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

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.