@Override public int forEachByte(ByteBufProcessor processor) { int ret = buffer.forEachByte(processor); if (ret < 0) { throw REPLAY; } else { return ret; } }
/** * 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; }
@Override public int forEachByte(ByteBufProcessor processor) { int ret = buffer.forEachByte(processor); if (ret < 0) { throw REPLAY; } else { return ret; } }
/** * 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; }
@Override public int forEachByte(ByteBufProcessor processor) { return buf.forEachByte(processor); }
@Override public int forEachByte(int index, int length, ByteBufProcessor processor) { return buf.forEachByte(index, length, processor); }
public void check(ByteBuf buffer) { checking = true; buffer.forEachByte(this); }
/** * Finds the position of the correct closing character, taking into account the fact that before the correct one, * other sub section with same opening and closing characters can be encountered. * * @param buf the {@link ByteBuf} where to search for the end of a section enclosed in openingChar and closingChar. * @param openingChar the section opening char, used to detect a sub-section. * @param closingChar the section closing char, used to detect the end of a sub-section / this section. * @return */ private static int findSectionClosingPosition(ByteBuf buf, char openingChar, char closingChar) { return buf.forEachByte(new ClosingPositionBufProcessor(openingChar, closingChar, true)); }
/** * Finds the position of the split character, taking into account the fact that the character * could be found escaped in strings (such occurrences are ignored). * * This implementation starts for the current {@link ByteBuf#readerIndex() readerIndex}. * * @param buf the {@link ByteBuf} where to search for the split character. * @param splitChar the split character to detect. * @return the split character position or -1 if not found. */ public static final int findSplitPosition(ByteBuf buf, char splitChar) { return buf.forEachByte(new SplitPositionBufProcessor(splitChar, true)); }
@Override public int forEachByte(int index, int length, ByteBufProcessor processor) { return unwrap().forEachByte(index, length, processor); }
/** * Finds the position of the correct closing character, taking into account the fact that before the correct one, * other sub section with same opening and closing characters can be encountered. * * @param buf the {@link ByteBuf} where to search for the end of a section enclosed in openingChar and closingChar. * @param openingChar the section opening char, used to detect a sub-section. * @param closingChar the section closing char, used to detect the end of a sub-section / this section. * @return */ private static int findSectionClosingPosition(ByteBuf buf, char openingChar, char closingChar) { return buf.forEachByte(new ClosingPositionBufProcessor(openingChar, closingChar, true)); }
@Override public int forEachByte(int index, int length, ByteBufProcessor processor) { return unwrap().forEachByte(index, length, processor); }
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 IndexOfProcessor(value)); }
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 IndexOfProcessor(value)); }
public AppendableCharSequence parse(ByteBuf buffer) { final int oldSize = size; seq.reset(); int i = buffer.forEachByte(this); if (i == -1) { size = oldSize; return null; } buffer.readerIndex(i + 1); return seq; }
public AppendableCharSequence parse(ByteBuf buffer) { final int oldSize = size; seq.reset(); int i = buffer.forEachByte(this); if (i == -1) { size = oldSize; return null; } buffer.readerIndex(i + 1); return seq; }
@Override public int forEachByte(int index, int length, ByteBufProcessor processor) { checkIndex0(index, length); int ret = unwrap().forEachByte(idx(index), length, processor); if (ret >= adjustment) { return ret - adjustment; } else { return -1; } }
@Override public int forEachByte(int index, int length, ByteBufProcessor processor) { checkIndex0(index, length); int ret = unwrap().forEachByte(idx(index), length, processor); if (ret >= adjustment) { return ret - adjustment; } else { return -1; } }
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; } }
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; } }