private static int findDotAtBeginningOfLine(ByteBuf buffer, int startAt, byte[] previousBytes) { int length = buffer.readableBytes(); if (previousBytes[0] == CR && previousBytes[1] == LF && buffer.getByte(startAt) == DOT) { return startAt; } if (previousBytes[1] == CR && length >= 2 && buffer.getByte(startAt) == LF && buffer.getByte(startAt + 1) == DOT) { return startAt + 1; } int i = startAt; while (++i < length) { i = buffer.forEachByte(i, length - i, ByteProcessor.FIND_LF); if (i == -1) { return -1; } if (buffer.getByte(i - 1) == CR) { if (i + 1 < length && buffer.getByte(i + 1) == DOT) { return i + 1; } else { continue; } } } return -1; }
/** * Returns the index in the buffer of the end of line found. * Returns -1 if no end of line was found in the buffer. */ private static int findEndOfLine(final ByteBuf buffer) { int i = buffer.forEachByte(ByteProcessor.FIND_LF); if (i > 0 && buffer.getByte(i - 1) == '\r') { i--; } return i; }
@Override public int forEachByteDesc(final int n, final int n2, final ByteProcessor byteProcessor) { if ((n + n2) > this.buffer.writerIndex()) { throw EOF; } return this.buffer.forEachByteDesc(n, n2, byteProcessor); }
private static int findEndOfLine(final ByteBuf buffer) { int i = buffer.forEachByte(ByteProcessor.FIND_CRLF); if (i > 0 && buffer.getByte(i - 1) == '\r') { i--; } return i; }
@Override public int forEachByte(ByteProcessor byteProcessor) { return handle.forEachByte(byteProcessor); }
@Override public int forEachByte(int i, int i1, ByteProcessor byteProcessor) { return handle.forEachByte(i, i1, byteProcessor); }
@Override public int forEachByteDesc(ByteProcessor byteProcessor) { return handle.forEachByteDesc(byteProcessor); }
@Override public int forEachByteDesc(int i, int i1, ByteProcessor byteProcessor) { return handle.forEachByteDesc(i, i1, byteProcessor); }
@Override public int forEachByte(ByteProcessor processor) { return buf.forEachByte(processor); }
@Override public int forEachByte(int index, int length, ByteProcessor processor) { return buf.forEachByte(index, length, processor); }
@Override public int forEachByteDesc(ByteProcessor processor) { return buf.forEachByteDesc(processor); }
@Override public int forEachByteDesc(int index, int length, ByteProcessor processor) { return buf.forEachByteDesc(index, length, processor); }
@Override public int forEachByte(final ByteProcessor byteProcessor) { return byteBuf.forEachByte(byteProcessor); }
@Override public int forEachByte(final int i, final int i1, final ByteProcessor byteProcessor) { return byteBuf.forEachByte(i, i1, byteProcessor); }
@Override public int forEachByteDesc(final ByteProcessor byteProcessor) { return byteBuf.forEachByteDesc(byteProcessor); }
@Override public int forEachByteDesc(final int i, final int i1, final ByteProcessor byteProcessor) { return byteBuf.forEachByteDesc(i, i1, byteProcessor); }
@Override public int forEachByte(final ByteProcessor bytebufprocessor) { return this.byteBuf.forEachByte(bytebufprocessor); }
@Override public int forEachByte(final int i, final int j, final ByteProcessor bytebufprocessor) { return this.byteBuf.forEachByte(i, j, bytebufprocessor); }
@Override public int forEachByteDesc(final ByteProcessor bytebufprocessor) { return this.byteBuf.forEachByteDesc(bytebufprocessor); }
@Override public int forEachByteDesc(final int i, final int j, final ByteProcessor bytebufprocessor) { return this.byteBuf.forEachByteDesc(i, j, bytebufprocessor); }
@Override public int forEachByteDesc(final ByteProcessor byteProcessor) { return this.buffer.forEachByteDesc(byteProcessor); }
@Override public int forEachByte(final ByteProcessor byteProcessor) { return this.buf.forEachByte(byteProcessor); }
@Override public int forEachByte(final int n, final int n2, final ByteProcessor byteProcessor) { return this.buf.forEachByte(n, n2, byteProcessor); }
@Override public int forEachByteDesc(final ByteProcessor byteProcessor) { return this.buf.forEachByteDesc(byteProcessor); }
@Override public int forEachByteDesc(final int n, final int n2, final ByteProcessor byteProcessor) { return this.buf.forEachByteDesc(n, n2, byteProcessor); }
@Override public int forEachByte(ByteProcessor byteProcessor) { return 0; }
@Override public int forEachByte(int i, int i1, ByteProcessor byteProcessor) { return 0; }
@Override public int forEachByteDesc(ByteProcessor byteProcessor) { return 0; }
@Override public int forEachByteDesc(int i, int i1, ByteProcessor byteProcessor) { return 0; }
@Override public int forEachByte(ByteProcessor processor) {return buf.forEachByte(processor);}
@Override public int forEachByte(int index, int length, ByteProcessor processor) {return buf.forEachByte(index, length, processor);}
@Override public int forEachByteDesc(ByteProcessor processor) {return buf.forEachByteDesc(processor);}
@Override public int forEachByteDesc(int index, int length, ByteProcessor processor) {return buf.forEachByteDesc(index, length, processor);}