org.jboss.netty.buffer
类 TruncatedChannelBuffer

java.lang.Object
  继承者 org.jboss.netty.buffer.AbstractChannelBuffer
      继承者 org.jboss.netty.buffer.TruncatedChannelBuffer
所有已实现的接口:
java.lang.Comparable<ChannelBuffer>, ChannelBuffer, WrappedChannelBuffer

public class TruncatedChannelBuffer
extends AbstractChannelBuffer
implements WrappedChannelBuffer

一个隐藏父缓冲某个索引之后数据的派生缓冲. 强烈建议使用 ChannelBuffer.slice()ChannelBuffer.slice(int, int)代替使用构造方法.


构造方法摘要
TruncatedChannelBuffer(ChannelBuffer buffer, int length)
           
 
方法摘要
 byte[] array()
          返回该缓冲支持的字节数组.
 int arrayOffset()
          返回该缓冲内部的字节数组的第一个字节的偏移量
 int capacity()
          返回缓冲区包含字节数量.
 ChannelBuffer copy(int index, int length)
          返回该缓冲的子部分,修改其中任何一个缓冲对另一个都不会有影响.且并不修改该缓冲区的 readerIndexwriterIndex.
 ChannelBuffer duplicate()
          返回该缓冲全部分.修改其中任何一个缓冲对另一个都会有影响,不过它们维护着各自的索引和标记,该方法等同于 buf.slice(0, buf.capacity()).
 ChannelBufferFactory factory()
          返回一个用于创建与这个缓冲相同类型和默认ByteOrderChannelBuffer的工厂.
 byte getByte(int index)
          在指定绝对值index处获取一个字节.该方法并不修改缓冲的 readerIndexwriterIndex.
 void getBytes(int index, byte[] dst, int dstIndex, int length)
          在该缓冲区指定绝对值index开始处传输数据到指定的目标.
 void getBytes(int index, java.nio.ByteBuffer dst)
          在该缓冲区指定绝对值index开始处传输数据到指定的目标,直到目标的position到达限制为止.
 void getBytes(int index, ChannelBuffer dst, int dstIndex, int length)
          在该缓冲区指定绝对值index开始处传输数据到指定的目标.
 int getBytes(int index, java.nio.channels.GatheringByteChannel out, int length)
          在该缓冲区指定绝对值index开始处传输数据到指定的通道.该方法并不修改该缓冲区的 readerIndexwriterIndex.
 void getBytes(int index, java.io.OutputStream out, int length)
          在该缓冲区指定绝对值index开始处传输数据到指定的数据流.该方法并不修改该缓冲区的 readerIndexwriterIndex.
 int getInt(int index)
          在指定绝对值index处获取一个32位符号整型.该方法并不修改缓冲的 readerIndexwriterIndex.
 long getLong(int index)
          在指定绝对值index处获取一个64位整型.该方法并不修改缓冲的 readerIndexwriterIndex.
 short getShort(int index)
          在指定绝对值index处获取一个16位整型.该方法并不修改缓冲的 readerIndexwriterIndex.
 int getUnsignedMedium(int index)
          在指定绝对值index处获取一个24位无符号整型.该方法并不修改缓冲的 readerIndexwriterIndex.
 boolean hasArray()
          只有当该缓冲有一个支持的字节数组才返回true,如果该方法返回true,你可以安全的调用 ChannelBuffer.array()ChannelBuffer.arrayOffset().
 boolean isDirect()
          判断该缓冲区是否是由NIO direct缓冲支持.
 java.nio.ByteOrder order()
          返回缓冲区的 字节序.
 void setByte(int index, int value)
          在指定绝对值index处设置指定的字节. 24高序位会被忽略.
 void setBytes(int index, byte[] src, int srcIndex, int length)
          把指定的源数组的数据传输到该缓冲区指定绝对值index的位置 .
 void setBytes(int index, java.nio.ByteBuffer src)
          把指定的源缓冲的数据传输到该缓冲区指定绝对值index的位置 ,直到源缓冲的position到达限制为止.
 void setBytes(int index, ChannelBuffer src, int srcIndex, int length)
          把指定的源缓冲区的数据传输到该缓冲区指定绝对值index的位置 .
 int setBytes(int index, java.io.InputStream in, int length)
          把指定的源输入流的数据传输到该缓冲区指定绝对值index的位置 .
 int setBytes(int index, java.nio.channels.ScatteringByteChannel in, int length)
          把指定的源通道的数据传输到该缓冲区指定绝对值index的位置 .
 void setInt(int index, int value)
          在指定绝对值index处设置指定的32位整型.
 void setLong(int index, long value)
          在指定绝对值index处设置指定的64位长整型.
 void setMedium(int index, int value)
          在指定绝对值index处设置指定的24位整型.
 void setShort(int index, int value)
          在指定绝对值index处设置指定的16位短整型. 16高序位会被忽略.
 ChannelBuffer slice(int index, int length)
          返回该缓冲子部分的切片.修改其中任何一个缓冲对另一个都会有影响,不过它们维护着各自的索引和标记,且并不修改该缓冲区的 readerIndexwriterIndex.
 java.nio.ByteBuffer toByteBuffer(int index, int length)
          转化该缓冲区的子部分到一个NIO缓冲区.返回的缓冲区可能有或没有和该缓冲共享内容,但是它们有各自的索引和标记.
 ChannelBuffer unwrap()
          返回该缓冲包装的父缓冲.
 
