Package org.apache.mina.common.support
Class BaseByteBuffer
java.lang.Object
org.apache.mina.common.ByteBuffer
org.apache.mina.common.support.BaseByteBuffer
- All Implemented Interfaces:
Comparable<ByteBuffer>
A base implementation of
ByteBuffer. This implementation
assumes that ByteBuffer.buf() always returns a correct NIO
ByteBuffer instance. Most implementations could
extend this class and implement their own buffer management mechanism.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcapacity()capacity(int newCapacity) Changes the capacity of this buffer.protected abstract voidcapacity0(int newCapacity) Implement this method to increase the capacity of this buffer.clear()compact()expand(int pos, int expectedRemaining) Changes the capacity and limit of this buffer so this buffer get the specified expectedRemaining room from the specified pos.flip()byteget()get(byte[] dst, int offset, int length) byteget(int index) chargetChar()chargetChar(int index) doubledoublegetDouble(int index) floatgetFloat()floatgetFloat(int index) intgetInt()intgetInt(int index) longgetLong()longgetLong(int index) shortgetShort()shortgetShort(int index) booleanReturns true if and only if autoExpand is turned on.booleanisDirect()booleanintlimit()limit(int newLimit) mark()intReturns the position of the current mark.order()intposition()position(int newPosition) put(byte b) put(byte[] src, int offset, int length) put(int index, byte b) put(ByteBuffer src) Writes the content of the specified src into this buffer.putChar(char value) putChar(int index, char value) putDouble(double value) putDouble(int index, double value) putFloat(float value) putFloat(int index, float value) putInt(int value) putInt(int index, int value) putLong(int index, long value) putLong(long value) putShort(int index, short value) putShort(short value) reset()rewind()setAutoExpand(boolean autoExpand) Turns on or off autoExpand.Methods inherited from class org.apache.mina.common.ByteBuffer
acquire, allocate, allocate, array, arrayOffset, asInputStream, asOutputStream, asReadOnlyBuffer, autoExpand, autoExpand, buf, compareTo, duplicate, equals, expand, fill, fill, fillAndReset, fillAndReset, get, getAllocator, getHexDump, getObject, getObject, getPrefixedString, getPrefixedString, getString, getString, getUnsigned, getUnsigned, getUnsignedInt, getUnsignedInt, getUnsignedShort, getUnsignedShort, hashCode, hasRemaining, isPooled, isUseDirectBuffers, prefixedDataAvailable, prefixedDataAvailable, put, put, putObject, putPrefixedString, putPrefixedString, putPrefixedString, putPrefixedString, putString, putString, release, remaining, setAllocator, setPooled, setUseDirectBuffers, skip, slice, sweep, sweep, toString, wrap, wrap, wrap
-
Constructor Details
-
BaseByteBuffer
protected BaseByteBuffer()
-
-
Method Details
-
isDirect
public boolean isDirect()- Specified by:
isDirectin classByteBuffer- See Also:
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnlyin classByteBuffer- See Also:
-
capacity
public int capacity()- Specified by:
capacityin classByteBuffer- See Also:
-
capacity
Description copied from class:ByteBufferChanges the capacity of this buffer.- Specified by:
capacityin classByteBuffer
-
capacity0
protected abstract void capacity0(int newCapacity) Implement this method to increase the capacity of this buffer. newCapacity is always greater than the current capacity. -
isAutoExpand
public boolean isAutoExpand()Description copied from class:ByteBufferReturns true if and only if autoExpand is turned on.- Specified by:
isAutoExpandin classByteBuffer
-
setAutoExpand
Description copied from class:ByteBufferTurns on or off autoExpand.- Specified by:
setAutoExpandin classByteBuffer
-
expand
Description copied from class:ByteBufferChanges the capacity and limit of this buffer so this buffer get the specified expectedRemaining room from the specified pos. This method works even if you didn't set autoExpand to true.- Specified by:
expandin classByteBuffer
-
position
public int position()- Specified by:
positionin classByteBuffer- See Also:
-
position
- Specified by:
positionin classByteBuffer- See Also:
-
limit
public int limit()- Specified by:
limitin classByteBuffer- See Also:
-
limit
- Specified by:
limitin classByteBuffer- See Also:
-
mark
- Specified by:
markin classByteBuffer- See Also:
-
markValue
public int markValue()Description copied from class:ByteBufferReturns the position of the current mark. This method returns -1 if no mark is set.- Specified by:
markValuein classByteBuffer
-
reset
- Specified by:
resetin classByteBuffer- See Also:
-
clear
- Specified by:
clearin classByteBuffer- See Also:
-
flip
- Specified by:
flipin classByteBuffer- See Also:
-
rewind
- Specified by:
rewindin classByteBuffer- See Also:
-
get
public byte get()- Specified by:
getin classByteBuffer- See Also:
-
put
- Specified by:
putin classByteBuffer- See Also:
-
get
public byte get(int index) - Specified by:
getin classByteBuffer- See Also:
-
put
- Specified by:
putin classByteBuffer- See Also:
-
get
- Specified by:
getin classByteBuffer- See Also:
-
put
Description copied from class:ByteBufferWrites the content of the specified src into this buffer.- Specified by:
putin classByteBuffer
-
put
- Specified by:
putin classByteBuffer- See Also:
-
compact
- Specified by:
compactin classByteBuffer- See Also:
-
order
- Specified by:
orderin classByteBuffer- See Also:
-
order
- Specified by:
orderin classByteBuffer- See Also:
-
getChar
public char getChar()- Specified by:
getCharin classByteBuffer- See Also:
-
putChar
- Specified by:
putCharin classByteBuffer- See Also:
-
getChar
public char getChar(int index) - Specified by:
getCharin classByteBuffer- See Also:
-
putChar
- Specified by:
putCharin classByteBuffer- See Also:
-
asCharBuffer
- Specified by:
asCharBufferin classByteBuffer- See Also:
-
getShort
public short getShort()- Specified by:
getShortin classByteBuffer- See Also:
-
putShort
- Specified by:
putShortin classByteBuffer- See Also:
-
getShort
public short getShort(int index) - Specified by:
getShortin classByteBuffer- See Also:
-
putShort
- Specified by:
putShortin classByteBuffer- See Also:
-
asShortBuffer
- Specified by:
asShortBufferin classByteBuffer- See Also:
-
getInt
public int getInt()- Specified by:
getIntin classByteBuffer- See Also:
-
putInt
- Specified by:
putIntin classByteBuffer- See Also:
-
getInt
public int getInt(int index) - Specified by:
getIntin classByteBuffer- See Also:
-
putInt
- Specified by:
putIntin classByteBuffer- See Also:
-
asIntBuffer
- Specified by:
asIntBufferin classByteBuffer- See Also:
-
getLong
public long getLong()- Specified by:
getLongin classByteBuffer- See Also:
-
putLong
- Specified by:
putLongin classByteBuffer- See Also:
-
getLong
public long getLong(int index) - Specified by:
getLongin classByteBuffer- See Also:
-
putLong
- Specified by:
putLongin classByteBuffer- See Also:
-
asLongBuffer
- Specified by:
asLongBufferin classByteBuffer- See Also:
-
getFloat
public float getFloat()- Specified by:
getFloatin classByteBuffer- See Also:
-
putFloat
- Specified by:
putFloatin classByteBuffer- See Also:
-
getFloat
public float getFloat(int index) - Specified by:
getFloatin classByteBuffer- See Also:
-
putFloat
- Specified by:
putFloatin classByteBuffer- See Also:
-
asFloatBuffer
- Specified by:
asFloatBufferin classByteBuffer- See Also:
-
getDouble
public double getDouble()- Specified by:
getDoublein classByteBuffer- See Also:
-
putDouble
- Specified by:
putDoublein classByteBuffer- See Also:
-
getDouble
public double getDouble(int index) - Specified by:
getDoublein classByteBuffer- See Also:
-
putDouble
- Specified by:
putDoublein classByteBuffer- See Also:
-
asDoubleBuffer
- Specified by:
asDoubleBufferin classByteBuffer- See Also:
-