2008-08-08 02:37:18 +02:00
|
|
|
/*
|
2011-12-09 06:18:34 +01:00
|
|
|
* Copyright 2011 The Netty Project
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
2011-12-09 06:18:34 +01:00
|
|
|
* 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:
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
2011-12-09 06:18:34 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2008-08-08 03:27:24 +02:00
|
|
|
*
|
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
|
2011-12-09 06:18:34 +01:00
|
|
|
* 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.
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
2011-12-09 04:38:59 +01:00
|
|
|
package io.netty.buffer;
|
2008-08-08 02:37:18 +02:00
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
import java.nio.ByteBuffer;
|
|
|
|
import java.nio.ByteOrder;
|
|
|
|
import java.nio.channels.GatheringByteChannel;
|
|
|
|
import java.nio.channels.ScatteringByteChannel;
|
2009-12-29 06:52:00 +01:00
|
|
|
import java.nio.charset.Charset;
|
2008-08-10 16:25:13 +02:00
|
|
|
import java.nio.charset.UnsupportedCharsetException;
|
2008-08-08 02:37:18 +02:00
|
|
|
|
|
|
|
/**
|
2008-09-02 09:13:20 +02:00
|
|
|
* A random and sequential accessible sequence of zero or more bytes (octets).
|
2008-08-08 02:37:18 +02:00
|
|
|
* This interface provides an abstract view for one or more primitive byte
|
|
|
|
* arrays ({@code byte[]}) and {@linkplain ByteBuffer NIO buffers}.
|
|
|
|
*
|
|
|
|
* <h3>Creation of a buffer</h3>
|
|
|
|
*
|
2008-09-03 03:04:33 +02:00
|
|
|
* It is recommended to create a new buffer using the helper methods in
|
|
|
|
* {@link ChannelBuffers} rather than calling an individual implementation's
|
|
|
|
* constructor.
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
|
|
|
* <h3>Random Access Indexing</h3>
|
|
|
|
*
|
|
|
|
* Just like an ordinary primitive byte array, {@link ChannelBuffer} uses
|
|
|
|
* <a href="http://en.wikipedia.org/wiki/Index_(information_technology)#Array_element_identifier">zero-based indexing</a>.
|
|
|
|
* It means the index of the first byte is always {@code 0} and the index of
|
|
|
|
* the last byte is always {@link #capacity() capacity - 1}. For example, to
|
|
|
|
* iterate all bytes of a buffer, you can do the following, regardless of
|
|
|
|
* its internal implementation:
|
|
|
|
*
|
|
|
|
* <pre>
|
2010-02-02 03:00:04 +01:00
|
|
|
* {@link ChannelBuffer} buffer = ...;
|
2012-01-11 12:16:14 +01:00
|
|
|
* for (int i = 0; i < buffer.capacity(); i ++) {
|
2011-02-07 11:58:48 +01:00
|
|
|
* byte b = buffer.getByte(i);
|
2008-08-08 02:37:18 +02:00
|
|
|
* System.out.println((char) b);
|
|
|
|
* }
|
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* <h3>Sequential Access Indexing</h3>
|
|
|
|
*
|
|
|
|
* {@link ChannelBuffer} provides two pointer variables to support sequential
|
|
|
|
* read and write operations - {@link #readerIndex() readerIndex} for a read
|
|
|
|
* operation and {@link #writerIndex() writerIndex} for a write operation
|
|
|
|
* respectively. The following diagram shows how a buffer is segmented into
|
|
|
|
* three areas by the two pointers:
|
|
|
|
*
|
|
|
|
* <pre>
|
|
|
|
* +-------------------+------------------+------------------+
|
2008-08-10 17:20:26 +02:00
|
|
|
* | discardable bytes | readable bytes | writable bytes |
|
2008-08-08 02:37:18 +02:00
|
|
|
* | | (CONTENT) | |
|
|
|
|
* +-------------------+------------------+------------------+
|
|
|
|
* | | | |
|
|
|
|
* 0 <= readerIndex <= writerIndex <= capacity
|
|
|
|
* </pre>
|
|
|
|
*
|
2008-08-11 05:33:25 +02:00
|
|
|
* <h4>Readable bytes (the actual content)</h4>
|
|
|
|
*
|
|
|
|
* This segment is where the actual data is stored. Any operation whose name
|
|
|
|
* starts with {@code read} or {@code skip} will get or skip the data at the
|
|
|
|
* current {@link #readerIndex() readerIndex} and increase it by the number of
|
|
|
|
* read bytes. If the argument of the read operation is also a
|
2009-06-17 10:24:52 +02:00
|
|
|
* {@link ChannelBuffer} and no destination index is specified, the specified
|
2008-08-11 05:33:25 +02:00
|
|
|
* buffer's {@link #readerIndex() readerIndex} is increased together.
|
2008-08-08 02:37:18 +02:00
|
|
|
* <p>
|
|
|
|
* If there's not enough content left, {@link IndexOutOfBoundsException} is
|
|
|
|
* raised. The default value of newly allocated, wrapped or copied buffer's
|
|
|
|
* {@link #readerIndex() readerIndex} is {@code 0}.
|
|
|
|
*
|
|
|
|
* <pre>
|
|
|
|
* // Iterates the readable bytes of a buffer.
|
2010-02-02 03:00:04 +01:00
|
|
|
* {@link ChannelBuffer} buffer = ...;
|
2008-08-08 02:37:18 +02:00
|
|
|
* while (buffer.readable()) {
|
|
|
|
* System.out.println(buffer.readByte());
|
|
|
|
* }
|
|
|
|
* </pre>
|
|
|
|
*
|
2008-08-10 17:20:26 +02:00
|
|
|
* <h4>Writable bytes</h4>
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
|
|
|
* This segment is a undefined space which needs to be filled. Any operation
|
|
|
|
* whose name ends with {@code write} will write the data at the current
|
|
|
|
* {@link #writerIndex() writerIndex} and increase it by the number of written
|
|
|
|
* bytes. If the argument of the write operation is also a {@link ChannelBuffer},
|
2009-06-17 10:24:52 +02:00
|
|
|
* and no source index is specified, the specified buffer's
|
2008-08-08 02:37:18 +02:00
|
|
|
* {@link #readerIndex() readerIndex} is increased together.
|
|
|
|
* <p>
|
2008-08-10 17:20:26 +02:00
|
|
|
* If there's not enough writable bytes left, {@link IndexOutOfBoundsException}
|
2008-08-08 02:37:18 +02:00
|
|
|
* is raised. The default value of newly allocated buffer's
|
|
|
|
* {@link #writerIndex() writerIndex} is {@code 0}. The default value of
|
|
|
|
* wrapped or copied buffer's {@link #writerIndex() writerIndex} is the
|
|
|
|
* {@link #capacity() capacity} of the buffer.
|
|
|
|
*
|
|
|
|
* <pre>
|
2008-08-10 17:20:26 +02:00
|
|
|
* // Fills the writable bytes of a buffer with random integers.
|
2010-02-02 03:00:04 +01:00
|
|
|
* {@link ChannelBuffer} buffer = ...;
|
2008-08-08 02:37:18 +02:00
|
|
|
* while (buffer.writableBytes() >= 4) {
|
|
|
|
* buffer.writeInt(random.nextInt());
|
|
|
|
* }
|
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* <h4>Discardable bytes</h4>
|
|
|
|
*
|
|
|
|
* This segment contains the bytes which were read already by a read operation.
|
|
|
|
* Initially, the size of this segment is {@code 0}, but its size increases up
|
|
|
|
* to the {@link #writerIndex() writerIndex} as read operations are executed.
|
|
|
|
* The read bytes can be discarded by calling {@link #discardReadBytes()} to
|
|
|
|
* reclaim unused area as depicted by the following diagram:
|
|
|
|
*
|
|
|
|
* <pre>
|
|
|
|
* BEFORE discardReadBytes()
|
|
|
|
*
|
|
|
|
* +-------------------+------------------+------------------+
|
2008-08-10 17:20:26 +02:00
|
|
|
* | discardable bytes | readable bytes | writable bytes |
|
2008-08-08 02:37:18 +02:00
|
|
|
* +-------------------+------------------+------------------+
|
|
|
|
* | | | |
|
|
|
|
* 0 <= readerIndex <= writerIndex <= capacity
|
|
|
|
* AFTER discardReadBytes()
|
|
|
|
*
|
|
|
|
* +------------------+--------------------------------------+
|
2008-08-10 17:20:26 +02:00
|
|
|
* | readable bytes | writable bytes (got more space) |
|
2008-08-08 02:37:18 +02:00
|
|
|
* +------------------+--------------------------------------+
|
|
|
|
* | | |
|
|
|
|
* readerIndex (0) <= writerIndex (decreased) <= capacity
|
|
|
|
* </pre>
|
|
|
|
*
|
2009-08-28 07:56:47 +02:00
|
|
|
* Please note that there is no guarantee about the content of writable bytes
|
|
|
|
* after calling {@link #discardReadBytes()}. The writable bytes will not be
|
|
|
|
* moved in most cases and could even be filled with completely different data
|
|
|
|
* depending on the underlying buffer implementation.
|
|
|
|
*
|
2008-08-08 02:37:18 +02:00
|
|
|
* <h4>Clearing the buffer indexes</h4>
|
|
|
|
*
|
|
|
|
* You can set both {@link #readerIndex() readerIndex} and
|
|
|
|
* {@link #writerIndex() writerIndex} to {@code 0} by calling {@link #clear()}.
|
2008-11-14 08:45:53 +01:00
|
|
|
* It does not clear the buffer content (e.g. filling with {@code 0}) but just
|
2008-08-08 02:37:18 +02:00
|
|
|
* clears the two pointers. Please also note that the semantic of this
|
|
|
|
* operation is different from {@link ByteBuffer#clear()}.
|
|
|
|
*
|
|
|
|
* <pre>
|
|
|
|
* BEFORE clear()
|
|
|
|
*
|
|
|
|
* +-------------------+------------------+------------------+
|
2008-08-10 17:20:26 +02:00
|
|
|
* | discardable bytes | readable bytes | writable bytes |
|
2008-08-08 02:37:18 +02:00
|
|
|
* +-------------------+------------------+------------------+
|
|
|
|
* | | | |
|
|
|
|
* 0 <= readerIndex <= writerIndex <= capacity
|
|
|
|
* AFTER clear()
|
|
|
|
*
|
|
|
|
* +---------------------------------------------------------+
|
2008-08-10 17:20:26 +02:00
|
|
|
* | writable bytes (got more space) |
|
2008-08-08 02:37:18 +02:00
|
|
|
* +---------------------------------------------------------+
|
|
|
|
* | |
|
|
|
|
* 0 = readerIndex = writerIndex <= capacity
|
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* <h3>Search operations</h3>
|
|
|
|
*
|
2010-01-20 06:55:16 +01:00
|
|
|
* Various {@link #indexOf(int, int, byte)} methods help you locate an index of
|
|
|
|
* a value which meets a certain criteria. Complicated dynamic sequential
|
|
|
|
* search can be done with {@link ChannelBufferIndexFinder} as well as simple
|
|
|
|
* static single byte search.
|
|
|
|
* <p>
|
|
|
|
* If you are decoding variable length data such as NUL-terminated string, you
|
|
|
|
* will find {@link #bytesBefore(byte)} also useful.
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
|
|
|
* <h3>Mark and reset</h3>
|
|
|
|
*
|
|
|
|
* There are two marker indexes in every buffer. One is for storing
|
|
|
|
* {@link #readerIndex() readerIndex} and the other is for storing
|
|
|
|
* {@link #writerIndex() writerIndex}. You can always reposition one of the
|
|
|
|
* two indexes by calling a reset method. It works in a similar fashion to
|
|
|
|
* the mark and reset methods in {@link InputStream} except that there's no
|
|
|
|
* {@code readlimit}.
|
|
|
|
*
|
|
|
|
* <h3>Derived buffers</h3>
|
|
|
|
*
|
|
|
|
* You can create a view of an existing buffer by calling either
|
|
|
|
* {@link #duplicate()}, {@link #slice()} or {@link #slice(int, int)}.
|
|
|
|
* A derived buffer will have an independent {@link #readerIndex() readerIndex},
|
|
|
|
* {@link #writerIndex() writerIndex} and marker indexes, while it shares
|
2008-08-11 05:33:25 +02:00
|
|
|
* other internal data representation, just like a NIO buffer does.
|
2008-08-08 02:37:18 +02:00
|
|
|
* <p>
|
|
|
|
* In case a completely fresh copy of an existing buffer is required, please
|
|
|
|
* call {@link #copy()} method instead.
|
|
|
|
*
|
|
|
|
* <h3>Conversion to existing JDK types</h3>
|
|
|
|
*
|
2010-05-06 09:33:26 +02:00
|
|
|
* <h4>Byte array</h4>
|
|
|
|
*
|
|
|
|
* If a {@link ChannelBuffer} is backed by a byte array (i.e. {@code byte[]}),
|
|
|
|
* you can access it directly via the {@link #array()} method. To determine
|
|
|
|
* if a buffer is backed by a byte array, {@link #hasArray()} should be used.
|
|
|
|
*
|
2008-08-11 05:33:25 +02:00
|
|
|
* <h4>NIO Buffers</h4>
|
2008-08-10 07:09:55 +02:00
|
|
|
*
|
2008-08-08 02:37:18 +02:00
|
|
|
* Various {@link #toByteBuffer()} and {@link #toByteBuffers()} methods convert
|
|
|
|
* a {@link ChannelBuffer} into one or more NIO buffers. These methods avoid
|
|
|
|
* buffer allocation and memory copy whenever possible, but there's no
|
2010-05-06 09:33:26 +02:00
|
|
|
* guarantee that memory copy will not be involved.
|
2008-08-10 07:09:55 +02:00
|
|
|
*
|
2008-08-11 05:33:25 +02:00
|
|
|
* <h4>Strings</h4>
|
2008-08-10 07:09:55 +02:00
|
|
|
*
|
2010-06-30 07:48:23 +02:00
|
|
|
* Various {@link #toString(Charset)} methods convert a {@link ChannelBuffer}
|
2009-06-17 10:24:52 +02:00
|
|
|
* into a {@link String}. Please note that {@link #toString()} is not a
|
2008-08-10 07:09:55 +02:00
|
|
|
* conversion method.
|
|
|
|
*
|
2008-08-11 05:33:25 +02:00
|
|
|
* <h4>I/O Streams</h4>
|
2008-08-10 07:09:55 +02:00
|
|
|
*
|
|
|
|
* Please refer to {@link ChannelBufferInputStream} and
|
|
|
|
* {@link ChannelBufferOutputStream}.
|
2008-08-08 02:37:18 +02:00
|
|
|
* @apiviz.landmark
|
|
|
|
*/
|
|
|
|
public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
|
|
|
|
2008-12-08 09:20:34 +01:00
|
|
|
/**
|
|
|
|
* Returns the factory which creates a {@link ChannelBuffer} whose
|
|
|
|
* type and default {@link ByteOrder} are same with this buffer.
|
|
|
|
*/
|
|
|
|
ChannelBufferFactory factory();
|
|
|
|
|
2008-08-08 02:37:18 +02:00
|
|
|
/**
|
|
|
|
* Returns the number of bytes (octets) this buffer can contain.
|
|
|
|
*/
|
|
|
|
int capacity();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the <a href="http://en.wikipedia.org/wiki/Endianness">endianness</a>
|
|
|
|
* of this buffer.
|
|
|
|
*/
|
|
|
|
ByteOrder order();
|
|
|
|
|
2010-01-27 06:07:32 +01:00
|
|
|
/**
|
|
|
|
* Returns {@code true} if and only if this buffer is backed by an
|
|
|
|
* NIO direct buffer.
|
|
|
|
*/
|
|
|
|
boolean isDirect();
|
|
|
|
|
2008-08-08 02:37:18 +02:00
|
|
|
/**
|
|
|
|
* Returns the {@code readerIndex} of this buffer.
|
|
|
|
*/
|
|
|
|
int readerIndex();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the {@code readerIndex} of this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-11 05:33:25 +02:00
|
|
|
* if the specified {@code readerIndex} is
|
|
|
|
* less than {@code 0} or
|
|
|
|
* greater than {@code this.writerIndex}
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
|
|
|
void readerIndex(int readerIndex);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the {@code writerIndex} of this buffer.
|
|
|
|
*/
|
|
|
|
int writerIndex();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the {@code writerIndex} of this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-11 05:33:25 +02:00
|
|
|
* if the specified {@code writerIndex} is
|
|
|
|
* less than {@code this.readerIndex} or
|
|
|
|
* greater than {@code this.capacity}
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
|
|
|
void writerIndex(int writerIndex);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the {@code readerIndex} and {@code writerIndex} of this buffer
|
2008-08-10 16:25:13 +02:00
|
|
|
* in one shot. This method is useful when you have to worry about the
|
|
|
|
* invocation order of {@link #readerIndex(int)} and {@link #writerIndex(int)}
|
2008-08-08 02:37:18 +02:00
|
|
|
* methods. For example, the following code will fail:
|
|
|
|
*
|
|
|
|
* <pre>
|
|
|
|
* // Create a buffer whose readerIndex, writerIndex and capacity are
|
|
|
|
* // 0, 0 and 8 respectively.
|
2010-02-02 03:00:04 +01:00
|
|
|
* {@link ChannelBuffer} buf = {@link ChannelBuffers}.buffer(8);
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
|
|
|
* // IndexOutOfBoundsException is thrown because the specified
|
|
|
|
* // readerIndex (2) cannot be greater than the current writerIndex (0).
|
|
|
|
* buf.readerIndex(2);
|
|
|
|
* buf.writerIndex(4);
|
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* The following code will also fail:
|
|
|
|
*
|
|
|
|
* <pre>
|
|
|
|
* // Create a buffer whose readerIndex, writerIndex and capacity are
|
|
|
|
* // 0, 8 and 8 respectively.
|
2010-02-02 03:00:04 +01:00
|
|
|
* {@link ChannelBuffer} buf = {@link ChannelBuffers}.wrappedBuffer(new byte[8]);
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
|
|
|
* // readerIndex becomes 8.
|
|
|
|
* buf.readLong();
|
|
|
|
*
|
|
|
|
* // IndexOutOfBoundsException is thrown because the specified
|
|
|
|
* // writerIndex (4) cannot be less than the current readerIndex (8).
|
|
|
|
* buf.writerIndex(4);
|
|
|
|
* buf.readerIndex(2);
|
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* By contrast, {@link #setIndex(int, int)} guarantees that it never
|
|
|
|
* throws an {@link IndexOutOfBoundsException} as long as the specified
|
2008-08-11 05:33:25 +02:00
|
|
|
* indexes meet basic constraints, regardless what the current index
|
|
|
|
* values of the buffer are:
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
|
|
|
* <pre>
|
|
|
|
* // No matter what the current state of the buffer is, the following
|
|
|
|
* // call always succeeds as long as the capacity of the buffer is not
|
|
|
|
* // less than 4.
|
|
|
|
* buf.setIndex(2, 4);
|
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code readerIndex} is less than 0,
|
|
|
|
* if the specified {@code writerIndex} is less than the specified
|
|
|
|
* {@code readerIndex} or if the specified {@code writerIndex} is
|
2008-08-10 16:25:13 +02:00
|
|
|
* greater than {@code this.capacity}
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
|
|
|
void setIndex(int readerIndex, int writerIndex);
|
|
|
|
|
|
|
|
/**
|
2008-08-11 05:33:25 +02:00
|
|
|
* Returns the number of readable bytes which is equal to
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code (this.writerIndex - this.readerIndex)}.
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
|
|
|
int readableBytes();
|
|
|
|
|
|
|
|
/**
|
2008-08-11 05:33:25 +02:00
|
|
|
* Returns the number of writable bytes which is equal to
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code (this.capacity - this.writerIndex)}.
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
|
|
|
int writableBytes();
|
|
|
|
|
|
|
|
/**
|
2008-08-10 16:25:13 +02:00
|
|
|
* Returns {@code true}
|
|
|
|
* if and only if {@code (this.writerIndex - this.readerIndex)} is greater
|
|
|
|
* than {@code 0}.
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
|
|
|
boolean readable();
|
|
|
|
|
|
|
|
/**
|
2008-08-10 16:25:13 +02:00
|
|
|
* Returns {@code true}
|
|
|
|
* if and only if {@code (this.capacity - this.writerIndex)} is greater
|
|
|
|
* than {@code 0}.
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
|
|
|
boolean writable();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the {@code readerIndex} and {@code writerIndex} of this buffer to
|
|
|
|
* {@code 0}.
|
|
|
|
* This method is identical to {@link #setIndex(int, int) setIndex(0, 0)}.
|
|
|
|
* <p>
|
|
|
|
* Please note that the behavior of this method is different
|
2008-08-11 05:33:25 +02:00
|
|
|
* from that of NIO buffer, which sets the {@code limit} to
|
2008-08-10 16:25:13 +02:00
|
|
|
* the {@code capacity} of the buffer.
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
/**
|
2008-08-10 16:25:13 +02:00
|
|
|
* Marks the current {@code readerIndex} in this buffer. You can
|
|
|
|
* reposition the current {@code readerIndex} to the marked
|
|
|
|
* {@code readerIndex} by calling {@link #resetReaderIndex()}.
|
|
|
|
* The initial value of the marked {@code readerIndex} is {@code 0}.
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
|
|
|
void markReaderIndex();
|
|
|
|
|
|
|
|
/**
|
2008-08-10 16:25:13 +02:00
|
|
|
* Repositions the current {@code readerIndex} to the marked
|
|
|
|
* {@code readerIndex} in this buffer.
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the current {@code writerIndex} is less than the marked
|
|
|
|
* {@code readerIndex}
|
|
|
|
*/
|
|
|
|
void resetReaderIndex();
|
|
|
|
|
|
|
|
/**
|
2008-08-10 16:25:13 +02:00
|
|
|
* Marks the current {@code writerIndex} in this buffer. You can
|
|
|
|
* reposition the current {@code writerIndex} to the marked
|
|
|
|
* {@code writerIndex} by calling {@link #resetWriterIndex()}.
|
|
|
|
* The initial value of the marked {@code writerIndex} is {@code 0}.
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
|
|
|
void markWriterIndex();
|
|
|
|
|
|
|
|
/**
|
2008-08-10 16:25:13 +02:00
|
|
|
* Repositions the current {@code writerIndex} to the marked
|
|
|
|
* {@code writerIndex} in this buffer.
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the current {@code readerIndex} is greater than the marked
|
|
|
|
* {@code writerIndex}
|
|
|
|
*/
|
|
|
|
void resetWriterIndex();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Discards the bytes between the 0th index and {@code readerIndex}.
|
|
|
|
* It moves the bytes between {@code readerIndex} and {@code writerIndex}
|
|
|
|
* to the 0th index, and sets {@code readerIndex} and {@code writerIndex}
|
|
|
|
* to {@code 0} and {@code oldWriterIndex - oldReaderIndex} respectively.
|
|
|
|
* <p>
|
2008-08-10 16:25:13 +02:00
|
|
|
* Please refer to the class documentation for more detailed explanation.
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
|
|
|
void discardReadBytes();
|
|
|
|
|
2009-12-16 06:02:23 +01:00
|
|
|
/**
|
|
|
|
* Makes sure the number of {@linkplain #writableBytes() the writable bytes}
|
|
|
|
* is equal to or greater than the specified value. If there is enough
|
|
|
|
* writable bytes in this buffer, this method returns with no side effect.
|
|
|
|
* Otherwise:
|
|
|
|
* <ul>
|
|
|
|
* <li>a non-dynamic buffer will throw an {@link IndexOutOfBoundsException}.</li>
|
|
|
|
* <li>a dynamic buffer will expand its capacity so that the number of the
|
|
|
|
* {@link #writableBytes() writable bytes} becomes equal to or greater
|
|
|
|
* than the specified value. The expansion involves the reallocation of
|
|
|
|
* the internal buffer and consequently memory copy.</li>
|
|
|
|
* </ul>
|
|
|
|
*
|
|
|
|
* @param writableBytes
|
|
|
|
* the expected minimum number of writable bytes
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if {@linkplain #writableBytes() the writable bytes} of this
|
2009-12-16 06:05:56 +01:00
|
|
|
* buffer is less than the specified value and if this buffer is
|
|
|
|
* not a dynamic buffer
|
2009-12-16 06:02:23 +01:00
|
|
|
*/
|
|
|
|
void ensureWritableBytes(int writableBytes);
|
2011-11-07 12:07:54 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a boolean at the specified absolute (@code index) in this buffer.
|
|
|
|
* This method does not modify the {@code readerIndex} or {@code writerIndex}
|
|
|
|
* of this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
|
|
|
* {@code index + 1} is greater than {@code this.capacity}
|
|
|
|
*/
|
|
|
|
boolean getBoolean(int index);
|
2009-12-16 06:02:23 +01:00
|
|
|
|
2008-08-08 10:14:32 +02:00
|
|
|
/**
|
|
|
|
* Gets a byte at the specified absolute {@code index} in this buffer.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code index + 1} is greater than {@code this.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
byte getByte(int index);
|
2008-08-08 10:14:32 +02:00
|
|
|
|
2008-08-10 02:52:59 +02:00
|
|
|
/**
|
2008-09-24 11:48:32 +02:00
|
|
|
* Gets an unsigned byte at the specified absolute {@code index} in this
|
2009-04-24 15:56:35 +02:00
|
|
|
* buffer. This method does not modify {@code readerIndex} or
|
|
|
|
* {@code writerIndex} of this buffer.
|
2008-08-10 02:52:59 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code index + 1} is greater than {@code this.capacity}
|
2008-08-10 02:52:59 +02:00
|
|
|
*/
|
|
|
|
short getUnsignedByte(int index);
|
|
|
|
|
2008-08-08 10:14:32 +02:00
|
|
|
/**
|
|
|
|
* Gets a 16-bit short integer at the specified absolute {@code index} in
|
2009-04-24 15:56:35 +02:00
|
|
|
* this buffer. This method does not modify {@code readerIndex} or
|
|
|
|
* {@code writerIndex} of this buffer.
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code index + 2} is greater than {@code this.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
short getShort(int index);
|
2008-08-08 10:14:32 +02:00
|
|
|
|
2008-08-10 02:52:59 +02:00
|
|
|
/**
|
2008-09-24 11:48:32 +02:00
|
|
|
* Gets an unsigned 16-bit short integer at the specified absolute
|
2009-04-24 15:56:35 +02:00
|
|
|
* {@code index} in this buffer. This method does not modify
|
|
|
|
* {@code readerIndex} or {@code writerIndex} of this buffer.
|
2008-08-10 02:52:59 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code index + 2} is greater than {@code this.capacity}
|
2008-08-10 02:52:59 +02:00
|
|
|
*/
|
|
|
|
int getUnsignedShort(int index);
|
|
|
|
|
2008-08-08 10:14:32 +02:00
|
|
|
/**
|
|
|
|
* Gets a 24-bit medium integer at the specified absolute {@code index} in
|
2009-04-24 15:56:35 +02:00
|
|
|
* this buffer. This method does not modify {@code readerIndex} or
|
|
|
|
* {@code writerIndex} of this buffer.
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code index + 3} is greater than {@code this.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
int getMedium(int index);
|
2008-08-08 10:14:32 +02:00
|
|
|
|
2008-08-10 02:52:59 +02:00
|
|
|
/**
|
2008-09-24 11:48:32 +02:00
|
|
|
* Gets an unsigned 24-bit medium integer at the specified absolute
|
2009-04-24 15:56:35 +02:00
|
|
|
* {@code index} in this buffer. This method does not modify
|
|
|
|
* {@code readerIndex} or {@code writerIndex} of this buffer.
|
2008-08-10 02:52:59 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code index + 3} is greater than {@code this.capacity}
|
2008-08-10 02:52:59 +02:00
|
|
|
*/
|
|
|
|
int getUnsignedMedium(int index);
|
|
|
|
|
2008-08-08 10:14:32 +02:00
|
|
|
/**
|
|
|
|
* Gets a 32-bit integer at the specified absolute {@code index} in
|
2009-04-24 15:56:35 +02:00
|
|
|
* this buffer. This method does not modify {@code readerIndex} or
|
|
|
|
* {@code writerIndex} of this buffer.
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code index + 4} is greater than {@code this.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
int getInt(int index);
|
2008-08-08 10:14:32 +02:00
|
|
|
|
2008-08-10 02:52:59 +02:00
|
|
|
/**
|
2008-09-24 11:48:32 +02:00
|
|
|
* Gets an unsigned 32-bit integer at the specified absolute {@code index}
|
2009-04-24 15:56:35 +02:00
|
|
|
* in this buffer. This method does not modify {@code readerIndex} or
|
|
|
|
* {@code writerIndex} of this buffer.
|
2008-08-10 02:52:59 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code index + 4} is greater than {@code this.capacity}
|
2008-08-10 02:52:59 +02:00
|
|
|
*/
|
|
|
|
long getUnsignedInt(int index);
|
|
|
|
|
2008-08-08 10:14:32 +02:00
|
|
|
/**
|
|
|
|
* Gets a 64-bit long integer at the specified absolute {@code index} in
|
2009-04-24 15:56:35 +02:00
|
|
|
* this buffer. This method does not modify {@code readerIndex} or
|
|
|
|
* {@code writerIndex} of this buffer.
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code index + 8} is greater than {@code this.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
long getLong(int index);
|
|
|
|
|
2009-11-25 07:51:43 +01:00
|
|
|
/**
|
|
|
|
* Gets a 2-byte UTF-16 character at the specified absolute
|
|
|
|
* {@code index} in this buffer. This method does not modify
|
|
|
|
* {@code readerIndex} or {@code writerIndex} of this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
|
|
|
* {@code index + 2} is greater than {@code this.capacity}
|
|
|
|
*/
|
|
|
|
char getChar(int index);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a 32-bit floating point number at the specified absolute
|
|
|
|
* {@code index} in this buffer. This method does not modify
|
|
|
|
* {@code readerIndex} or {@code writerIndex} of this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
|
|
|
* {@code index + 4} is greater than {@code this.capacity}
|
|
|
|
*/
|
|
|
|
float getFloat(int index);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a 64-bit floating point number at the specified absolute
|
|
|
|
* {@code index} in this buffer. This method does not modify
|
|
|
|
* {@code readerIndex} or {@code writerIndex} of this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
|
|
|
* {@code index + 8} is greater than {@code this.capacity}
|
|
|
|
*/
|
|
|
|
double getDouble(int index);
|
|
|
|
|
2008-08-08 10:14:32 +02:00
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified destination starting at
|
|
|
|
* the specified absolute {@code index} until the destination becomes
|
2008-09-24 11:48:32 +02:00
|
|
|
* non-writable. This method is basically same with
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@link #getBytes(int, ChannelBuffer, int, int)}, except that this
|
|
|
|
* method increases the {@code writerIndex} of the destination by the
|
|
|
|
* number of the transferred bytes while
|
2008-11-14 08:45:53 +01:00
|
|
|
* {@link #getBytes(int, ChannelBuffer, int, int)} does not.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* the source buffer (i.e. {@code this}).
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code index + dst.writableBytes} is greater than
|
|
|
|
* {@code this.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void getBytes(int index, ChannelBuffer dst);
|
2008-08-08 10:14:32 +02:00
|
|
|
|
2008-08-10 17:10:27 +02:00
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified destination starting at
|
|
|
|
* the specified absolute {@code index}. This method is basically same
|
|
|
|
* with {@link #getBytes(int, ChannelBuffer, int, int)}, except that this
|
|
|
|
* method increases the {@code writerIndex} of the destination by the
|
|
|
|
* number of the transferred bytes while
|
2008-11-14 08:45:53 +01:00
|
|
|
* {@link #getBytes(int, ChannelBuffer, int, int)} does not.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* the source buffer (i.e. {@code this}).
|
2008-08-10 17:10:27 +02:00
|
|
|
*
|
|
|
|
* @param length the number of bytes to transfer
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0},
|
|
|
|
* if {@code index + length} is greater than
|
|
|
|
* {@code this.capacity}, or
|
|
|
|
* if {@code length} is greater than {@code dst.writableBytes}
|
|
|
|
*/
|
|
|
|
void getBytes(int index, ChannelBuffer dst, int length);
|
|
|
|
|
2008-08-08 10:14:32 +02:00
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified destination starting at
|
|
|
|
* the specified absolute {@code index}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex}
|
|
|
|
* of both the source (i.e. {@code this}) and the destination.
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
2008-08-10 16:25:13 +02:00
|
|
|
* @param dstIndex the first index of the destination
|
|
|
|
* @param length the number of bytes to transfer
|
|
|
|
*
|
2008-08-08 10:14:32 +02:00
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0},
|
|
|
|
* if the specified {@code dstIndex} is less than {@code 0},
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code index + length} is greater than
|
|
|
|
* {@code this.capacity}, or
|
|
|
|
* if {@code dstIndex + length} is greater than
|
|
|
|
* {@code dst.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void getBytes(int index, ChannelBuffer dst, int dstIndex, int length);
|
2008-08-08 10:14:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified destination starting at
|
|
|
|
* the specified absolute {@code index}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code index + dst.length} is greater than
|
|
|
|
* {@code this.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void getBytes(int index, byte[] dst);
|
2008-08-08 10:14:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified destination starting at
|
|
|
|
* the specified absolute {@code index}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex}
|
|
|
|
* of this buffer.
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
2008-08-10 16:25:13 +02:00
|
|
|
* @param dstIndex the first index of the destination
|
|
|
|
* @param length the number of bytes to transfer
|
|
|
|
*
|
2008-08-08 10:14:32 +02:00
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0},
|
|
|
|
* if the specified {@code dstIndex} is less than {@code 0},
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code index + length} is greater than
|
|
|
|
* {@code this.capacity}, or
|
|
|
|
* if {@code dstIndex + length} is greater than
|
|
|
|
* {@code dst.length}
|
2008-08-08 10:14:32 +02:00
|
|
|
*/
|
2011-11-07 12:07:54 +01:00
|
|
|
void getBytes(int index, byte[] dst, int dstIndex, int length);
|
2008-08-08 10:14:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified destination starting at
|
|
|
|
* the specified absolute {@code index} until the destination's position
|
2008-09-24 11:48:32 +02:00
|
|
|
* reaches its limit.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer while the destination's {@code position} will be increased.
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code index + dst.remaining()} is greater than
|
|
|
|
* {@code this.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
*/
|
2011-11-07 12:07:54 +01:00
|
|
|
void getBytes(int index, ByteBuffer dst);
|
2008-08-08 10:14:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified stream starting at the
|
|
|
|
* specified absolute {@code index}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
2008-08-10 16:25:13 +02:00
|
|
|
* @param length the number of bytes to transfer
|
|
|
|
*
|
2008-08-08 10:14:32 +02:00
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code index + length} is greater than
|
|
|
|
* {@code this.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
* @throws IOException
|
|
|
|
* if the specified stream threw an exception during I/O
|
|
|
|
*/
|
2011-11-07 12:07:54 +01:00
|
|
|
void getBytes(int index, OutputStream out, int length) throws IOException;
|
2008-08-08 10:14:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified channel starting at the
|
|
|
|
* specified absolute {@code index}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
2008-08-10 16:25:13 +02:00
|
|
|
* @param length the maximum number of bytes to transfer
|
|
|
|
*
|
|
|
|
* @return the actual number of bytes written out to the specified channel
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code index + length} is greater than
|
|
|
|
* {@code this.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
* @throws IOException
|
|
|
|
* if the specified channel threw an exception during I/O
|
|
|
|
*/
|
2011-11-07 12:07:54 +01:00
|
|
|
int getBytes(int index, GatheringByteChannel out, int length) throws IOException;
|
2008-08-08 02:37:18 +02:00
|
|
|
|
2011-11-07 12:07:54 +01:00
|
|
|
/**
|
|
|
|
* Sets the specified boolean at the specified absolute {@code index} in this
|
|
|
|
* buffer.
|
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
|
|
|
* {@code index + 1} is greater than {@code this.capacity}
|
|
|
|
*/
|
|
|
|
void setBoolean(int index, boolean value);
|
|
|
|
|
2008-08-08 10:14:32 +02:00
|
|
|
/**
|
|
|
|
* Sets the specified byte at the specified absolute {@code index} in this
|
2010-03-03 06:35:01 +01:00
|
|
|
* buffer. The 24 high-order bits of the specified value are ignored.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code index + 1} is greater than {@code this.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
*/
|
2011-11-07 12:07:54 +01:00
|
|
|
void setByte(int index, int value);
|
2008-08-08 10:14:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the specified 16-bit short integer at the specified absolute
|
2010-03-03 06:35:01 +01:00
|
|
|
* {@code index} in this buffer. The 16 high-order bits of the specified
|
|
|
|
* value are ignored.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code index + 2} is greater than {@code this.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
*/
|
2010-03-03 06:35:01 +01:00
|
|
|
void setShort(int index, int value);
|
2008-08-08 10:14:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the specified 24-bit medium integer at the specified absolute
|
|
|
|
* {@code index} in this buffer. Please note that the most significant
|
|
|
|
* byte is ignored in the specified value.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code index + 3} is greater than {@code this.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void setMedium(int index, int value);
|
2008-08-08 10:14:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the specified 32-bit integer at the specified absolute
|
|
|
|
* {@code index} in this buffer.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code index + 4} is greater than {@code this.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void setInt(int index, int value);
|
2008-08-08 10:14:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the specified 64-bit long integer at the specified absolute
|
|
|
|
* {@code index} in this buffer.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-08 10:14:32 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* {@code index + 8} is greater than {@code this.capacity}
|
2008-08-08 10:14:32 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void setLong(int index, long value);
|
|
|
|
|
2009-11-25 07:51:43 +01:00
|
|
|
/**
|
|
|
|
* Sets the specified 2-byte UTF-16 character at the specified absolute
|
|
|
|
* {@code index} in this buffer.
|
2010-03-03 06:35:01 +01:00
|
|
|
* The 16 high-order bits of the specified value are ignored.
|
2009-11-25 07:51:43 +01:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
|
|
|
* {@code index + 2} is greater than {@code this.capacity}
|
|
|
|
*/
|
2010-03-03 06:35:01 +01:00
|
|
|
void setChar(int index, int value);
|
2009-11-25 07:51:43 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the specified 32-bit floating-point number at the specified
|
|
|
|
* absolute {@code index} in this buffer.
|
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
|
|
|
* {@code index + 4} is greater than {@code this.capacity}
|
|
|
|
*/
|
|
|
|
void setFloat(int index, float value);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the specified 64-bit floating-point number at the specified
|
|
|
|
* absolute {@code index} in this buffer.
|
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
|
|
|
* {@code index + 8} is greater than {@code this.capacity}
|
|
|
|
*/
|
|
|
|
void setDouble(int index, double value);
|
|
|
|
|
2008-08-10 07:09:55 +02:00
|
|
|
/**
|
|
|
|
* Transfers the specified source buffer's data to this buffer starting at
|
2010-05-06 09:33:26 +02:00
|
|
|
* the specified absolute {@code index} until the source buffer becomes
|
2008-08-10 16:25:13 +02:00
|
|
|
* unreadable. This method is basically same with
|
|
|
|
* {@link #setBytes(int, ChannelBuffer, int, int)}, except that this
|
2008-08-10 17:10:27 +02:00
|
|
|
* method increases the {@code readerIndex} of the source buffer by
|
2008-08-10 16:25:13 +02:00
|
|
|
* the number of the transferred bytes while
|
2010-05-06 09:33:26 +02:00
|
|
|
* {@link #setBytes(int, ChannelBuffer, int, int)} does not.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* the source buffer (i.e. {@code this}).
|
2008-08-10 07:09:55 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code index + src.readableBytes} is greater than
|
|
|
|
* {@code this.capacity}
|
2008-08-10 07:09:55 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void setBytes(int index, ChannelBuffer src);
|
2008-08-10 07:09:55 +02:00
|
|
|
|
2008-08-10 17:10:27 +02:00
|
|
|
/**
|
|
|
|
* Transfers the specified source buffer's data to this buffer starting at
|
|
|
|
* the specified absolute {@code index}. This method is basically same
|
|
|
|
* with {@link #setBytes(int, ChannelBuffer, int, int)}, except that this
|
|
|
|
* method increases the {@code readerIndex} of the source buffer by
|
|
|
|
* the number of the transferred bytes while
|
2010-05-06 09:33:26 +02:00
|
|
|
* {@link #setBytes(int, ChannelBuffer, int, int)} does not.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* the source buffer (i.e. {@code this}).
|
2008-08-10 17:10:27 +02:00
|
|
|
*
|
|
|
|
* @param length the number of bytes to transfer
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0},
|
|
|
|
* if {@code index + length} is greater than
|
|
|
|
* {@code this.capacity}, or
|
|
|
|
* if {@code length} is greater than {@code src.readableBytes}
|
|
|
|
*/
|
|
|
|
void setBytes(int index, ChannelBuffer src, int length);
|
|
|
|
|
2008-08-10 07:09:55 +02:00
|
|
|
/**
|
|
|
|
* Transfers the specified source buffer's data to this buffer starting at
|
|
|
|
* the specified absolute {@code index}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex}
|
|
|
|
* of both the source (i.e. {@code this}) and the destination.
|
2008-08-10 07:09:55 +02:00
|
|
|
*
|
2008-08-10 16:25:13 +02:00
|
|
|
* @param srcIndex the first index of the source
|
|
|
|
* @param length the number of bytes to transfer
|
|
|
|
*
|
2008-08-10 07:09:55 +02:00
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0},
|
|
|
|
* if the specified {@code srcIndex} is less than {@code 0},
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code index + length} is greater than
|
|
|
|
* {@code this.capacity}, or
|
|
|
|
* if {@code srcIndex + length} is greater than
|
|
|
|
* {@code src.capacity}
|
2008-08-10 07:09:55 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void setBytes(int index, ChannelBuffer src, int srcIndex, int length);
|
2008-08-10 07:09:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers the specified source array's data to this buffer starting at
|
|
|
|
* the specified absolute {@code index}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-10 07:09:55 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code index + src.length} is greater than
|
|
|
|
* {@code this.capacity}
|
2008-08-10 07:09:55 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void setBytes(int index, byte[] src);
|
2008-08-10 07:09:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers the specified source array's data to this buffer starting at
|
|
|
|
* the specified absolute {@code index}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-10 07:09:55 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0},
|
|
|
|
* if the specified {@code srcIndex} is less than {@code 0},
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code index + length} is greater than
|
|
|
|
* {@code this.capacity}, or
|
|
|
|
* if {@code srcIndex + length} is greater than {@code src.length}
|
2008-08-10 07:09:55 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void setBytes(int index, byte[] src, int srcIndex, int length);
|
2008-08-10 07:09:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers the specified source buffer's data to this buffer starting at
|
|
|
|
* the specified absolute {@code index} until the source buffer's position
|
2008-09-24 11:48:32 +02:00
|
|
|
* reaches its limit.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-10 07:09:55 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code index + src.remaining()} is greater than
|
|
|
|
* {@code this.capacity}
|
2008-08-10 07:09:55 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void setBytes(int index, ByteBuffer src);
|
2008-08-10 07:09:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers the content of the specified source stream to this buffer
|
|
|
|
* starting at the specified absolute {@code index}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-10 07:09:55 +02:00
|
|
|
*
|
2008-08-10 16:25:13 +02:00
|
|
|
* @param length the number of bytes to transfer
|
|
|
|
*
|
2008-08-20 05:09:23 +02:00
|
|
|
* @return the actual number of bytes read in from the specified channel.
|
|
|
|
* {@code -1} if the specified channel is closed.
|
|
|
|
*
|
2008-08-10 07:09:55 +02:00
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code index + length} is greater than {@code this.capacity}
|
2008-08-10 07:09:55 +02:00
|
|
|
* @throws IOException
|
|
|
|
* if the specified stream threw an exception during I/O
|
|
|
|
*/
|
2008-08-20 05:09:23 +02:00
|
|
|
int setBytes(int index, InputStream in, int length) throws IOException;
|
2008-08-10 07:09:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers the content of the specified source channel to this buffer
|
|
|
|
* starting at the specified absolute {@code index}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-10 07:09:55 +02:00
|
|
|
*
|
2008-08-10 16:25:13 +02:00
|
|
|
* @param length the maximum number of bytes to transfer
|
|
|
|
*
|
2008-08-20 05:09:23 +02:00
|
|
|
* @return the actual number of bytes read in from the specified channel.
|
|
|
|
* {@code -1} if the specified channel is closed.
|
2008-08-10 07:09:55 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code index + length} is greater than {@code this.capacity}
|
2008-08-10 07:09:55 +02:00
|
|
|
* @throws IOException
|
|
|
|
* if the specified channel threw an exception during I/O
|
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
int setBytes(int index, ScatteringByteChannel in, int length) throws IOException;
|
|
|
|
|
2008-08-10 07:09:55 +02:00
|
|
|
/**
|
|
|
|
* Fills this buffer with <tt>NUL (0x00)</tt> starting at the specified
|
|
|
|
* absolute {@code index}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-10 07:09:55 +02:00
|
|
|
*
|
|
|
|
* @param length the number of <tt>NUL</tt>s to write to the buffer
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code index} is less than {@code 0} or
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code index + length} is greater than {@code this.capacity}
|
2008-08-10 07:09:55 +02:00
|
|
|
*/
|
2008-08-08 10:14:32 +02:00
|
|
|
void setZero(int index, int length);
|
2011-11-07 12:07:54 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a boolean at the current {@code readerIndex} and increases
|
|
|
|
* the {@code readerIndex} by {@code 1} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if {@code this.readableBytes} is less than {@code 1}
|
|
|
|
*/
|
|
|
|
boolean readBoolean();
|
2008-08-08 10:14:32 +02:00
|
|
|
|
2008-08-10 07:09:55 +02:00
|
|
|
/**
|
|
|
|
* Gets a byte at the current {@code readerIndex} and increases
|
|
|
|
* the {@code readerIndex} by {@code 1} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code this.readableBytes} is less than {@code 1}
|
2008-08-10 07:09:55 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
byte readByte();
|
2008-08-10 07:09:55 +02:00
|
|
|
|
|
|
|
/**
|
2008-09-24 11:48:32 +02:00
|
|
|
* Gets an unsigned byte at the current {@code readerIndex} and increases
|
2008-08-10 07:09:55 +02:00
|
|
|
* the {@code readerIndex} by {@code 1} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code this.readableBytes} is less than {@code 1}
|
2008-08-10 07:09:55 +02:00
|
|
|
*/
|
2008-08-10 02:52:59 +02:00
|
|
|
short readUnsignedByte();
|
2008-08-10 07:09:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a 16-bit short integer at the current {@code readerIndex}
|
|
|
|
* and increases the {@code readerIndex} by {@code 2} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code this.readableBytes} is less than {@code 2}
|
2008-08-10 07:09:55 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
short readShort();
|
2008-08-10 07:09:55 +02:00
|
|
|
|
|
|
|
/**
|
2008-09-24 11:48:32 +02:00
|
|
|
* Gets an unsigned 16-bit short integer at the current {@code readerIndex}
|
2008-08-10 07:09:55 +02:00
|
|
|
* and increases the {@code readerIndex} by {@code 2} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code this.readableBytes} is less than {@code 2}
|
2008-08-10 07:09:55 +02:00
|
|
|
*/
|
2008-08-10 02:52:59 +02:00
|
|
|
int readUnsignedShort();
|
2008-08-10 07:09:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a 24-bit medium integer at the current {@code readerIndex}
|
|
|
|
* and increases the {@code readerIndex} by {@code 3} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code this.readableBytes} is less than {@code 3}
|
2008-08-10 07:09:55 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
int readMedium();
|
2008-08-10 07:09:55 +02:00
|
|
|
|
|
|
|
/**
|
2008-09-24 11:48:32 +02:00
|
|
|
* Gets an unsigned 24-bit medium integer at the current {@code readerIndex}
|
2008-08-10 07:09:55 +02:00
|
|
|
* and increases the {@code readerIndex} by {@code 3} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code this.readableBytes} is less than {@code 3}
|
2008-08-10 07:09:55 +02:00
|
|
|
*/
|
2008-08-10 02:52:59 +02:00
|
|
|
int readUnsignedMedium();
|
2008-08-10 07:09:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a 32-bit integer at the current {@code readerIndex}
|
|
|
|
* and increases the {@code readerIndex} by {@code 4} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code this.readableBytes} is less than {@code 4}
|
2008-08-10 07:09:55 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
int readInt();
|
2008-08-10 07:09:55 +02:00
|
|
|
|
|
|
|
/**
|
2008-09-24 11:48:32 +02:00
|
|
|
* Gets an unsigned 32-bit integer at the current {@code readerIndex}
|
2008-08-10 07:09:55 +02:00
|
|
|
* and increases the {@code readerIndex} by {@code 4} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code this.readableBytes} is less than {@code 4}
|
2008-08-10 07:09:55 +02:00
|
|
|
*/
|
2008-08-10 02:52:59 +02:00
|
|
|
long readUnsignedInt();
|
2008-08-10 07:09:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a 64-bit integer at the current {@code readerIndex}
|
|
|
|
* and increases the {@code readerIndex} by {@code 8} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code this.readableBytes} is less than {@code 8}
|
2008-08-10 07:09:55 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
long readLong();
|
|
|
|
|
2009-11-25 07:51:43 +01:00
|
|
|
/**
|
|
|
|
* Gets a 2-byte UTF-16 character at the current {@code readerIndex}
|
|
|
|
* and increases the {@code readerIndex} by {@code 2} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if {@code this.readableBytes} is less than {@code 2}
|
|
|
|
*/
|
|
|
|
char readChar();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a 32-bit floating point number at the current {@code readerIndex}
|
|
|
|
* and increases the {@code readerIndex} by {@code 4} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if {@code this.readableBytes} is less than {@code 4}
|
|
|
|
*/
|
|
|
|
float readFloat();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a 64-bit floating point number at the current {@code readerIndex}
|
|
|
|
* and increases the {@code readerIndex} by {@code 8} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if {@code this.readableBytes} is less than {@code 8}
|
|
|
|
*/
|
|
|
|
double readDouble();
|
|
|
|
|
2008-08-11 06:08:41 +02:00
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to a newly created buffer starting at
|
|
|
|
* the current {@code readerIndex} and increases the {@code readerIndex}
|
|
|
|
* by the number of the transferred bytes (= {@code length}).
|
|
|
|
* The returned buffer's {@code readerIndex} and {@code writerIndex} are
|
|
|
|
* {@code 0} and {@code length} respectively.
|
|
|
|
*
|
|
|
|
* @param length the number of bytes to transfer
|
|
|
|
*
|
|
|
|
* @return the newly created buffer which contains the transferred bytes
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if {@code length} is greater than {@code this.readableBytes}
|
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelBuffer readBytes(int length);
|
2008-08-11 06:08:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a new slice of this buffer's sub-region starting at the current
|
|
|
|
* {@code readerIndex} and increases the {@code readerIndex} by the size
|
|
|
|
* of the new slice (= {@code length}).
|
|
|
|
*
|
|
|
|
* @param length the size of the new slice
|
|
|
|
*
|
|
|
|
* @return the newly created slice
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if {@code length} is greater than {@code this.readableBytes}
|
|
|
|
*/
|
2008-08-10 01:47:40 +02:00
|
|
|
ChannelBuffer readSlice(int length);
|
2008-08-11 06:08:41 +02:00
|
|
|
|
2008-08-10 16:25:13 +02:00
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified destination starting at
|
|
|
|
* the current {@code readerIndex} until the destination becomes
|
2008-09-24 11:48:32 +02:00
|
|
|
* non-writable, and increases the {@code readerIndex} by the number of the
|
2008-08-10 16:25:13 +02:00
|
|
|
* transferred bytes. This method is basically same with
|
|
|
|
* {@link #readBytes(ChannelBuffer, int, int)}, except that this method
|
|
|
|
* increases the {@code writerIndex} of the destination by the number of
|
|
|
|
* the transferred bytes while {@link #readBytes(ChannelBuffer, int, int)}
|
2008-11-14 08:45:53 +01:00
|
|
|
* does not.
|
2008-08-10 16:25:13 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code dst.writableBytes} is greater than
|
|
|
|
* {@code this.readableBytes}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void readBytes(ChannelBuffer dst);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified destination starting at
|
|
|
|
* the current {@code readerIndex} and increases the {@code readerIndex}
|
|
|
|
* by the number of the transferred bytes (= {@code length}). This method
|
|
|
|
* is basically same with {@link #readBytes(ChannelBuffer, int, int)},
|
|
|
|
* except that this method increases the {@code writerIndex} of the
|
|
|
|
* destination by the number of the transferred bytes (= {@code length})
|
2008-11-14 08:45:53 +01:00
|
|
|
* while {@link #readBytes(ChannelBuffer, int, int)} does not.
|
2008-08-10 16:25:13 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code length} is greater than {@code this.readableBytes} or
|
|
|
|
* if {@code length} is greater than {@code dst.writableBytes}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void readBytes(ChannelBuffer dst, int length);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified destination starting at
|
|
|
|
* the current {@code readerIndex} and increases the {@code readerIndex}
|
|
|
|
* by the number of the transferred bytes (= {@code length}).
|
|
|
|
*
|
|
|
|
* @param dstIndex the first index of the destination
|
|
|
|
* @param length the number of bytes to transfer
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code dstIndex} is less than {@code 0},
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code length} is greater than {@code this.readableBytes}, or
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code dstIndex + length} is greater than
|
|
|
|
* {@code dst.capacity}
|
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void readBytes(ChannelBuffer dst, int dstIndex, int length);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified destination starting at
|
|
|
|
* the current {@code readerIndex} and increases the {@code readerIndex}
|
|
|
|
* by the number of the transferred bytes (= {@code dst.length}).
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code dst.length} is greater than {@code this.readableBytes}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void readBytes(byte[] dst);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified destination starting at
|
|
|
|
* the current {@code readerIndex} and increases the {@code readerIndex}
|
|
|
|
* by the number of the transferred bytes (= {@code length}).
|
|
|
|
*
|
|
|
|
* @param dstIndex the first index of the destination
|
|
|
|
* @param length the number of bytes to transfer
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code dstIndex} is less than {@code 0},
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code length} is greater than {@code this.readableBytes}, or
|
2008-08-10 16:25:13 +02:00
|
|
|
* if {@code dstIndex + length} is greater than {@code dst.length}
|
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void readBytes(byte[] dst, int dstIndex, int length);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified destination starting at
|
|
|
|
* the current {@code readerIndex} until the destination's position
|
2008-09-24 11:48:32 +02:00
|
|
|
* reaches its limit, and increases the {@code readerIndex} by the
|
2008-08-10 16:25:13 +02:00
|
|
|
* number of the transferred bytes.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code dst.remaining()} is greater than
|
|
|
|
* {@code this.readableBytes}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void readBytes(ByteBuffer dst);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified stream starting at the
|
|
|
|
* current {@code readerIndex}.
|
|
|
|
*
|
|
|
|
* @param length the number of bytes to transfer
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code length} is greater than {@code this.readableBytes}
|
2008-08-10 16:25:13 +02:00
|
|
|
* @throws IOException
|
|
|
|
* if the specified stream threw an exception during I/O
|
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void readBytes(OutputStream out, int length) throws IOException;
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers this buffer's data to the specified stream starting at the
|
|
|
|
* current {@code readerIndex}.
|
|
|
|
*
|
|
|
|
* @param length the maximum number of bytes to transfer
|
|
|
|
*
|
|
|
|
* @return the actual number of bytes written out to the specified channel
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code length} is greater than {@code this.readableBytes}
|
2008-08-10 16:25:13 +02:00
|
|
|
* @throws IOException
|
|
|
|
* if the specified channel threw an exception during I/O
|
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
int readBytes(GatheringByteChannel out, int length) throws IOException;
|
|
|
|
|
2008-08-10 16:25:13 +02:00
|
|
|
/**
|
|
|
|
* Increases the current {@code readerIndex} by the specified
|
|
|
|
* {@code length} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code length} is greater than {@code this.readableBytes}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void skipBytes(int length);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
2011-11-07 12:07:54 +01:00
|
|
|
/**
|
|
|
|
* Sets the specified boolean at the current {@code writerIndex}
|
|
|
|
* and increases the {@code writerIndex} by {@code 1} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if {@code this.writableBytes} is less than {@code 1}
|
|
|
|
*/
|
|
|
|
void writeBoolean(boolean value);
|
|
|
|
|
2008-08-10 16:25:13 +02:00
|
|
|
/**
|
|
|
|
* Sets the specified byte at the current {@code writerIndex}
|
|
|
|
* and increases the {@code writerIndex} by {@code 1} in this buffer.
|
2010-03-03 06:35:01 +01:00
|
|
|
* The 24 high-order bits of the specified value are ignored.
|
2008-08-10 16:25:13 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code this.writableBytes} is less than {@code 1}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2011-11-07 12:07:54 +01:00
|
|
|
void writeByte(int value);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the specified 16-bit short integer at the current
|
|
|
|
* {@code writerIndex} and increases the {@code writerIndex} by {@code 2}
|
2010-03-03 06:35:01 +01:00
|
|
|
* in this buffer. The 16 high-order bits of the specified value are ignored.
|
2008-08-10 16:25:13 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code this.writableBytes} is less than {@code 2}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2010-03-03 06:35:01 +01:00
|
|
|
void writeShort(int value);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the specified 24-bit medium integer at the current
|
|
|
|
* {@code writerIndex} and increases the {@code writerIndex} by {@code 3}
|
|
|
|
* in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code this.writableBytes} is less than {@code 3}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void writeMedium(int value);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the specified 32-bit integer at the current {@code writerIndex}
|
|
|
|
* and increases the {@code writerIndex} by {@code 4} in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code this.writableBytes} is less than {@code 4}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void writeInt(int value);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the specified 64-bit long integer at the current
|
|
|
|
* {@code writerIndex} and increases the {@code writerIndex} by {@code 8}
|
|
|
|
* in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code this.writableBytes} is less than {@code 8}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void writeLong(long value);
|
|
|
|
|
2009-11-25 07:51:43 +01:00
|
|
|
/**
|
|
|
|
* Sets the specified 2-byte UTF-16 character at the current
|
|
|
|
* {@code writerIndex} and increases the {@code writerIndex} by {@code 2}
|
2010-03-03 06:35:01 +01:00
|
|
|
* in this buffer. The 16 high-order bits of the specified value are ignored.
|
2009-11-25 07:51:43 +01:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if {@code this.writableBytes} is less than {@code 2}
|
|
|
|
*/
|
2010-03-03 06:35:01 +01:00
|
|
|
void writeChar(int value);
|
2009-11-25 07:51:43 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the specified 32-bit floating point number at the current
|
|
|
|
* {@code writerIndex} and increases the {@code writerIndex} by {@code 4}
|
|
|
|
* in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if {@code this.writableBytes} is less than {@code 4}
|
|
|
|
*/
|
|
|
|
void writeFloat(float value);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the specified 64-bit floating point number at the current
|
|
|
|
* {@code writerIndex} and increases the {@code writerIndex} by {@code 8}
|
|
|
|
* in this buffer.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if {@code this.writableBytes} is less than {@code 8}
|
|
|
|
*/
|
|
|
|
void writeDouble(double value);
|
|
|
|
|
2008-08-10 16:25:13 +02:00
|
|
|
/**
|
|
|
|
* Transfers the specified source buffer's data to this buffer starting at
|
|
|
|
* the current {@code writerIndex} until the source buffer becomes
|
|
|
|
* unreadable, and increases the {@code writerIndex} by the number of
|
|
|
|
* the transferred bytes. This method is basically same with
|
|
|
|
* {@link #writeBytes(ChannelBuffer, int, int)}, except that this method
|
|
|
|
* increases the {@code readerIndex} of the source buffer by the number of
|
|
|
|
* the transferred bytes while {@link #writeBytes(ChannelBuffer, int, int)}
|
2008-11-14 08:45:53 +01:00
|
|
|
* does not.
|
2008-08-10 16:25:13 +02:00
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code src.readableBytes} is greater than
|
|
|
|
* {@code this.writableBytes}
|
2011-12-09 05:43:34 +01:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void writeBytes(ChannelBuffer src);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers the specified source buffer's data to this buffer starting at
|
|
|
|
* the current {@code writerIndex} and increases the {@code writerIndex}
|
|
|
|
* by the number of the transferred bytes (= {@code length}). This method
|
|
|
|
* is basically same with {@link #writeBytes(ChannelBuffer, int, int)},
|
|
|
|
* except that this method increases the {@code readerIndex} of the source
|
|
|
|
* buffer by the number of the transferred bytes (= {@code length}) while
|
2008-11-14 08:45:53 +01:00
|
|
|
* {@link #writeBytes(ChannelBuffer, int, int)} does not.
|
2008-08-10 16:25:13 +02:00
|
|
|
*
|
|
|
|
* @param length the number of bytes to transfer
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code length} is greater than {@code this.writableBytes} or
|
|
|
|
* if {@code length} is greater then {@code src.readableBytes}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void writeBytes(ChannelBuffer src, int length);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers the specified source buffer's data to this buffer starting at
|
|
|
|
* the current {@code writerIndex} and increases the {@code writerIndex}
|
|
|
|
* by the number of the transferred bytes (= {@code length}).
|
|
|
|
*
|
|
|
|
* @param srcIndex the first index of the source
|
|
|
|
* @param length the number of bytes to transfer
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code srcIndex} is less than {@code 0},
|
|
|
|
* if {@code srcIndex + length} is greater than
|
|
|
|
* {@code src.capacity}, or
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code length} is greater than {@code this.writableBytes}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void writeBytes(ChannelBuffer src, int srcIndex, int length);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers the specified source array's data to this buffer starting at
|
|
|
|
* the current {@code writerIndex} and increases the {@code writerIndex}
|
|
|
|
* by the number of the transferred bytes (= {@code src.length}).
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code src.length} is greater than {@code this.writableBytes}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void writeBytes(byte[] src);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers the specified source array's data to this buffer starting at
|
|
|
|
* the current {@code writerIndex} and increases the {@code writerIndex}
|
|
|
|
* by the number of the transferred bytes (= {@code length}).
|
|
|
|
*
|
|
|
|
* @param srcIndex the first index of the source
|
|
|
|
* @param length the number of bytes to transfer
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if the specified {@code srcIndex} is less than {@code 0},
|
|
|
|
* if {@code srcIndex + length} is greater than
|
|
|
|
* {@code src.length}, or
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code length} is greater than {@code this.writableBytes}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void writeBytes(byte[] src, int srcIndex, int length);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers the specified source buffer's data to this buffer starting at
|
|
|
|
* the current {@code writerIndex} until the source buffer's position
|
2008-09-24 11:48:32 +02:00
|
|
|
* reaches its limit, and increases the {@code writerIndex} by the
|
2008-08-10 16:25:13 +02:00
|
|
|
* number of the transferred bytes.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code src.remaining()} is greater than
|
|
|
|
* {@code this.writableBytes}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void writeBytes(ByteBuffer src);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers the content of the specified stream to this buffer
|
|
|
|
* starting at the current {@code writerIndex} and increases the
|
|
|
|
* {@code writerIndex} by the number of the transferred bytes.
|
|
|
|
*
|
|
|
|
* @param length the number of bytes to transfer
|
|
|
|
*
|
2009-03-12 07:40:36 +01:00
|
|
|
* @return the actual number of bytes read in from the specified stream
|
|
|
|
*
|
2008-08-10 16:25:13 +02:00
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code length} is greater than {@code this.writableBytes}
|
2008-08-10 16:25:13 +02:00
|
|
|
* @throws IOException
|
|
|
|
* if the specified stream threw an exception during I/O
|
|
|
|
*/
|
2009-03-12 07:40:36 +01:00
|
|
|
int writeBytes(InputStream in, int length) throws IOException;
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers the content of the specified channel to this buffer
|
|
|
|
* starting at the current {@code writerIndex} and increases the
|
|
|
|
* {@code writerIndex} by the number of the transferred bytes.
|
|
|
|
*
|
|
|
|
* @param length the maximum number of bytes to transfer
|
|
|
|
*
|
|
|
|
* @return the actual number of bytes read in from the specified channel
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code length} is greater than {@code this.writableBytes}
|
2008-08-10 16:25:13 +02:00
|
|
|
* @throws IOException
|
|
|
|
* if the specified channel threw an exception during I/O
|
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
int writeBytes(ScatteringByteChannel in, int length) throws IOException;
|
|
|
|
|
2008-08-10 16:25:13 +02:00
|
|
|
/**
|
|
|
|
* Fills this buffer with <tt>NUL (0x00)</tt> starting at the current
|
|
|
|
* {@code writerIndex} and increases the {@code writerIndex} by the
|
|
|
|
* specified {@code length}.
|
|
|
|
*
|
|
|
|
* @param length the number of <tt>NUL</tt>s to write to the buffer
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
2008-08-10 17:10:27 +02:00
|
|
|
* if {@code length} is greater than {@code this.writableBytes}
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 10:14:32 +02:00
|
|
|
void writeZero(int length);
|
2008-08-08 02:37:18 +02:00
|
|
|
|
2008-08-11 06:08:41 +02:00
|
|
|
/**
|
|
|
|
* Locates the first occurrence of the specified {@code value} in this
|
|
|
|
* buffer. The search takes place from the specified {@code fromIndex}
|
|
|
|
* (inclusive) to the specified {@code toIndex} (exclusive).
|
|
|
|
* <p>
|
|
|
|
* If {@code fromIndex} is greater than {@code toIndex}, the search is
|
|
|
|
* performed in a reversed order.
|
2009-04-24 15:56:35 +02:00
|
|
|
* <p>
|
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-11 06:08:41 +02:00
|
|
|
*
|
|
|
|
* @return the absolute index of the first occurrence if found.
|
|
|
|
* {@code -1} otherwise.
|
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
int indexOf(int fromIndex, int toIndex, byte value);
|
2008-08-11 06:08:41 +02:00
|
|
|
|
|
|
|
/**
|
2010-01-20 06:55:16 +01:00
|
|
|
* Locates the first place where the specified {@code indexFinder}
|
2008-08-11 06:08:41 +02:00
|
|
|
* returns {@code true}. The search takes place from the specified
|
|
|
|
* {@code fromIndex} (inclusive) to the specified {@code toIndex}
|
|
|
|
* (exclusive).
|
|
|
|
* <p>
|
|
|
|
* If {@code fromIndex} is greater than {@code toIndex}, the search is
|
|
|
|
* performed in a reversed order.
|
2009-04-24 15:56:35 +02:00
|
|
|
* <p>
|
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-11 06:08:41 +02:00
|
|
|
*
|
|
|
|
* @return the absolute index where the specified {@code indexFinder}
|
2010-01-20 06:55:16 +01:00
|
|
|
* returned {@code true}. {@code -1} if the {@code indexFinder}
|
|
|
|
* did not return {@code true} at all.
|
2008-08-11 06:08:41 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
int indexOf(int fromIndex, int toIndex, ChannelBufferIndexFinder indexFinder);
|
|
|
|
|
2010-01-20 06:55:16 +01:00
|
|
|
/**
|
|
|
|
* Locates the first occurrence of the specified {@code value} in this
|
|
|
|
* buffer. The search takes place from the current {@code readerIndex}
|
|
|
|
* (inclusive) to the current {@code writerIndex} (exclusive).
|
|
|
|
* <p>
|
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
|
|
|
*
|
|
|
|
* @return the number of bytes between the current {@code readerIndex}
|
|
|
|
* and the first occurrence if found. {@code -1} otherwise.
|
|
|
|
*/
|
|
|
|
int bytesBefore(byte value);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Locates the first place where the specified {@code indexFinder} returns
|
|
|
|
* {@code true}. The search takes place from the current {@code readerIndex}
|
|
|
|
* (inclusive) to the current {@code writerIndex}.
|
|
|
|
* <p>
|
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
|
|
|
*
|
|
|
|
* @return the number of bytes between the current {@code readerIndex}
|
|
|
|
* and the first place where the {@code indexFinder} returned
|
|
|
|
* {@code true}. {@code -1} if the {@code indexFinder} did not
|
|
|
|
* return {@code true} at all.
|
|
|
|
*/
|
|
|
|
int bytesBefore(ChannelBufferIndexFinder indexFinder);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Locates the first occurrence of the specified {@code value} in this
|
|
|
|
* buffer. The search starts from the current {@code readerIndex}
|
|
|
|
* (inclusive) and lasts for the specified {@code length}.
|
|
|
|
* <p>
|
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
|
|
|
*
|
|
|
|
* @return the number of bytes between the current {@code readerIndex}
|
|
|
|
* and the first occurrence if found. {@code -1} otherwise.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if {@code length} is greater than {@code this.readableBytes}
|
|
|
|
*/
|
|
|
|
int bytesBefore(int length, byte value);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Locates the first place where the specified {@code indexFinder} returns
|
|
|
|
* {@code true}. The search starts the current {@code readerIndex}
|
|
|
|
* (inclusive) and lasts for the specified {@code length}.
|
|
|
|
* <p>
|
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
|
|
|
*
|
|
|
|
* @return the number of bytes between the current {@code readerIndex}
|
|
|
|
* and the first place where the {@code indexFinder} returned
|
|
|
|
* {@code true}. {@code -1} if the {@code indexFinder} did not
|
|
|
|
* return {@code true} at all.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if {@code length} is greater than {@code this.readableBytes}
|
|
|
|
*/
|
|
|
|
int bytesBefore(int length, ChannelBufferIndexFinder indexFinder);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Locates the first occurrence of the specified {@code value} in this
|
|
|
|
* buffer. The search starts from the specified {@code index} (inclusive)
|
|
|
|
* and lasts for the specified {@code length}.
|
|
|
|
* <p>
|
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
|
|
|
*
|
|
|
|
* @return the number of bytes between the specified {@code index}
|
|
|
|
* and the first occurrence if found. {@code -1} otherwise.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if {@code index + length} is greater than {@code this.capacity}
|
|
|
|
*/
|
|
|
|
int bytesBefore(int index, int length, byte value);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Locates the first place where the specified {@code indexFinder} returns
|
|
|
|
* {@code true}. The search starts the specified {@code index} (inclusive)
|
|
|
|
* and lasts for the specified {@code length}.
|
|
|
|
* <p>
|
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
|
|
|
*
|
|
|
|
* @return the number of bytes between the specified {@code index}
|
|
|
|
* and the first place where the {@code indexFinder} returned
|
|
|
|
* {@code true}. {@code -1} if the {@code indexFinder} did not
|
|
|
|
* return {@code true} at all.
|
|
|
|
*
|
|
|
|
* @throws IndexOutOfBoundsException
|
|
|
|
* if {@code index + length} is greater than {@code this.capacity}
|
|
|
|
*/
|
|
|
|
int bytesBefore(int index, int length, ChannelBufferIndexFinder indexFinder);
|
|
|
|
|
2008-08-10 16:25:13 +02:00
|
|
|
/**
|
|
|
|
* Returns a copy of this buffer's readable bytes. Modifying the content
|
2008-11-14 08:45:53 +01:00
|
|
|
* of the returned buffer or this buffer does not affect each other at all.
|
2008-08-10 16:25:13 +02:00
|
|
|
* This method is identical to {@code buf.copy(buf.readerIndex(), buf.readableBytes())}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2011-12-09 05:43:34 +01:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelBuffer copy();
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a copy of this buffer's sub-region. Modifying the content of
|
2008-11-14 08:45:53 +01:00
|
|
|
* the returned buffer or this buffer does not affect each other at all.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelBuffer copy(int index, int length);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a slice of this buffer's readable bytes. Modifying the content
|
|
|
|
* of the returned buffer or this buffer affects each other's content
|
|
|
|
* while they maintain separate indexes and marks. This method is
|
|
|
|
* identical to {@code buf.slice(buf.readerIndex(), buf.readableBytes())}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelBuffer slice();
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a slice of this buffer's sub-region. Modifying the content of
|
|
|
|
* the returned buffer or this buffer affects each other's content while
|
2009-05-08 10:21:13 +02:00
|
|
|
* they maintain separate indexes and marks.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelBuffer slice(int index, int length);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a buffer which shares the whole region of this buffer.
|
|
|
|
* Modifying the content of the returned buffer or this buffer affects
|
|
|
|
* each other's content while they maintain separate indexes and marks.
|
|
|
|
* This method is identical to {@code buf.slice(0, buf.capacity())}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelBuffer duplicate();
|
|
|
|
|
2008-08-10 16:25:13 +02:00
|
|
|
/**
|
|
|
|
* Converts this buffer's readable bytes into a NIO buffer. The returned
|
|
|
|
* buffer might or might not share the content with this buffer, while
|
|
|
|
* they have separate indexes and marks. This method is identical to
|
|
|
|
* {@code buf.toByteBuffer(buf.readerIndex(), buf.readableBytes())}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ByteBuffer toByteBuffer();
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts this buffer's sub-region into a NIO buffer. The returned
|
|
|
|
* buffer might or might not share the content with this buffer, while
|
|
|
|
* they have separate indexes and marks.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ByteBuffer toByteBuffer(int index, int length);
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts this buffer's readable bytes into an array of NIO buffers.
|
|
|
|
* The returned buffers might or might not share the content with this
|
|
|
|
* buffer, while they have separate indexes and marks. This method is
|
|
|
|
* identical to {@code buf.toByteBuffers(buf.readerIndex(), buf.readableBytes())}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ByteBuffer[] toByteBuffers();
|
2008-08-10 16:25:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts this buffer's sub-region into an array of NIO buffers.
|
|
|
|
* The returned buffers might or might not share the content with this
|
|
|
|
* buffer, while they have separate indexes and marks.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-10 16:25:13 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ByteBuffer[] toByteBuffers(int index, int length);
|
|
|
|
|
2009-11-25 08:08:52 +01:00
|
|
|
/**
|
|
|
|
* Returns {@code true} if and only if this buffer has a backing byte array.
|
|
|
|
* If this method returns true, you can safely call {@link #array()} and
|
|
|
|
* {@link #arrayOffset()}.
|
|
|
|
*/
|
|
|
|
boolean hasArray();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the backing byte array of this buffer.
|
|
|
|
*
|
|
|
|
* @throws UnsupportedOperationException
|
|
|
|
* if there no accessible backing byte array
|
|
|
|
*/
|
|
|
|
byte[] array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the offset of the first byte within the backing byte array of
|
|
|
|
* this buffer.
|
|
|
|
*
|
|
|
|
* @throws UnsupportedOperationException
|
|
|
|
* if there no accessible backing byte array
|
|
|
|
*/
|
|
|
|
int arrayOffset();
|
|
|
|
|
2008-08-10 16:25:13 +02:00
|
|
|
/**
|
|
|
|
* Decodes this buffer's readable bytes into a string with the specified
|
|
|
|
* character set name. This method is identical to
|
|
|
|
* {@code buf.toString(buf.readerIndex(), buf.readableBytes(), charsetName)}.
|
2009-04-24 15:56:35 +02:00
|
|
|
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
|
|
|
* this buffer.
|
2008-08-10 16:25:13 +02:00
|
|
|
*
|
|
|
|
* @throws UnsupportedCharsetException
|
|
|
|
* if the specified character set name is not supported by the
|
|
|
|
* current VM
|
|
|
|
*/
|
2009-12-29 06:52:00 +01:00
|
|
|
String toString(Charset charset);
|
|
|
|
|
2010-01-15 06:28:17 +01:00
|
|
|
/**
|
|
|
|
* Decodes this buffer's sub-region into a string with the specified
|
|
|
|
* character set. This method does not modify {@code readerIndex} or
|
|
|
|
* {@code writerIndex} of this buffer.
|
|
|
|
*/
|
|
|
|
String toString(int index, int length, Charset charset);
|
|
|
|
|
2008-08-08 02:37:18 +02:00
|
|
|
/**
|
|
|
|
* Returns a hash code which was calculated from the content of this
|
|
|
|
* buffer. If there's a byte array which is
|
|
|
|
* {@linkplain #equals(Object) equal to} this array, both arrays should
|
|
|
|
* return the same value.
|
|
|
|
*/
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2008-08-08 02:37:18 +02:00
|
|
|
int hashCode();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if the content of the specified buffer is identical to the
|
|
|
|
* content of this array. 'Identical' here means:
|
|
|
|
* <ul>
|
|
|
|
* <li>the size of the contents of the two buffers are same and</li>
|
|
|
|
* <li>every single byte of the content of the two buffers are same.</li>
|
|
|
|
* </ul>
|
2008-11-14 08:45:53 +01:00
|
|
|
* Please note that it does not compare {@link #readerIndex()} nor
|
2008-08-08 02:37:18 +02:00
|
|
|
* {@link #writerIndex()}. This method also returns {@code false} for
|
|
|
|
* {@code null} and an object which is not an instance of
|
|
|
|
* {@link ChannelBuffer} type.
|
|
|
|
*/
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2008-08-08 02:37:18 +02:00
|
|
|
boolean equals(Object obj);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compares the content of the specified buffer to the content of this
|
|
|
|
* buffer. Comparison is performed in the same manner with the string
|
|
|
|
* comparison functions of various languages such as {@code strcmp},
|
|
|
|
* {@code memcmp} and {@link String#compareTo(String)}.
|
|
|
|
*/
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2008-08-08 02:37:18 +02:00
|
|
|
int compareTo(ChannelBuffer buffer);
|
|
|
|
|
|
|
|
/**
|
2008-11-14 08:45:53 +01:00
|
|
|
* Returns the string representation of this buffer. This method does not
|
2008-08-08 02:37:18 +02:00
|
|
|
* necessarily return the whole content of the buffer but returns
|
|
|
|
* the values of the key properties such as {@link #readerIndex()},
|
2008-08-10 17:43:04 +02:00
|
|
|
* {@link #writerIndex()} and {@link #capacity()}.
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2008-08-08 02:37:18 +02:00
|
|
|
String toString();
|
|
|
|
}
|