netty5/buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java

384 lines
9.9 KiB
Java
Raw Normal View History

/*
2012-06-04 22:31:44 +02:00
* Copyright 2012 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
2012-06-04 22:31:44 +02:00
* http://www.apache.org/licenses/LICENSE-2.0
*
2009-08-28 09:15:49 +02:00
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
2009-08-28 09:15:49 +02:00
* License for the specific language governing permissions and limitations
* under the License.
*/
2011-12-09 04:38:59 +01:00
package io.netty.buffer;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.util.List;
/**
* A {@link ByteBuf} which is composed out of other {@link ByteBuf}s.
*/
public interface CompositeByteBuf extends ByteBuf, Iterable<ByteBuf> {
/**
* Add the given {@link ByteBuf}.
*
* @param buffer the {@link ByteBuf} to add
* @return self this instance
*/
CompositeByteBuf addComponent(ByteBuf buffer);
/**
* Add the given {@link ByteBuf} on the specific index.
*
* @param cIndex
* the index on which the {@link ByteBuf} will be added
* @param buffer
* the {@link ByteBuf} to add
* @return self
* this instance
* @throws IndexOutOfBoundsException
* if the index is invalid
*/
CompositeByteBuf addComponent(int cIndex, ByteBuf buffer);
/**
* Add the given {@link ByteBuf}s.
*
* @param buffers the {@link ByteBuf}s to add
* @return self this instance
*/
CompositeByteBuf addComponents(ByteBuf... buffers);
/**
* Add the given {@link ByteBuf}s.
*
* @param buffers the {@link ByteBuf}s to add
* @return self this instance
*/
CompositeByteBuf addComponents(Iterable<ByteBuf> buffers);
/**
* Add the given {@link ByteBuf}s on the specific index
*
* @param cIndex
* the index on which the {@link ByteBuf} will be added.
* @param buffers
* the {@link ByteBuf}s to add
* @return self
* this instance
* @throws IndexOutOfBoundsException
* if the index is invalid
*
*/
CompositeByteBuf addComponents(int cIndex, ByteBuf... buffers);
/**
* Add the given {@link ByteBuf}s on the specific index
*
* @param cIndex
* the index on which the {@link ByteBuf} will be added.
* @param buffers
* the {@link ByteBuf}s to add
* @return self
* this instance
* @throws IndexOutOfBoundsException
* if the index is invalid
*/
CompositeByteBuf addComponents(int cIndex, Iterable<ByteBuf> buffers);
/**
* Remove the {@link ByteBuf} from the given index.
*
* @param cIndex
* the index on from which the {@link ByteBuf} will be remove
* @return self
* this instance
* @throws IndexOutOfBoundsException
* if the index is invalid
*/
CompositeByteBuf removeComponent(int cIndex);
/**
* Remove the number of {@link ByteBuf}s starting from the given index.
*
* @param cIndex
* the index on which the {@link ByteBuf}s will be started to removed
* @param numComponents
* the number of components to remove
* @return self
* this instance
* @throws IndexOutOfBoundsException
* if the index is invalid
*/
CompositeByteBuf removeComponents(int cIndex, int numComponents);
2009-12-30 04:14:50 +01:00
/**
* Return the current number of {@link ByteBuf}'s that are composed in this instance
*/
int numComponents();
/**
* Return the max number of {@link ByteBuf}'s that are composed in this instance
*/
int maxNumComponents();
2009-12-30 04:14:50 +01:00
/**
* Return the {@link ByteBuf} on the specified index
*
* @param cIndex
* the index for which the {@link ByteBuf} should be returned
* @return buf
* the {@link ByteBuf} on the specified index
* @throws IndexOutOfBoundsException
* if the index is invalid
*/
ByteBuf component(int cIndex);
/**
* Return the {@link ByteBuf} on the specified index
*
* @param offset
* the offset for which the {@link ByteBuf} should be returned
* @return buf
* the {@link ByteBuf} on the specified index
* @throws IndexOutOfBoundsException
* if the offset is invalid
*/
ByteBuf componentAtOffset(int offset);
2009-12-30 04:14:50 +01:00
/**
* Discard all {@link ByteBuf}s which are read.
*
* @return self this instance
*/
CompositeByteBuf discardReadComponents();
/**
* Consolidate the composed {@link ByteBuf}s
*
* @return self this instance
*/
CompositeByteBuf consolidate();
/**
* Consolidate the composed {@link ByteBuf}s
*
* @param cIndex
* the index on which to start to compose
* @param numComponents
* the number of components to compose
* @return self
* this instance
* @throws IndexOutOfBoundsException
* if the offset is invalid
*/
CompositeByteBuf consolidate(int cIndex, int numComponents);
2009-12-30 04:14:50 +01:00
/**
* Return the index for the given offset
*/
int toComponentIndex(int offset);
int toByteIndex(int cIndex);
2009-12-30 04:14:50 +01:00
/**
* Same with {@link #slice(int, int)} except that this method returns a list.
*/
List<ByteBuf> decompose(int offset, int length);
@Override
CompositeByteBuf capacity(int newCapacity);
@Override
CompositeByteBuf readerIndex(int readerIndex);
@Override
CompositeByteBuf writerIndex(int writerIndex);
@Override
CompositeByteBuf setIndex(int readerIndex, int writerIndex);
@Override
CompositeByteBuf clear();
@Override
CompositeByteBuf markReaderIndex();
@Override
CompositeByteBuf resetReaderIndex();
@Override
CompositeByteBuf markWriterIndex();
@Override
CompositeByteBuf resetWriterIndex();
@Override
CompositeByteBuf discardReadBytes();
@Override
CompositeByteBuf discardSomeReadBytes();
@Override
CompositeByteBuf ensureWritable(int minWritableBytes);
@Override
CompositeByteBuf getBytes(int index, ByteBuf dst);
@Override
CompositeByteBuf getBytes(int index, ByteBuf dst, int length);
@Override
CompositeByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length);
@Override
CompositeByteBuf getBytes(int index, byte[] dst);
@Override
CompositeByteBuf getBytes(int index, byte[] dst, int dstIndex, int length);
@Override
CompositeByteBuf getBytes(int index, ByteBuffer dst);
@Override
CompositeByteBuf getBytes(int index, OutputStream out, int length) throws IOException;
@Override
CompositeByteBuf setBoolean(int index, boolean value);
@Override
CompositeByteBuf setByte(int index, int value);
@Override
CompositeByteBuf setShort(int index, int value);
@Override
CompositeByteBuf setMedium(int index, int value);
@Override
CompositeByteBuf setInt(int index, int value);
@Override
CompositeByteBuf setLong(int index, long value);
@Override
CompositeByteBuf setChar(int index, int value);
@Override
CompositeByteBuf setFloat(int index, float value);
@Override
CompositeByteBuf setDouble(int index, double value);
@Override
CompositeByteBuf setBytes(int index, ByteBuf src);
@Override
CompositeByteBuf setBytes(int index, ByteBuf src, int length);
@Override
CompositeByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length);
@Override
CompositeByteBuf setBytes(int index, byte[] src);
@Override
CompositeByteBuf setBytes(int index, byte[] src, int srcIndex, int length);
@Override
CompositeByteBuf setBytes(int index, ByteBuffer src);
@Override
CompositeByteBuf setZero(int index, int length);
@Override
CompositeByteBuf readBytes(ByteBuf dst);
@Override
CompositeByteBuf readBytes(ByteBuf dst, int length);
@Override
CompositeByteBuf readBytes(ByteBuf dst, int dstIndex, int length);
@Override
CompositeByteBuf readBytes(byte[] dst);
@Override
CompositeByteBuf readBytes(byte[] dst, int dstIndex, int length);
@Override
CompositeByteBuf readBytes(ByteBuffer dst);
@Override
CompositeByteBuf readBytes(OutputStream out, int length) throws IOException;
@Override
CompositeByteBuf skipBytes(int length);
@Override
CompositeByteBuf writeBoolean(boolean value);
@Override
CompositeByteBuf writeByte(int value);
@Override
CompositeByteBuf writeShort(int value);
@Override
CompositeByteBuf writeMedium(int value);
@Override
CompositeByteBuf writeInt(int value);
@Override
CompositeByteBuf writeLong(long value);
@Override
CompositeByteBuf writeChar(int value);
@Override
CompositeByteBuf writeFloat(float value);
@Override
CompositeByteBuf writeDouble(double value);
@Override
CompositeByteBuf writeBytes(ByteBuf src);
@Override
CompositeByteBuf writeBytes(ByteBuf src, int length);
@Override
CompositeByteBuf writeBytes(ByteBuf src, int srcIndex, int length);
@Override
CompositeByteBuf writeBytes(byte[] src);
@Override
CompositeByteBuf writeBytes(byte[] src, int srcIndex, int length);
@Override
CompositeByteBuf writeBytes(ByteBuffer src);
@Override
CompositeByteBuf writeZero(int length);
@Override
CompositeByteBuf suspendIntermediaryDeallocations();
@Override
CompositeByteBuf resumeIntermediaryDeallocations();
@Override
CompositeByteBuf retain(int increment);
@Override
CompositeByteBuf retain();
}