Example usage for io.netty.buffer ByteBufProcessor process

List of usage examples for io.netty.buffer ByteBufProcessor process

Introduction

In this page you can find the example usage for io.netty.buffer ByteBufProcessor process.

Prototype

boolean process(byte value) throws Exception;

Source Link

Usage

From source file:net.tomp2p.storage.AlternativeCompositeByteBuf.java

License:Apache License

private int forEachByteAsc0(int index, int length, ByteBufProcessor processor) {
    if (processor == null) {
        throw new NullPointerException("processor");
    }//  w  w  w.  ja v a2s .c om

    if (length == 0) {
        return -1;
    }

    final int endIndex = index + length;
    int i = index;
    try {
        do {
            if (processor.process(getByte(i))) {
                i++;
            } else {
                return i;
            }
        } while (i < endIndex);
    } catch (Exception e) {
        PlatformDependent.throwException(e);
    }

    return -1;
}

From source file:net.tomp2p.storage.AlternativeCompositeByteBuf.java

License:Apache License

private int forEachByteDesc0(int index, int length, ByteBufProcessor processor) {
    if (processor == null) {
        throw new NullPointerException("processor");
    }/*from  w  w  w .ja  va2s  .  com*/

    if (length == 0) {
        return -1;
    }

    int i = index + length - 1;
    try {
        do {
            if (processor.process(getByte(i))) {
                i--;
            } else {
                return i;
            }
        } while (i >= index);
    } catch (Exception e) {
        PlatformDependent.throwException(e);
    }

    return -1;
}