@Override public CompositeByteBuf addComponent(ByteBuf buffer) { wrapped.addComponent(buffer); return this; }
@Override public CompositeByteBuf addComponent(int cIndex, ByteBuf buffer) { wrapped.addComponent(cIndex, buffer); return this; }
@Override public CompositeByteBuf addComponent(boolean increaseWriterIndex, ByteBuf buffer) { wrapped.addComponent(increaseWriterIndex, buffer); return this; }
@Override public CompositeByteBuf addComponent(boolean increaseWriterIndex, int cIndex, ByteBuf buffer) { wrapped.addComponent(increaseWriterIndex, cIndex, buffer); return this; }
/** * Add the given {@link ByteBuf}. * <p> * Be aware that this method does not increase the {@code writerIndex} of the {@link CompositeByteBuf}. * If you need to have it increased use {@link #addComponent(boolean, ByteBuf)}. * <p> * {@link ByteBuf#release()} ownership of {@code buffer} is transferred to this {@link CompositeByteBuf}. * @param buffer the {@link ByteBuf} to add. {@link ByteBuf#release()} ownership is transferred to this * {@link CompositeByteBuf}. */ public CompositeByteBuf addComponent(ByteBuf buffer) { return addComponent(false, buffer); }
/** * Add the given {@link ByteBuf} on the specific index. * <p> * Be aware that this method does not increase the {@code writerIndex} of the {@link CompositeByteBuf}. * If you need to have it increased use {@link #addComponent(boolean, int, ByteBuf)}. * <p> * {@link ByteBuf#release()} ownership of {@code buffer} is transferred to this {@link CompositeByteBuf}. * @param cIndex the index on which the {@link ByteBuf} will be added. * @param buffer the {@link ByteBuf} to add. {@link ByteBuf#release()} ownership is transferred to this * {@link CompositeByteBuf}. */ public CompositeByteBuf addComponent(int cIndex, ByteBuf buffer) { return addComponent(false, cIndex, buffer); }
@Override public CompositeByteBuf addComponent(ByteBuf buffer) { wrapped.addComponent(buffer); return this; }
@Override public CompositeByteBuf addComponent(int cIndex, ByteBuf buffer) { wrapped.addComponent(cIndex, buffer); return this; }
@Override public CompositeByteBuf addComponent(boolean increaseWriterIndex, int cIndex, ByteBuf buffer) { wrapped.addComponent(increaseWriterIndex, cIndex, buffer); return this; }
@Override public CompositeByteBuf addComponent(boolean increaseWriterIndex, ByteBuf buffer) { wrapped.addComponent(increaseWriterIndex, buffer); return this; }
/** * Add the given {@link ByteBuf}. * <p> * Be aware that this method does not increase the {@code writerIndex} of the {@link CompositeByteBuf}. * If you need to have it increased use {@link #addComponent(boolean, ByteBuf)}. * <p> * {@link ByteBuf#release()} ownership of {@code buffer} is transferred to this {@link CompositeByteBuf}. * @param buffer the {@link ByteBuf} to add. {@link ByteBuf#release()} ownership is transferred to this * {@link CompositeByteBuf}. */ public CompositeByteBuf addComponent(ByteBuf buffer) { return addComponent(false, buffer); }
/** * Add the given {@link ByteBuf} on the specific index. * <p> * Be aware that this method does not increase the {@code writerIndex} of the {@link CompositeByteBuf}. * If you need to have it increased use {@link #addComponent(boolean, int, ByteBuf)}. * <p> * {@link ByteBuf#release()} ownership of {@code buffer} is transferred to this {@link CompositeByteBuf}. * @param cIndex the index on which the {@link ByteBuf} will be added. * @param buffer the {@link ByteBuf} to add. {@link ByteBuf#release()} ownership is transferred to this * {@link CompositeByteBuf}. */ public CompositeByteBuf addComponent(int cIndex, ByteBuf buffer) { return addComponent(false, cIndex, buffer); }
private static void appendPartialContent(CompositeByteBuf content, ByteBuf partialContent) { if (partialContent.isReadable()) { content.addComponent(true, partialContent.retain()); } }
private static void appendPartialContent(CompositeByteBuf content, ByteBuf partialContent) { if (partialContent.isReadable()) { content.addComponent(true, partialContent.retain()); } }
@Override protected ByteBuf compose(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf next) { if (cumulation instanceof CompositeByteBuf) { CompositeByteBuf composite = (CompositeByteBuf) cumulation; composite.addComponent(true, next); return composite; } return composeIntoComposite(alloc, cumulation, next); }
@Override protected ByteBuf compose(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf next) { if (cumulation instanceof CompositeByteBuf) { CompositeByteBuf composite = (CompositeByteBuf) cumulation; composite.addComponent(true, next); return composite; } return composeIntoComposite(alloc, cumulation, next); }
/** * {@inheritDoc} * <p>This implementation uses Netty's {@link CompositeByteBuf}. */ @Override public DataBuffer join(List<? extends DataBuffer> dataBuffers) { Assert.notEmpty(dataBuffers, "DataBuffer List must not be empty"); int bufferCount = dataBuffers.size(); if (bufferCount == 1) { return dataBuffers.get(0); } CompositeByteBuf composite = this.byteBufAllocator.compositeBuffer(bufferCount); for (DataBuffer dataBuffer : dataBuffers) { Assert.isInstanceOf(NettyDataBuffer.class, dataBuffer); composite.addComponent(true, ((NettyDataBuffer) dataBuffer).getNativeBuffer()); } return new NettyDataBuffer(composite, this); }
/** * Compose {@code cumulation} and {@code next} into a new {@link CompositeByteBuf}. */ protected final ByteBuf composeIntoComposite(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf next) { // Create a composite buffer to accumulate this pair and potentially all the buffers // in the queue. Using +2 as we have already dequeued current and next. CompositeByteBuf composite = alloc.compositeBuffer(size() + 2); try { composite.addComponent(true, cumulation); composite.addComponent(true, next); } catch (Throwable cause) { composite.release(); safeRelease(next); throwException(cause); } return composite; }
/** * Compose {@code cumulation} and {@code next} into a new {@link CompositeByteBuf}. */ protected final ByteBuf composeIntoComposite(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf next) { // Create a composite buffer to accumulate this pair and potentially all the buffers // in the queue. Using +2 as we have already dequeued current and next. CompositeByteBuf composite = alloc.compositeBuffer(size() + 2); try { composite.addComponent(true, cumulation); composite.addComponent(true, next); } catch (Throwable cause) { composite.release(); safeRelease(next); throwException(cause); } return composite; }
@Override protected ByteBuf compose(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf next) { final int wrapDataSize = SslHandler.this.wrapDataSize; if (cumulation instanceof CompositeByteBuf) { CompositeByteBuf composite = (CompositeByteBuf) cumulation; int numComponents = composite.numComponents(); if (numComponents == 0 || !attemptCopyToCumulation(composite.internalComponent(numComponents - 1), next, wrapDataSize)) { composite.addComponent(true, next); } return composite; } return attemptCopyToCumulation(cumulation, next, wrapDataSize) ? cumulation : copyAndCompose(alloc, cumulation, next); }