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 java.lang.Object implements ChannelBufferFactory
A skeletal implementation ofChannelBufferFactory.
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteOrderdefaultOrder
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractChannelBufferFactory()Creates a new factory whose defaultByteOrderisByteOrder.BIG_ENDIAN.protectedAbstractChannelBufferFactory(java.nio.ByteOrder defaultOrder)Creates a new factory with the specified defaultByteOrder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChannelBuffergetBuffer(byte[] array, int offset, int length)Returns aChannelBufferwhose content is equal to the sub-region of the specifiedarray.ChannelBuffergetBuffer(int capacity)Returns aChannelBufferwith the specifiedcapacity.java.nio.ByteOrdergetDefaultOrder()Returns the default endianness of theChannelBufferwhich 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 defaultByteOrderisByteOrder.BIG_ENDIAN.
-
AbstractChannelBufferFactory
protected AbstractChannelBufferFactory(java.nio.ByteOrder defaultOrder)
Creates a new factory with the specified defaultByteOrder.- Parameters:
defaultOrder- the defaultByteOrderof this factory
-
-
Method Detail
-
getBuffer
public ChannelBuffer getBuffer(int capacity)
Description copied from interface:ChannelBufferFactoryReturns aChannelBufferwith the specifiedcapacity. This method is identical togetBuffer(getDefaultOrder(), capacity).- Specified by:
getBufferin interfaceChannelBufferFactory- Parameters:
capacity- the capacity of the returnedChannelBuffer- Returns:
- a
ChannelBufferwith the specifiedcapacity, whosereaderIndexandwriterIndexare0
-
getBuffer
public ChannelBuffer getBuffer(byte[] array, int offset, int length)
Description copied from interface:ChannelBufferFactoryReturns aChannelBufferwhose content is equal to the sub-region of the specifiedarray. Depending on the factory implementation, the returned buffer could wrap thearrayor create a new copy of thearray. This method is identical togetBuffer(getDefaultOrder(), array, offset, length).- Specified by:
getBufferin interfaceChannelBufferFactory- Parameters:
array- the byte arrayoffset- the offset of the byte arraylength- the length of the byte array- Returns:
- a
ChannelBufferwith the specified content, whosereaderIndexandwriterIndexare0and(length - offset)respectively
-
getDefaultOrder
public java.nio.ByteOrder getDefaultOrder()
Description copied from interface:ChannelBufferFactoryReturns the default endianness of theChannelBufferwhich is returned byChannelBufferFactory.getBuffer(int).- Specified by:
getDefaultOrderin interfaceChannelBufferFactory- Returns:
- the default endianness of the
ChannelBufferwhich is returned byChannelBufferFactory.getBuffer(int)
-
-