Package org.jboss.netty.buffer
Interface ChannelBufferFactory
- All Known Implementing Classes:
AbstractChannelBufferFactory
,DirectChannelBufferFactory
,HeapChannelBufferFactory
public interface ChannelBufferFactory
A factory that creates or pools
ChannelBuffer
s.-
Method Summary
Modifier and TypeMethodDescriptiongetBuffer
(byte[] array, int offset, int length) Returns aChannelBuffer
whose content is equal to the sub-region of the specifiedarray
.getBuffer
(int capacity) Returns aChannelBuffer
with the specifiedcapacity
.getBuffer
(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
.Returns the default endianness of theChannelBuffer
which is returned bygetBuffer(int)
.
-
Method Details
-
getBuffer
Returns aChannelBuffer
with the specifiedcapacity
. This method is identical togetBuffer(getDefaultOrder(), capacity)
.- Parameters:
capacity
- the capacity of the returnedChannelBuffer
- Returns:
- a
ChannelBuffer
with the specifiedcapacity
, whosereaderIndex
andwriterIndex
are0
-
getBuffer
- Parameters:
endianness
- the endianness of the returnedChannelBuffer
capacity
- the capacity of the returnedChannelBuffer
- Returns:
- a
ChannelBuffer
with the specifiedendianness
andcapacity
, whosereaderIndex
andwriterIndex
are0
-
getBuffer
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)
.- 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
-
getBuffer
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:
endianness
- 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
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
-
getDefaultOrder
ByteOrder getDefaultOrder()Returns the default endianness of theChannelBuffer
which is returned bygetBuffer(int)
.- Returns:
- the default endianness of the
ChannelBuffer
which is returned bygetBuffer(int)
-