Package org.jboss.netty.buffer
Class HeapChannelBufferFactory
java.lang.Object
org.jboss.netty.buffer.AbstractChannelBufferFactory
org.jboss.netty.buffer.HeapChannelBufferFactory
- All Implemented Interfaces:
ChannelBufferFactory
A
ChannelBufferFactory
which merely allocates a heap buffer with
the specified capacity. HeapChannelBufferFactory
should perform
very well in most situations because it relies on the JVM garbage collector,
which is highly optimized for heap allocation.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final HeapChannelBufferFactory
private static final HeapChannelBufferFactory
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new factory whose defaultByteOrder
isByteOrder.BIG_ENDIAN
.HeapChannelBufferFactory
(ByteOrder defaultOrder) Creates a new factory with the specified defaultByteOrder
. -
Method Summary
Modifier and TypeMethodDescriptiongetBuffer
(ByteBuffer nioBuffer) Returns aChannelBuffer
whose content is equal to the sub-region of the specifiednioBuffer
.Returns aChannelBuffer
whose content is equal to the sub-region of the specifiedarray
.static ChannelBufferFactory
static ChannelBufferFactory
getInstance
(ByteOrder endianness) Methods inherited from class org.jboss.netty.buffer.AbstractChannelBufferFactory
getBuffer, getBuffer, getDefaultOrder
-
Field Details
-
INSTANCE_BE
-
INSTANCE_LE
-
-
Constructor Details
-
HeapChannelBufferFactory
public HeapChannelBufferFactory()Creates a new factory whose defaultByteOrder
isByteOrder.BIG_ENDIAN
. -
HeapChannelBufferFactory
Creates a new factory with the specified defaultByteOrder
.- Parameters:
defaultOrder
- the defaultByteOrder
of this factory
-
-
Method Details
-
getInstance
-
getInstance
-
getBuffer
Description copied from interface:ChannelBufferFactory
- Parameters:
order
- the endianness of the returnedChannelBuffer
capacity
- the capacity of the returnedChannelBuffer
- Returns:
- a
ChannelBuffer
with the specifiedendianness
andcapacity
, whosereaderIndex
andwriterIndex
are0
-
getBuffer
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
.- Parameters:
order
- the endianness of the returnedChannelBuffer
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
-
getBuffer
Description copied from interface:ChannelBufferFactory
Returns aChannelBuffer
whose content is equal to the sub-region of the specifiednioBuffer
. Depending on the factory implementation, the returned buffer could wrap thenioBuffer
or create a new copy of thenioBuffer
.- Parameters:
nioBuffer
- the NIOByteBuffer
- Returns:
- a
ChannelBuffer
with the specified content, whosereaderIndex
andwriterIndex
are0
andnioBuffer.remaining()
respectively
-