Package net.gleamynode.netty.array

Examples of net.gleamynode.netty.array.ByteArray


    }

    @Override
    public void get(int index, ByteArray dst, int dstIndex, int length) {
        if (isReplaying()) {
            ByteArray src = (ByteArray) replay();
            if (src.length() != length) {
                throw new IllegalStateException("mismatching request");
            }
            src.get(0, dst, dstIndex, length);
        } else if (index < super.firstIndex() || dstIndex + length > dst.endIndex()) {
            throw new NoSuchElementException();
        } else if (index + length > super.endIndex()) {
            rewind();
        } else {
            ByteArray src = new HeapByteArray(length);
            super.get(index, src, 0, length);
            src.get(0, dst, dstIndex, length);
            record(src);
        }
    }
View Full Code Here


    }

    @Override
    public void get(int index, ByteBuffer dst) {
        if (isReplaying()) {
            ByteArray src = (ByteArray) replay();
            if (src.length() != dst.remaining()) {
                throw new IllegalStateException(
                        "mismatching request: dst.remaining() has been changed since rewind.");
            }
            src.get(0, dst);
        } else if (index < super.firstIndex()) {
            throw new NoSuchElementException();
        } else if (index + dst.remaining() > super.endIndex()) {
            rewind();
        } else {
            ByteArray src = new HeapByteArray(dst.remaining());
            super.get(index, src, 0, dst.remaining());
            src.get(0, dst);
            record(src);
        }
    }
View Full Code Here

        if (!(e.getMessage() instanceof ByteArray)) {
            context.sendUpstream(element);
            return;
        }

        ByteArray src = (ByteArray) e.getMessage();
        byte[] dst = new byte[src.length()];
        src.get(src.firstIndex(), dst);
        ChannelUtil.fireMessageReceived(context, e.getChannel(), new String(dst, charsetName));
    }
View Full Code Here

        if (!(m instanceof ByteArray)) {
            ctx.sendUpstream(e);
            return;
        }

        ByteArray input = (ByteArray) m;
        if (input.empty()) {
            return;
        }

        ReplayableByteArrayBuffer cumulation = this.cumulation;

        // Avoid CompositeByteArray index overflow.
        if (Integer.MAX_VALUE - cumulation.endIndex() < input.length()) {
            ReplayableByteArrayBuffer newCumulation = new ReplayableByteArrayBuffer();
            for (ByteArray component: cumulation) {
                newCumulation.unwrap().write(component);
            }
            this.cumulation = cumulation = newCumulation;
View Full Code Here

        }
        if (dataLen > maxObjectSize) {
            throw new StreamCorruptedException(
                    "data length too big: " + dataLen + " (max: " + maxObjectSize + ')');
        }
        ByteArray data = buffer.read(dataLen);
        return new CompactObjectInputStream(new ByteArrayInputStream(data)).readObject();
    }
View Full Code Here

        if (!(m instanceof ByteArray)) {
            ctx.sendUpstream(e);
            return;
        }

        ByteArray input = (ByteArray) m;
        if (input.empty()) {
            return;
        }

        CompositeByteArray cumulation = this.cumulation;

        // Avoid CompositeByteArray index overflow.
        if (Integer.MAX_VALUE - cumulation.endIndex() < input.length()) {
            CompositeByteArray newCumulation = new CompositeByteArray();
            for (ByteArray component: cumulation) {
                newCumulation.addLast(component);
            }
            this.cumulation = cumulation = newCumulation;
View Full Code Here

        if (delimiters.length == 0) {
            throw new IllegalArgumentException("empty delimiters");
        }
        this.delimiters = new ByteArray[delimiters.length];
        for (int i = 0; i < delimiters.length; i ++) {
            ByteArray d = delimiters[i];
            validateDelimiter(d);
            this.delimiters[i] = d;
        }
        this.maxFrameLength = maxFrameLength;
    }
View Full Code Here

            ChannelHandlerContext ctx, Channel channel, ByteArrayBuffer buffer) throws Exception {
        // Try all delimiters.
        for (ByteArray delim: delimiters) {
            int delimIndex = indexOf(buffer, delim);
            if (delimIndex > buffer.firstIndex()) {
                ByteArray frame = buffer.read(delimIndex - buffer.firstIndex());
                if (frame.length() > maxFrameLength) {
                    fail();
                }
                buffer.skip(delim.length());
                return frame;
            } else if (delimIndex == buffer.firstIndex()) {
View Full Code Here

        if (!(m instanceof ByteArray)) {
            ctx.sendUpstream(e);
            return;
        }

        ByteArray input = (ByteArray) m;
        if (input.empty()) {
            return;
        }

        CompositeByteArray cumulation = this.cumulation;

        // Avoid CompositeByteArray index overflow.
        if (Integer.MAX_VALUE - cumulation.endIndex() < input.length()) {
            CompositeByteArray newCumulation = new CompositeByteArray();
            for (ByteArray component: cumulation) {
                newCumulation.addLast(component);
            }
            this.cumulation = cumulation = newCumulation;
View Full Code Here

        if (delimiters.length == 0) {
            throw new IllegalArgumentException("empty delimiters");
        }
        this.delimiters = new ByteArray[delimiters.length];
        for (int i = 0; i < delimiters.length; i ++) {
            ByteArray d = delimiters[i];
            validateDelimiter(d);
            this.delimiters[i] = d;
        }
        this.maxFrameLength = maxFrameLength;
    }
View Full Code Here

TOP

Related Classes of net.gleamynode.netty.array.ByteArray

Copyright © 2018 www.massapicom. 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.