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:
java.lang.Comparable<ByteBuffer>
public abstract class BaseByteBuffer extends ByteBuffer
A base implementation ofByteBuffer
. This implementation assumes thatByteBuffer.buf()
always returns a correct NIOByteBuffer
instance. Most implementations could extend this class and implement their own buffer management mechanism.- See Also:
ByteBufferAllocator
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseByteBuffer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.nio.CharBuffer
asCharBuffer()
java.nio.DoubleBuffer
asDoubleBuffer()
java.nio.FloatBuffer
asFloatBuffer()
java.nio.IntBuffer
asIntBuffer()
java.nio.LongBuffer
asLongBuffer()
java.nio.ShortBuffer
asShortBuffer()
int
capacity()
ByteBuffer
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.ByteBuffer
clear()
ByteBuffer
compact()
ByteBuffer
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.ByteBuffer
flip()
byte
get()
ByteBuffer
get(byte[] dst, int offset, int length)
byte
get(int index)
char
getChar()
char
getChar(int index)
double
getDouble()
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
isAutoExpand()
Returns true if and only if autoExpand is turned on.boolean
isDirect()
boolean
isReadOnly()
int
limit()
ByteBuffer
limit(int newLimit)
ByteBuffer
mark()
int
markValue()
Returns the position of the current mark.java.nio.ByteOrder
order()
ByteBuffer
order(java.nio.ByteOrder bo)
int
position()
ByteBuffer
position(int newPosition)
ByteBuffer
put(byte b)
ByteBuffer
put(byte[] src, int offset, int length)
ByteBuffer
put(int index, byte b)
ByteBuffer
put(java.nio.ByteBuffer src)
Writes the content of the specified src into this buffer.ByteBuffer
putChar(char value)
ByteBuffer
putChar(int index, char value)
ByteBuffer
putDouble(double value)
ByteBuffer
putDouble(int index, double value)
ByteBuffer
putFloat(float value)
ByteBuffer
putFloat(int index, float value)
ByteBuffer
putInt(int value)
ByteBuffer
putInt(int index, int value)
ByteBuffer
putLong(int index, long value)
ByteBuffer
putLong(long value)
ByteBuffer
putShort(int index, short value)
ByteBuffer
putShort(short value)
ByteBuffer
reset()
ByteBuffer
rewind()
ByteBuffer
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
-
-
-
-
Method Detail
-
isDirect
public boolean isDirect()
- Specified by:
isDirect
in classByteBuffer
- See Also:
ByteBuffer.isDirect()
-
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnly
in classByteBuffer
- See Also:
Buffer.isReadOnly()
-
capacity
public int capacity()
- Specified by:
capacity
in classByteBuffer
- See Also:
Buffer.capacity()
-
capacity
public ByteBuffer capacity(int newCapacity)
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
public ByteBuffer setAutoExpand(boolean autoExpand)
Description copied from class:ByteBuffer
Turns on or off autoExpand.- Specified by:
setAutoExpand
in classByteBuffer
-
expand
public ByteBuffer expand(int pos, int expectedRemaining)
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:
Buffer.position()
-
position
public ByteBuffer position(int newPosition)
- Specified by:
position
in classByteBuffer
- See Also:
Buffer.position(int)
-
limit
public int limit()
- Specified by:
limit
in classByteBuffer
- See Also:
Buffer.limit()
-
limit
public ByteBuffer limit(int newLimit)
- Specified by:
limit
in classByteBuffer
- See Also:
Buffer.limit(int)
-
mark
public ByteBuffer mark()
- Specified by:
mark
in classByteBuffer
- See Also:
Buffer.mark()
-
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
public ByteBuffer reset()
- Specified by:
reset
in classByteBuffer
- See Also:
Buffer.reset()
-
clear
public ByteBuffer clear()
- Specified by:
clear
in classByteBuffer
- See Also:
Buffer.clear()
-
flip
public ByteBuffer flip()
- Specified by:
flip
in classByteBuffer
- See Also:
Buffer.flip()
-
rewind
public ByteBuffer rewind()
- Specified by:
rewind
in classByteBuffer
- See Also:
Buffer.rewind()
-
get
public byte get()
- Specified by:
get
in classByteBuffer
- See Also:
ByteBuffer.get()
-
put
public ByteBuffer put(byte b)
- Specified by:
put
in classByteBuffer
- See Also:
ByteBuffer.put(byte)
-
get
public byte get(int index)
- Specified by:
get
in classByteBuffer
- See Also:
ByteBuffer.get(int)
-
put
public ByteBuffer put(int index, byte b)
- Specified by:
put
in classByteBuffer
- See Also:
ByteBuffer.put(int, byte)
-
get
public ByteBuffer get(byte[] dst, int offset, int length)
- Specified by:
get
in classByteBuffer
- See Also:
ByteBuffer.get(byte[], int, int)
-
put
public ByteBuffer put(java.nio.ByteBuffer src)
Description copied from class:ByteBuffer
Writes the content of the specified src into this buffer.- Specified by:
put
in classByteBuffer
-
put
public ByteBuffer put(byte[] src, int offset, int length)
- Specified by:
put
in classByteBuffer
- See Also:
ByteBuffer.put(byte[], int, int)
-
compact
public ByteBuffer compact()
- Specified by:
compact
in classByteBuffer
- See Also:
ByteBuffer.compact()
-
order
public java.nio.ByteOrder order()
- Specified by:
order
in classByteBuffer
- See Also:
ByteBuffer.order()
-
order
public ByteBuffer order(java.nio.ByteOrder bo)
- Specified by:
order
in classByteBuffer
- See Also:
ByteBuffer.order(ByteOrder)
-
getChar
public char getChar()
- Specified by:
getChar
in classByteBuffer
- See Also:
ByteBuffer.getChar()
-
putChar
public ByteBuffer putChar(char value)
- Specified by:
putChar
in classByteBuffer
- See Also:
ByteBuffer.putChar(char)
-
getChar
public char getChar(int index)
- Specified by:
getChar
in classByteBuffer
- See Also:
ByteBuffer.getChar(int)
-
putChar
public ByteBuffer putChar(int index, char value)
- Specified by:
putChar
in classByteBuffer
- See Also:
ByteBuffer.putChar(int, char)
-
asCharBuffer
public java.nio.CharBuffer asCharBuffer()
- Specified by:
asCharBuffer
in classByteBuffer
- See Also:
ByteBuffer.asCharBuffer()
-
getShort
public short getShort()
- Specified by:
getShort
in classByteBuffer
- See Also:
ByteBuffer.getShort()
-
putShort
public ByteBuffer putShort(short value)
- Specified by:
putShort
in classByteBuffer
- See Also:
ByteBuffer.putShort(short)
-
getShort
public short getShort(int index)
- Specified by:
getShort
in classByteBuffer
- See Also:
ByteBuffer.getShort()
-
putShort
public ByteBuffer putShort(int index, short value)
- Specified by:
putShort
in classByteBuffer
- See Also:
ByteBuffer.putShort(int, short)
-
asShortBuffer
public java.nio.ShortBuffer asShortBuffer()
- Specified by:
asShortBuffer
in classByteBuffer
- See Also:
ByteBuffer.asShortBuffer()
-
getInt
public int getInt()
- Specified by:
getInt
in classByteBuffer
- See Also:
ByteBuffer.getInt()
-
putInt
public ByteBuffer putInt(int value)
- Specified by:
putInt
in classByteBuffer
- See Also:
ByteBuffer.putInt(int)
-
getInt
public int getInt(int index)
- Specified by:
getInt
in classByteBuffer
- See Also:
ByteBuffer.getInt(int)
-
putInt
public ByteBuffer putInt(int index, int value)
- Specified by:
putInt
in classByteBuffer
- See Also:
ByteBuffer.putInt(int, int)
-
asIntBuffer
public java.nio.IntBuffer asIntBuffer()
- Specified by:
asIntBuffer
in classByteBuffer
- See Also:
ByteBuffer.asIntBuffer()
-
getLong
public long getLong()
- Specified by:
getLong
in classByteBuffer
- See Also:
ByteBuffer.getLong()
-
putLong
public ByteBuffer putLong(long value)
- Specified by:
putLong
in classByteBuffer
- See Also:
ByteBuffer.putLong(int, long)
-
getLong
public long getLong(int index)
- Specified by:
getLong
in classByteBuffer
- See Also:
ByteBuffer.getLong(int)
-
putLong
public ByteBuffer putLong(int index, long value)
- Specified by:
putLong
in classByteBuffer
- See Also:
ByteBuffer.putLong(int, long)
-
asLongBuffer
public java.nio.LongBuffer asLongBuffer()
- Specified by:
asLongBuffer
in classByteBuffer
- See Also:
ByteBuffer.asLongBuffer()
-
getFloat
public float getFloat()
- Specified by:
getFloat
in classByteBuffer
- See Also:
ByteBuffer.getFloat()
-
putFloat
public ByteBuffer putFloat(float value)
- Specified by:
putFloat
in classByteBuffer
- See Also:
ByteBuffer.putFloat(float)
-
getFloat
public float getFloat(int index)
- Specified by:
getFloat
in classByteBuffer
- See Also:
ByteBuffer.getFloat(int)
-
putFloat
public ByteBuffer putFloat(int index, float value)
- Specified by:
putFloat
in classByteBuffer
- See Also:
ByteBuffer.putFloat(int, float)
-
asFloatBuffer
public java.nio.FloatBuffer asFloatBuffer()
- Specified by:
asFloatBuffer
in classByteBuffer
- See Also:
ByteBuffer.asFloatBuffer()
-
getDouble
public double getDouble()
- Specified by:
getDouble
in classByteBuffer
- See Also:
ByteBuffer.getDouble()
-
putDouble
public ByteBuffer putDouble(double value)
- Specified by:
putDouble
in classByteBuffer
- See Also:
ByteBuffer.putDouble(double)
-
getDouble
public double getDouble(int index)
- Specified by:
getDouble
in classByteBuffer
- See Also:
ByteBuffer.getDouble(int)
-
putDouble
public ByteBuffer putDouble(int index, double value)
- Specified by:
putDouble
in classByteBuffer
- See Also:
ByteBuffer.putDouble(int, double)
-
asDoubleBuffer
public java.nio.DoubleBuffer asDoubleBuffer()
- Specified by:
asDoubleBuffer
in classByteBuffer
- See Also:
ByteBuffer.asDoubleBuffer()
-
-