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 TypeMethodDescriptionint
capacity()
capacity
(int newCapacity) Changes the capacity of this buffer.protected abstract void
capacity0
(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()
byte
get()
get
(byte[] dst, int offset, int length) byte
get
(int index) char
getChar()
char
getChar
(int index) double
double
getDouble
(int index) float
getFloat()
float
getFloat
(int index) int
getInt()
int
getInt
(int index) long
getLong()
long
getLong
(int index) short
getShort()
short
getShort
(int index) boolean
Returns true if and only if autoExpand is turned on.boolean
isDirect()
boolean
int
limit()
limit
(int newLimit) mark()
int
Returns the position of the current mark.order()
int
position()
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:
isDirect
in classByteBuffer
- See Also:
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnly
in classByteBuffer
- See Also:
-
capacity
public int capacity()- Specified by:
capacity
in classByteBuffer
- See Also:
-
capacity
Description copied from class:ByteBuffer
Changes the capacity of this buffer.- Specified by:
capacity
in 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:ByteBuffer
Returns true if and only if autoExpand is turned on.- Specified by:
isAutoExpand
in classByteBuffer
-
setAutoExpand
Description copied from class:ByteBuffer
Turns on or off autoExpand.- Specified by:
setAutoExpand
in classByteBuffer
-
expand
Description copied from class:ByteBuffer
Changes 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:
expand
in classByteBuffer
-
position
public int position()- Specified by:
position
in classByteBuffer
- See Also:
-
position
- Specified by:
position
in classByteBuffer
- See Also:
-
limit
public int limit()- Specified by:
limit
in classByteBuffer
- See Also:
-
limit
- Specified by:
limit
in classByteBuffer
- See Also:
-
mark
- Specified by:
mark
in classByteBuffer
- See Also:
-
markValue
public int markValue()Description copied from class:ByteBuffer
Returns the position of the current mark. This method returns -1 if no mark is set.- Specified by:
markValue
in classByteBuffer
-
reset
- Specified by:
reset
in classByteBuffer
- See Also:
-
clear
- Specified by:
clear
in classByteBuffer
- See Also:
-
flip
- Specified by:
flip
in classByteBuffer
- See Also:
-
rewind
- Specified by:
rewind
in classByteBuffer
- See Also:
-
get
public byte get()- Specified by:
get
in classByteBuffer
- See Also:
-
put
- Specified by:
put
in classByteBuffer
- See Also:
-
get
public byte get(int index) - Specified by:
get
in classByteBuffer
- See Also:
-
put
- Specified by:
put
in classByteBuffer
- See Also:
-
get
- Specified by:
get
in classByteBuffer
- See Also:
-
put
Description copied from class:ByteBuffer
Writes the content of the specified src into this buffer.- Specified by:
put
in classByteBuffer
-
put
- Specified by:
put
in classByteBuffer
- See Also:
-
compact
- Specified by:
compact
in classByteBuffer
- See Also:
-
order
- Specified by:
order
in classByteBuffer
- See Also:
-
order
- Specified by:
order
in classByteBuffer
- See Also:
-
getChar
public char getChar()- Specified by:
getChar
in classByteBuffer
- See Also:
-
putChar
- Specified by:
putChar
in classByteBuffer
- See Also:
-
getChar
public char getChar(int index) - Specified by:
getChar
in classByteBuffer
- See Also:
-
putChar
- Specified by:
putChar
in classByteBuffer
- See Also:
-
asCharBuffer
- Specified by:
asCharBuffer
in classByteBuffer
- See Also:
-
getShort
public short getShort()- Specified by:
getShort
in classByteBuffer
- See Also:
-
putShort
- Specified by:
putShort
in classByteBuffer
- See Also:
-
getShort
public short getShort(int index) - Specified by:
getShort
in classByteBuffer
- See Also:
-
putShort
- Specified by:
putShort
in classByteBuffer
- See Also:
-
asShortBuffer
- Specified by:
asShortBuffer
in classByteBuffer
- See Also:
-
getInt
public int getInt()- Specified by:
getInt
in classByteBuffer
- See Also:
-
putInt
- Specified by:
putInt
in classByteBuffer
- See Also:
-
getInt
public int getInt(int index) - Specified by:
getInt
in classByteBuffer
- See Also:
-
putInt
- Specified by:
putInt
in classByteBuffer
- See Also:
-
asIntBuffer
- Specified by:
asIntBuffer
in classByteBuffer
- See Also:
-
getLong
public long getLong()- Specified by:
getLong
in classByteBuffer
- See Also:
-
putLong
- Specified by:
putLong
in classByteBuffer
- See Also:
-
getLong
public long getLong(int index) - Specified by:
getLong
in classByteBuffer
- See Also:
-
putLong
- Specified by:
putLong
in classByteBuffer
- See Also:
-
asLongBuffer
- Specified by:
asLongBuffer
in classByteBuffer
- See Also:
-
getFloat
public float getFloat()- Specified by:
getFloat
in classByteBuffer
- See Also:
-
putFloat
- Specified by:
putFloat
in classByteBuffer
- See Also:
-
getFloat
public float getFloat(int index) - Specified by:
getFloat
in classByteBuffer
- See Also:
-
putFloat
- Specified by:
putFloat
in classByteBuffer
- See Also:
-
asFloatBuffer
- Specified by:
asFloatBuffer
in classByteBuffer
- See Also:
-
getDouble
public double getDouble()- Specified by:
getDouble
in classByteBuffer
- See Also:
-
putDouble
- Specified by:
putDouble
in classByteBuffer
- See Also:
-
getDouble
public double getDouble(int index) - Specified by:
getDouble
in classByteBuffer
- See Also:
-
putDouble
- Specified by:
putDouble
in classByteBuffer
- See Also:
-
asDoubleBuffer
- Specified by:
asDoubleBuffer
in classByteBuffer
- See Also:
-