Example usage for io.netty.util ByteProcessor FIND_LF

List of usage examples for io.netty.util ByteProcessor FIND_LF

Introduction

In this page you can find the example usage for io.netty.util ByteProcessor FIND_LF.

Prototype

ByteProcessor FIND_LF

To view the source code for io.netty.util ByteProcessor FIND_LF.

Click Source Link

Document

Aborts on a LF ('\n') .

Usage

From source file:com.heliosapm.streams.collector.groovy.ByteBufReaderSource.java

License:Apache License

/**
  * Returns the index in the buffer of the end of line found.
  * Returns -1 if no end of line was found in the buffer.
  *///from   w ww.  java 2 s .  c o  m
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;
}

From source file:io.lettuce.core.protocol.RedisStateMachine.java

License:Apache License

private int findLineEnd(ByteBuf buffer) {

    int index = buffer.forEachByte(ByteProcessor.FIND_LF);
    return (index > 0 && buffer.getByte(index - 1) == '\r') ? index : -1;
}

From source file:org.graylog2.inputs.transports.netty.LenientLineBasedFrameDecoder.java

License:Open Source License

/**
 * Returns the index in the buffer of the end of line found.
 * Returns -1 if no end of line was found in the buffer.
 *//*  w w  w .  j  a va2s  .c  o  m*/
private int findEndOfLine(final ByteBuf buffer) {
    int totalLength = buffer.readableBytes();
    int i = buffer.forEachByte(buffer.readerIndex() + offset, totalLength - offset, ByteProcessor.FIND_LF);
    if (i >= 0) {
        offset = 0;
        if (i > 0 && buffer.getByte(i - 1) == '\r') {
            i--;
        }
    } else {
        offset = totalLength;
    }
    return i;
}