从类 org.jboss.netty.buffer.AbstractChannelBuffer 继承的方法
bytesBefore, bytesBefore, bytesBefore, bytesBefore, bytesBefore, bytesBefore, clear, compareTo, copy, discardReadBytes, ensureWritableBytes, equals, getBytes, getBytes, getBytes, getChar, getDouble, getFloat, getMedium, getUnsignedByte, getUnsignedInt, getUnsignedShort, hashCode, indexOf, indexOf, markReaderIndex, markWriterIndex, readable, readableBytes, readByte, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readChar, readDouble, readerIndex, readerIndex, readFloat, readInt, readLong, readMedium, readShort, readSlice, readSlice, readUnsignedByte, readUnsignedInt, readUnsignedMedium, readUnsignedShort, resetReaderIndex, resetWriterIndex, setBytes, setBytes, setBytes, setChar, setDouble, setFloat, setIndex, setZero, skipBytes, skipBytes, slice, toByteBuffer, toByteBuffers, toByteBuffers, toString, toString, toString, toString, toString, toString, toString, writable, writableBytes, writeByte, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeChar, writeDouble, writeFloat, writeInt, writeLong, writeMedium, writerIndex, writerIndex, writeShort, writeZero
 
从类 java.lang.Object 继承的方法
getClass, notify, notifyAll, wait, wait, wait
 
从接口 org.jboss.netty.buffer.ChannelBuffer 继承的方法
bytesBefore, bytesBefore, bytesBefore, bytesBefore, bytesBefore, bytesBefore, clear, compareTo, copy, discardReadBytes, ensureWritableBytes, equals, getBytes, getBytes, getBytes, getChar, getDouble, getFloat, getMedium, getUnsignedByte, getUnsignedInt, getUnsignedShort, hashCode, indexOf, indexOf, markReaderIndex, markWriterIndex, readable, readableBytes, readByte, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readChar, readDouble, readerIndex, readerIndex, readFloat, readInt, readLong, readMedium, readShort, readSlice, readSlice, readUnsignedByte, readUnsignedInt, readUnsignedMedium, readUnsignedShort, resetReaderIndex, resetWriterIndex, setBytes, setBytes, setBytes, setChar, setDouble, setFloat, setIndex, setZero, skipBytes, skipBytes, slice, toByteBuffer, toByteBuffers, toByteBuffers, toString, toString, toString, toString, toString, toString, toString, writable, writableBytes, writeByte, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeChar, writeDouble, writeFloat, writeInt, writeLong, writeMedium, writerIndex, writerIndex, writeShort, writeZero
 

构造方法详细信息

TruncatedChannelBuffer

public TruncatedChannelBuffer(ChannelBuffer buffer,
                              int length)
方法详细信息

unwrap

public ChannelBuffer unwrap()
从接口 WrappedChannelBuffer 复制的描述
返回该缓冲包装的父缓冲.

指定者:
接口 WrappedChannelBuffer 中的 unwrap

factory

public ChannelBufferFactory factory()
从接口 ChannelBuffer 复制的描述
返回一个用于创建与这个缓冲相同类型和默认ByteOrderChannelBuffer的工厂.

