org.jboss.netty.buffer
Class LittleEndianHeapChannelBuffer

java.lang.Object
  extended by org.jboss.netty.buffer.AbstractChannelBuffer
      extended by org.jboss.netty.buffer.HeapChannelBuffer
          extended by org.jboss.netty.buffer.LittleEndianHeapChannelBuffer
All Implemented Interfaces:
Comparable<ChannelBuffer>, ChannelBuffer

public class LittleEndianHeapChannelBuffer
extends HeapChannelBuffer

A little-endian Java heap buffer. It is recommended to use ChannelBuffers.buffer(ByteOrder, int) and ChannelBuffers.wrappedBuffer(ByteOrder, byte[]) instead of calling the constructor explicitly.

Version:
$Rev: 1685 $, $Date: 2009-08-28 16:15:49 +0900 (금, 28 8 2009) $
Author:
The Netty Project (netty-dev@lists.jboss.org), Trustin Lee (tlee@redhat.com)

Field Summary
 
Fields inherited from class org.jboss.netty.buffer.HeapChannelBuffer
array
 
Constructor Summary
LittleEndianHeapChannelBuffer(byte[] array)
          Creates a new little-endian heap buffer with an existing byte array.
LittleEndianHeapChannelBuffer(int length)
          Creates a new little-endian heap buffer with a newly allocated byte array.
 
Method Summary
 ChannelBuffer copy(int index, int length)
          Returns a copy of this buffer's sub-region.
 ChannelBuffer duplicate()
          Returns a buffer which shares the whole region of this buffer.
 ChannelBufferFactory factory()
          Returns the factory which creates a ChannelBuffer whose type and default ByteOrder are same with this buffer.
 int getInt(int index)
          Gets a 32-bit integer at the specified absolute index in this buffer.
 long getLong(int index)
          Gets a 64-bit long integer at the specified absolute index in this buffer.
 short getShort(int index)
          Gets a 16-bit short integer at the specified absolute index in this buffer.
 int getUnsignedMedium(int index)
          Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer.
 ByteOrder order()
          Returns the endianness of this buffer.
 void setInt(int index, int value)
          Sets the specified 32-bit integer at the specified absolute index in this buffer.
 void setLong(int index, long value)
          Sets the specified 64-bit long integer at the specified absolute index in this buffer.
 void setMedium(int index, int value)
          Sets the specified 24-bit medium integer at the specified absolute index in this buffer.
 void setShort(int index, short value)
          Sets the specified 16-bit short integer at the specified absolute index in this buffer.
 
Methods inherited from class org.jboss.netty.buffer.HeapChannelBuffer
capacity, getByte, getBytes, getBytes, getBytes, getBytes, getBytes, setByte, setBytes, setBytes, setBytes, setBytes, setBytes, slice, toByteBuffer, toString
 
Methods inherited from class org.jboss.netty.buffer.AbstractChannelBuffer
checkReadableBytes, clear, compareTo, copy, discardReadBytes, equals, getBytes, getBytes, getBytes, getMedium, getUnsignedByte, getUnsignedInt, getUnsignedShort, hashCode, indexOf, indexOf, markReaderIndex, markWriterIndex, readable, readableBytes, readByte, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readerIndex, readerIndex, readInt, readLong, readMedium, readShort, readSlice, readSlice, readUnsignedByte, readUnsignedInt, readUnsignedMedium, readUnsignedShort, resetReaderIndex, resetWriterIndex, setBytes, setBytes, setBytes, setIndex, setZero, skipBytes, skipBytes, slice, toByteBuffer, toByteBuffers, toByteBuffers, toString, toString, toString, toString, writable, writableBytes, writeByte, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeInt, writeLong, writeMedium, writerIndex, writerIndex, writeShort, writeZero
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LittleEndianHeapChannelBuffer

public LittleEndianHeapChannelBuffer(int length)
Creates a new little-endian heap buffer with a newly allocated byte array.

Parameters:
length - the length of the new byte array

LittleEndianHeapChannelBuffer

public LittleEndianHeapChannelBuffer(byte[] array)
Creates a new little-endian heap buffer with an existing byte array.

Parameters:
array - the byte array to wrap
Method Detail

factory

public ChannelBufferFactory factory()
Description copied from interface: ChannelBuffer
Returns the factory which creates a ChannelBuffer whose type and default ByteOrder are same with this buffer.


order

public ByteOrder order()
Description copied from interface: ChannelBuffer
Returns the endianness of this buffer.


getShort

public short getShort(int index)
Description copied from interface: ChannelBuffer
Gets a 16-bit short integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.


getUnsignedMedium

public int getUnsignedMedium(int index)
Description copied from interface: ChannelBuffer
Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.


getInt

public int getInt(int index)
Description copied from interface: ChannelBuffer
Gets a 32-bit integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.


getLong

public long getLong(int index)
Description copied from interface: ChannelBuffer
Gets a 64-bit long integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.


setShort

public void setShort(int index,
                     short value)
Description copied from interface: ChannelBuffer
Sets the specified 16-bit short integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.


setMedium

public void setMedium(int index,
                      int value)
Description copied from interface: ChannelBuffer
Sets the specified 24-bit medium integer at the specified absolute index in this buffer. Please note that the most significant byte is ignored in the specified value. This method does not modify readerIndex or writerIndex of this buffer.


setInt

public void setInt(int index,
                   int value)
Description copied from interface: ChannelBuffer
Sets the specified 32-bit integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.


setLong

public void setLong(int index,
                    long value)
Description copied from interface: ChannelBuffer
Sets the specified 64-bit long integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.


duplicate

public ChannelBuffer duplicate()
Description copied from interface: ChannelBuffer
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 buf.slice(0, buf.capacity()). This method does not modify readerIndex or writerIndex of this buffer.


copy

public ChannelBuffer copy(int index,
                          int length)
Description copied from interface: ChannelBuffer
Returns a copy of this buffer's sub-region. Modifying the content of the returned buffer or this buffer does not affect each other at all. This method does not modify readerIndex or writerIndex of this buffer.



Copyright © 2008-2009 JBoss, by Red Hat. All Rights Reserved.