本文整理了Java中io.netty.buffer.ByteBuf.forEachByte()
方法的一些代码示例,展示了ByteBuf.forEachByte()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.forEachByte()
方法的具体详情如下:
包路径:io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:forEachByte
[英]Iterates over the specified area of this buffer with the specified processor in ascending order. (i.e. index, (index + 1), .. (index + length - 1))
[中]使用指定的处理器以升序遍历此缓冲区的指定区域。(即指数,(指数+1)。。(索引+长度-1))
代码示例来源:origin: netty/netty
/**
* Writes an array to the block.
* @param buffer The buffer to write
* @param offset The offset within the input data to write from
* @param length The number of bytes of input data to write
* @return The actual number of input bytes written. May be less than the number requested, or
* zero if the block is already full
*/
int write(final ByteBuf buffer, int offset, int length) {
int index = buffer.forEachByte(offset, length, writeProcessor);
return index == -1 ? length : index - offset;
}
代码示例来源:origin: netty/netty
/**
* Returns {@code true} if the specified {@link ByteBuf} starting at {@code index} with {@code length} is valid
* ASCII text, otherwise return {@code false}.
*
* @param buf The given {@link ByteBuf}.
* @param index The start index of the specified buffer.
* @param length The length of the specified buffer.
*/
private static boolean isAscii(ByteBuf buf, int index, int length) {
return buf.forEachByte(index, length, FIND_NON_ASCII) == -1;
}
代码示例来源:origin: netty/netty
@Override
public int forEachByte(ByteProcessor processor) {
int ret = buffer.forEachByte(processor);
if (ret < 0) {
throw REPLAY;
} else {
return ret;
}
}
代码示例来源:origin: netty/netty
@Override
public int forEachByte(ByteProcessor processor) {
return buf.forEachByte(processor);
}
代码示例来源:origin: netty/netty
@Override
public int forEachByte(ByteProcessor processor) {
return buf.forEachByte(processor);
}
代码示例来源:origin: netty/netty
@Override
public int forEachByte(int index, int length, ByteProcessor processor) {
return buf.forEachByte(index, length, processor);
}
代码示例来源:origin: netty/netty
@Override
public int forEachByte(int index, int length, ByteProcessor processor) {
return buf.forEachByte(index, length, processor);
}
代码示例来源:origin: redisson/redisson
@Override
public int forEachByte(ByteProcessor processor) {
int ret = buffer.forEachByte(processor);
if (ret < 0) {
throw REPLAY;
} else {
return ret;
}
}
代码示例来源:origin: netty/netty
@Override
public int forEachByte(int index, int length, ByteProcessor processor) {
final int writerIndex = buffer.writerIndex();
if (index >= writerIndex) {
throw REPLAY;
}
if (index <= writerIndex - length) {
return buffer.forEachByte(index, length, processor);
}
int ret = buffer.forEachByte(index, writerIndex - index, processor);
if (ret < 0) {
throw REPLAY;
} else {
return ret;
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public int indexOf(IntPredicate predicate, int fromIndex) {
Assert.notNull(predicate, "IntPredicate must not be null");
if (fromIndex < 0) {
fromIndex = 0;
}
else if (fromIndex >= this.byteBuf.writerIndex()) {
return -1;
}
int length = this.byteBuf.writerIndex() - fromIndex;
return this.byteBuf.forEachByte(fromIndex, length, predicate.negate()::test);
}
代码示例来源:origin: netty/netty
@Override
public int forEachByte(int index, int length, ByteProcessor processor) {
return unwrap().forEachByte(index, length, processor);
}
代码示例来源:origin: netty/netty
@Override
public int forEachByte(int index, int length, ByteProcessor processor) {
return unwrap().forEachByte(index, length, processor);
}
代码示例来源:origin: netty/netty
/**
* 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 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;
}
}
代码示例来源:origin: netty/netty
private static int firstIndexOf(ByteBuf buffer, int fromIndex, int toIndex, byte value) {
fromIndex = Math.max(fromIndex, 0);
if (fromIndex >= toIndex || buffer.capacity() == 0) {
return -1;
}
return buffer.forEachByte(fromIndex, toIndex - fromIndex, new ByteProcessor.IndexOfProcessor(value));
}
代码示例来源:origin: netty/netty
/**
* @see #update(byte[], int, int)
*/
public void update(ByteBuf b, int off, int len) {
if (b.hasArray()) {
update(b.array(), b.arrayOffset() + off, len);
} else {
b.forEachByte(off, len, updateProcessor);
}
}
代码示例来源:origin: netty/netty
ByteBuf decode(ByteBuf src, int off, int len, ByteBufAllocator allocator, Base64Dialect dialect) {
dest = allocator.buffer(decodedBufferSize(len)).order(src.order()); // Upper limit on size of output
decodabet = decodabet(dialect);
try {
src.forEachByte(off, len, this);
return dest.slice(0, outBuffPosn);
} catch (Throwable cause) {
dest.release();
PlatformDependent.throwException(cause);
return null;
}
}
代码示例来源:origin: netty/netty
@Override
public int forEachByte(int index, int length, ByteProcessor processor) {
checkIndex0(index, length);
int ret = unwrap().forEachByte(idx(index), length, processor);
if (ret >= adjustment) {
return ret - adjustment;
} else {
return -1;
}
}
代码示例来源:origin: redisson/redisson
/**
* @see #update(byte[], int, int)
*/
public void update(ByteBuf b, int off, int len) {
if (b.hasArray()) {
update(b.array(), b.arrayOffset() + off, len);
} else {
b.forEachByte(off, len, updateProcessor);
}
}
代码示例来源:origin: redisson/redisson
@Override
public int forEachByte(int index, int length, ByteProcessor processor) {
checkIndex0(index, length);
int ret = unwrap().forEachByte(idx(index), length, processor);
if (ret >= adjustment) {
return ret - adjustment;
} else {
return -1;
}
}
代码示例来源:origin: redisson/redisson
ByteBuf decode(ByteBuf src, int off, int len, ByteBufAllocator allocator, Base64Dialect dialect) {
dest = allocator.buffer(decodedBufferSize(len)).order(src.order()); // Upper limit on size of output
decodabet = decodabet(dialect);
try {
src.forEachByte(off, len, this);
return dest.slice(0, outBuffPosn);
} catch (Throwable cause) {
dest.release();
PlatformDependent.throwException(cause);
return null;
}
}
内容来源于网络,如有侵权,请联系作者删除!