指定者:
接口 ChannelBuffer 中的 factory

order

public java.nio.ByteOrder order()
从接口 ChannelBuffer 复制的描述
返回缓冲区的 字节序.

指定者:
接口 ChannelBuffer 中的 order

isDirect

public boolean isDirect()
从接口 ChannelBuffer 复制的描述
判断该缓冲区是否是由NIO direct缓冲支持.

指定者:
接口 ChannelBuffer 中的 isDirect

capacity

public int capacity()
从接口 ChannelBuffer 复制的描述
返回缓冲区包含字节数量.

指定者:
接口 ChannelBuffer 中的 capacity

hasArray

public boolean hasArray()
从接口 ChannelBuffer 复制的描述
只有当该缓冲有一个支持的字节数组才返回true,如果该方法返回true,你可以安全的调用 ChannelBuffer.array()ChannelBuffer.arrayOffset().

指定者:
接口 ChannelBuffer 中的 hasArray

array

public byte[] array()
从接口 ChannelBuffer 复制的描述
返回该缓冲支持的字节数组.

指定者:
接口 ChannelBuffer 中的 array

arrayOffset

public int arrayOffset()
从接口 ChannelBuffer 复制的描述
返回该缓冲内部的字节数组的第一个字节的偏移量

指定者:
接口 ChannelBuffer 中的 arrayOffset

getByte

public byte getByte(int index)
从接口 ChannelBuffer 复制的描述
在指定绝对值index处获取一个字节.该方法并不修改缓冲的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 getByte

getShort

public short getShort(int index)
从接口 ChannelBuffer 复制的描述
在指定绝对值index处获取一个16位整型.该方法并不修改缓冲的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 getShort

getUnsignedMedium

public int getUnsignedMedium(int index)
从接口 ChannelBuffer 复制的描述
在指定绝对值index处获取一个24位无符号整型.该方法并不修改缓冲的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 getUnsignedMedium

getInt

public int getInt(int index)
从接口 ChannelBuffer 复制的描述
在指定绝对值index处获取一个32位符号整型.该方法并不修改缓冲的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 getInt

getLong

public long getLong(int index)
从接口 ChannelBuffer 复制的描述
在指定绝对值index处获取一个64位整型.该方法并不修改缓冲的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 getLong

duplicate

public ChannelBuffer duplicate()
从接口 ChannelBuffer 复制的描述
返回该缓冲全部分.修改其中任何一个缓冲对另一个都会有影响,不过它们维护着各自的索引和标记,该方法等同于 buf.slice(0, buf.capacity()). 且并不修改该缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 duplicate

copy

public ChannelBuffer copy(int index,
                          int length)
从接口 ChannelBuffer 复制的描述
返回该缓冲的子部分,修改其中任何一个缓冲对另一个都不会有影响.且并不修改该缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 copy

slice

public ChannelBuffer slice(int index,
                           int length)
从接口 ChannelBuffer 复制的描述
返回该缓冲子部分的切片.修改其中任何一个缓冲对另一个都会有影响,不过它们维护着各自的索引和标记,且并不修改该缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 slice

getBytes

public void getBytes(int index,
                     ChannelBuffer dst,
                     int dstIndex,
                     int length)
从接口 ChannelBuffer 复制的描述
在该缓冲区指定绝对值index开始处传输数据到指定的目标. 该方法并不修改源缓冲区和目标缓冲区的 readerIndexwriterIndex

指定者:
接口 ChannelBuffer 中的 getBytes
dstIndex - 目标缓冲区的开始索引
length - 传输字节数量

getBytes

public void getBytes(int index,
                     byte[] dst,
                     int dstIndex,
                     int length)
从接口 ChannelBuffer 复制的描述
在该缓冲区指定绝对值index开始处传输数据到指定的目标. 该方法并不修改该缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 getBytes
dstIndex - 目标缓冲区的开始索引
length - 传输的字节数量

getBytes

public void getBytes(int index,
                     java.nio.ByteBuffer dst)
从接口 ChannelBuffer 复制的描述
在该缓冲区指定绝对值index开始处传输数据到指定的目标,直到目标的position到达限制为止. 该方法并不修改该缓冲区的 readerIndexwriterIndex,但会增加目标的 position.

指定者:
接口 ChannelBuffer 中的 getBytes

setByte

