Package org.jboss.netty.buffer
Class AbstractChannelBufferFactory
- java.lang.Object
-
- org.jboss.netty.buffer.AbstractChannelBufferFactory
-
- All Implemented Interfaces:
ChannelBufferFactory
- Direct Known Subclasses:
DirectChannelBufferFactory
,HeapChannelBufferFactory
public abstract class AbstractChannelBufferFactory extends Object implements ChannelBufferFactory
A skeletal implementation ofChannelBufferFactory
.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractChannelBufferFactory()
Creates a new factory whose defaultByteOrder
isByteOrder.BIG_ENDIAN
.protected
AbstractChannelBufferFactory(ByteOrder defaultOrder)
Creates a new factory with the specified defaultByteOrder
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChannelBuffer
getBuffer(byte[] array, int offset, int length)
Returns aChannelBuffer
whose content is equal to the sub-region of the specifiedarray
.ChannelBuffer
getBuffer(int capacity)
Returns aChannelBuffer
with the specifiedcapacity
.ByteOrder
getDefaultOrder()
Returns the default endianness of theChannelBuffer
which is returned byChannelBufferFactory.getBuffer(int)
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.netty.buffer.ChannelBufferFactory
getBuffer, getBuffer, getBuffer
-
-
-
-
Constructor Detail
-
AbstractChannelBufferFactory
protected AbstractChannelBufferFactory()
Creates a new factory whose defaultByteOrder
isByteOrder.BIG_ENDIAN
.
-
-
Method Detail
-
getBuffer
public ChannelBuffer getBuffer(int capacity)
Description copied from interface:ChannelBufferFactory
Returns aChannelBuffer
with the specifiedcapacity
. This method is identical togetBuffer(getDefaultOrder(), capacity)
.- Specified by:
getBuffer
in interfaceChannelBufferFactory
- Parameters:
capacity
- the capacity of the returnedChannelBuffer
- Returns:
- a
ChannelBuffer
with the specifiedcapacity
, whosereaderIndex
andwriterIndex
are0
-
getBuffer
public ChannelBuffer getBuffer(byte[] array, int offset, int length)
Description copied from interface:ChannelBufferFactory
Returns aChannelBuffer
whose content is equal to the sub-region of the specifiedarray
. Depending on the factory implementation, the returned buffer could wrap thearray
or create a new copy of thearray
. This method is identical togetBuffer(getDefaultOrder(), array, offset, length)
.- Specified by:
getBuffer
in interfaceChannelBufferFactory
- Parameters:
array
- the byte arrayoffset
- the offset of the byte arraylength
- the length of the byte array- Returns:
- a
ChannelBuffer
with the specified content, whosereaderIndex
andwriterIndex
are0
and(length - offset)
respectively
-
getDefaultOrder
public ByteOrder getDefaultOrder()
Description copied from interface:ChannelBufferFactory
Returns the default endianness of theChannelBuffer
which is returned byChannelBufferFactory.getBuffer(int)
.- Specified by:
getDefaultOrder
in interfaceChannelBufferFactory
- Returns:
- the default endianness of the
ChannelBuffer
which is returned byChannelBufferFactory.getBuffer(int)
-
-