public void setByte(int index,
                    int value)
从接口 ChannelBuffer 复制的描述
在指定绝对值index处设置指定的字节. 24高序位会被忽略. 该方法并不修改该缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 setByte

setShort

public void setShort(int index,
                     int value)
从接口 ChannelBuffer 复制的描述
在指定绝对值index处设置指定的16位短整型. 16高序位会被忽略. 该方法并不修改该缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 setShort

setMedium

public void setMedium(int index,
                      int value)
从接口 ChannelBuffer 复制的描述
在指定绝对值index处设置指定的24位整型. 请注意大多数有意义的字节会被忽略. 该方法并不修改该缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 setMedium

setInt

public void setInt(int index,
                   int value)
从接口 ChannelBuffer 复制的描述
在指定绝对值index处设置指定的32位整型. 该方法并不修改该缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 setInt

setLong

public void setLong(int index,
                    long value)
从接口 ChannelBuffer 复制的描述
在指定绝对值index处设置指定的64位长整型. 该方法并不修改该缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 setLong

setBytes

public void setBytes(int index,
                     byte[] src,
                     int srcIndex,
                     int length)
从接口 ChannelBuffer 复制的描述
把指定的源数组的数据传输到该缓冲区指定绝对值index的位置 . 该方法并不修改该缓冲区和源缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 setBytes

setBytes

public void setBytes(int index,
                     ChannelBuffer src,
                     int srcIndex,
                     int length)
从接口 ChannelBuffer 复制的描述
把指定的源缓冲区的数据传输到该缓冲区指定绝对值index的位置 . 该方法并不修改该缓冲区和源缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 setBytes
srcIndex - 源缓冲区的开始索引
length - 传输的字节数

setBytes

public void setBytes(int index,
                     java.nio.ByteBuffer src)
从接口 ChannelBuffer 复制的描述
把指定的源缓冲的数据传输到该缓冲区指定绝对值index的位置 ,直到源缓冲的position到达限制为止. 该方法并不修改该缓冲区和源缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 setBytes

getBytes

public void getBytes(int index,
                     java.io.OutputStream out,
                     int length)
              throws java.io.IOException
从接口 ChannelBuffer 复制的描述
在该缓冲区指定绝对值index开始处传输数据到指定的数据流.该方法并不修改该缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 getBytes
length - 传输字节的数量
抛出:
java.io.IOException - 指定的数据流在I/O期间抛出的异常

getBytes

public int getBytes(int index,
                    java.nio.channels.GatheringByteChannel out,
                    int length)
             throws java.io.IOException
从接口 ChannelBuffer 复制的描述
在该缓冲区指定绝对值index开始处传输数据到指定的通道.该方法并不修改该缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 getBytes
length - 传输字节的最大数
返回:
传输的实际字节数
抛出:
java.io.IOException - 指定的通道在I/O期间抛出的异常

setBytes

public int setBytes(int index,
                    java.io.InputStream in,
                    int length)
             throws java.io.IOException
从接口 ChannelBuffer 复制的描述
把指定的源输入流的数据传输到该缓冲区指定绝对值index的位置 . 该方法并不修改该缓冲区和源缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 setBytes
length - 传输的字节数
返回:
返回从输入流读取的实际字节数.如果指定的输入流被关闭则返回 -1.
抛出:
java.io.IOException - 输入流在IO期间抛出的异常

setBytes

public int setBytes(int index,
                    java.nio.channels.ScatteringByteChannel in,
                    int length)
             throws java.io.IOException
从接口 ChannelBuffer 复制的描述
把指定的源通道的数据传输到该缓冲区指定绝对值index的位置 . 该方法并不修改该缓冲区和源缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 setBytes
length - 最大的传输字节数
返回:
返回从通道读取的实际字节数.如果指定的通道被关闭则返回 -1.
抛出:
java.io.IOException - 通道在IO期间抛出的异常

toByteBuffer

public java.nio.ByteBuffer toByteBuffer(int index,
                                        int length)
从接口 ChannelBuffer 复制的描述
转化该缓冲区的子部分到一个NIO缓冲区.返回的缓冲区可能有或没有和该缓冲共享内容,但是它们有各自的索引和标记. 且并不修改该缓冲区的 readerIndexwriterIndex.

指定者:
接口 ChannelBuffer 中的 toByteBuffer